Skip to content

update the release workflow #3

update the release workflow

update the release workflow #3

Workflow file for this run

name: Build and Release
on:
push:
tags:
- 'v*'
jobs:
build:
strategy:
matrix:
target: [ x86_64-unknown-linux-gnu, x86_64-pc-windows-gnu, x86_64-apple-darwin ]
runner: [ ubuntu-latest, ubuntu-latest, macos-latest ]
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Rust
run: rustup target add ${{ matrix.target }}
- name: Install cross (Linux/Windows only)
if: matrix.target != 'x86_64-apple-darwin'
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Install OpenSSL (macOS only)
if: matrix.target == 'x86_64-apple-darwin'
run: |
brew install openssl
export OPENSSL_DIR="$(brew --prefix openssl)"
echo "OPENSSL_DIR=${OPENSSL_DIR}" >> $GITHUB_ENV
- name: Build binary
env:
OPENSSL_DIR: ${{ env.OPENSSL_DIR }} # Set for macOS to locate OpenSSL
run: |
if [ "${{ matrix.target }}" = "x86_64-apple-darwin" ]; then
cargo build --release --target ${{ matrix.target }};
else
cross build --release --target ${{ matrix.target }};
- name: Rename binary for Windows
if: matrix.target == 'x86_64-pc-windows-gnu'
run: mv target/${{ matrix.target }}/release/affected target/${{ matrix.target }}/release/affected.exe
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.target }}
path: |
target/${{ matrix.target }}/release/affected*
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: ${{ matrix.target }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: |
target/x86_64-unknown-linux-gnu/release/affected
target/x86_64-pc-windows-gnu/release/affected.exe
target/x86_64-apple-darwin/release/affected
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}