name: Build and test
on:
push:
branches:
- main
tags:
- v*
pull_request:
branches:
- main
permissions:
contents: write
packages: write
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ${{ matrix.job.os }}
strategy:
matrix:
job:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
protoc: linux-x86_64
gcc: gcc-x86-64-linux-gnu
publish: true
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
protoc: linux-x86_64
gcc: gcc-aarch64-linux-gnu
- os: macos-latest
target: x86_64-apple-darwin
protoc: osx-x86_64
- os: macos-latest
target: aarch64-apple-darwin
protoc: osx-x86_64
steps:
- uses: actions/checkout@v4
- run: |
cd $(mktemp -d)
wget https://github.com/protocolbuffers/protobuf/releases/download/v26.0/protoc-26.0-${{ matrix.job.protoc }}.zip
unzip protoc-26.0-${{ matrix.job.protoc }}.zip
sudo mv bin/protoc /usr/local/bin/
- run: rustup target add ${{ matrix.job.target }}
- run: sudo apt-get install -y ${{ matrix.job.gcc }}
if: ${{ matrix.job.os == 'ubuntu-latest' }}
- name: Build
run: |
cargo build --release --target ${{ matrix.job.target }}
mv target/${{ matrix.job.target }}/release/stablessh /tmp/stablessh-${{ matrix.job.target }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: stablessh-${{ matrix.job.target }}
path: /tmp/stablessh-${{ matrix.job.target }}
- name: Create release
id: create_release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: /tmp/stablessh-${{ matrix.job.target }}
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
- name: Publish crate
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && matrix.job.publish