feat: add customizable terminators #63
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build-binary | |
concurrency: | |
group: build-binary-${{ github.ref }} | |
cancel-in-progress: true | |
on: | |
release: | |
types: | |
- published | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
permissions: | |
contents: write | |
jobs: | |
build: | |
runs-on: ${{ matrix.image }} | |
strategy: | |
matrix: | |
include: | |
- image: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
- image: ubuntu-latest | |
target: x86_64-unknown-linux-musl | |
- image: macos-latest | |
target: x86_64-apple-darwin | |
- image: ubuntu-latest | |
target: x86_64-pc-windows-gnu | |
fail-fast: false | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Cache cargo | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Install Rust stable | |
run: | | |
rustup toolchain install stable --target ${{ matrix.target }} | |
- if: contains(matrix.target, 'windows') | |
name: Install Windows dependencies | |
run: | | |
sudo apt update | |
sudo apt install -y gcc-mingw-w64 | |
- if: contains(matrix.target, 'apple') | |
name: Install Apple dependencies | |
run: | | |
brew install openssl coreutils | |
- name: Build | |
run: | | |
cargo build --release --target ${{ matrix.target }} | |
- name: Get package name | |
id: package-name | |
run: | | |
cargo install --path . | |
echo "metadata=$(cargo get package.name)" >> $GITHUB_OUTPUT | |
- name: Get binary name | |
id: binary-name | |
run: | | |
if [[ "${{ matrix.target }}" == *"windows"* ]]; then | |
echo "binary-name=${{ steps.package-name.outputs.metadata }}.exe" >> $GITHUB_OUTPUT | |
else | |
echo "binary-name=${{ steps.package-name.outputs.metadata }}" >> $GITHUB_OUTPUT | |
fi | |
- name: Rename binary | |
run: | | |
cp target/${{ matrix.target }}/release/${{ steps.binary-name.outputs.binary-name }} target/${{ matrix.target }}/release/${{ steps.package-name.outputs.metadata }}-${{ matrix.target }} | |
- name: Checksum | |
run: | | |
cd target/${{ matrix.target }}/release | |
sha256sum ${{ steps.package-name.outputs.metadata }}-${{ matrix.target }} > ${{ steps.package-name.outputs.metadata }}-${{ matrix.target }}.sha256 | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ steps.package-name.outputs.metadata }}-${{ matrix.target }} | |
path: | | |
target/${{ matrix.target }}/release/${{ steps.package-name.outputs.metadata }}-${{ matrix.target }} | |
target/${{ matrix.target }}/release/${{ steps.package-name.outputs.metadata }}-${{ matrix.target }}.sha256 | |
if-no-files-found: error | |
- if: github.event_name == 'release' && github.event.action == 'published' | |
name: Upload assets | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
target/${{ matrix.target }}/release/${{ steps.package-name.outputs.metadata }}-${{ matrix.target }} | |
target/${{ matrix.target }}/release/${{ steps.package-name.outputs.metadata }}-${{ matrix.target }}.sha256 | |