name: Release build & publish on: release: types: [created] permissions: contents: write jobs: build-and-upload: strategy: matrix: target: - x86_64-unknown-linux-gnu - x86_64-apple-darwin - x86_64-pc-windows-msvc runs-on: ${{ matrix.target == 'x86_64-pc-windows-msvc' && 'windows-latest' || (matrix.target == 'x86_64-apple-darwin' && 'macos-latest' || 'ubuntu-latest') }} steps: - name: Check out sources uses: actions/checkout@v4 - name: Install Rust toolchain uses: actions-rust-lang/setup-rust-toolchain@v1 with: toolchain: stable target: ${{ matrix.target }} cache: true - name: Install target run: rustup target add ${{ matrix.target }} - name: Build (optimized) run: cargo build --release --target ${{ matrix.target }} - name: Package binary shell: bash run: | set -euo pipefail BIN=${{ env.BIN_NAME }} TARGET=${{ matrix.target }} EXT=$([[ "$TARGET" == *windows* ]] && echo ".exe" || echo "") BIN_PATH=target/$TARGET/release/$BIN$EXT if [[ ! -f "$BIN_PATH" ]]; then echo "::error ::Binary $BIN_PATH not found" ls -R target/$TARGET/release || true exit 1 fi mkdir -p dist ARCHIVE=$BIN-$TARGET.zip zip -9 "dist/$ARCHIVE" "$BIN_PATH" echo "ASSET=$ARCHIVE" >> "$GITHUB_ENV" - name: Upload to the release uses: softprops/action-gh-release@v2 with: files: dist/${{ env.ASSET }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}