name: release
on:
push:
branches:
- release*
tags:
- 'v*'
env:
NAME: zbr
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- id: release
uses: ncipollo/release-action@v1
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
with:
artifactErrorsFailBuild: true
body: "See [CHANGELOG.md](https://github.com/langston-barrett/${{ env.NAME }}/blob/main/CHANGELOG.md)."
draft: true
token: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to crates.io
env:
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
PUSH: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: |
if [[ ${PUSH} == true ]]; then
cargo publish --token ${CRATES_IO_TOKEN}
else
cargo publish --dry-run --token ${CRATES_IO_TOKEN}
fi
artifacts:
needs: release
runs-on: ${{ matrix.os }}
permissions:
contents: write
strategy:
matrix:
build: [linux-x86_64-gnu, linux-x86_64-musl, macos-x86_64]
include:
- build: linux-x86_64-gnu
os: ubuntu-latest
rust: stable
target: x86_64-unknown-linux-gnu
- build: linux-x86_64-musl
os: ubuntu-latest
rust: stable
target: x86_64-unknown-linux-musl
- build: macos-x86_64
os: macos-latest
rust: nightly
target: x86_64-apple-darwin
steps:
- uses: actions/checkout@v4
- name: Install rustup
shell: bash
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup-init.sh
sh rustup-init.sh -y --default-toolchain none
rustup target add ${{ matrix.target }}
- name: Add mingw64 to path for x86_64-gnu
run: echo "C:\msys64\mingw64\bin" >> $GITHUB_PATH
if: matrix.rust == 'nightly-x86_64-gnu'
shell: bash
- name: Deps
if: matrix.target == 'x86_64-unknown-linux-musl'
run: |
sudo apt-get install -y musl-tools
- name: Build executables
shell: bash
run: |
cargo build \
--bin ${{ env.NAME }} \
--locked \
--release \
--target=${{ matrix.target }}
- name: Upload binaries
uses: ncipollo/release-action@v1
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
with:
allowUpdates: true
artifactErrorsFailBuild: true
replacesArtifacts: false
artifacts: ${{ env.NAME }}_${{ matrix.target }}
body: "See [CHANGELOG.md](https://github.com/langston-barrett/${{ env.NAME }}/blob/main/CHANGELOG.md)."
draft: true
token: ${{ secrets.GITHUB_TOKEN }}