ci(release): enable macOS #17
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: release | |
permissions: | |
contents: write | |
on: | |
push: | |
tags: | |
- 'v[0-9]+.*' | |
env: | |
MACOSX_DEPLOYMENT_TARGET: '11.0' # Big Sur, first macOS release with Apple Silicon support | |
jobs: | |
create-release: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: extract version | |
shell: bash | |
run: | | |
VERSION_TAG="${{ github.ref_name }}" | |
VERSION="${VERSION_TAG#v}" | |
echo "VERSION=${VERSION}" >> $GITHUB_ENV | |
echo "Version: ${VERSION}" | |
if ! grep -q "version = \"$VERSION\"" Cargo.toml; then | |
exit 1 | |
fi | |
- name: create release | |
run: | | |
if gh release view "v${VERSION}" --json id; then | |
echo "release already exists" | |
else | |
gh release create "v${VERSION}" --draft --verify-tag --title "$VERSION" | |
fi | |
env: | |
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' | |
upload-binaries: | |
needs: create-release | |
strategy: | |
matrix: | |
include: | |
- target: x86_64-unknown-linux-musl | |
os: ubuntu-latest | |
features: rustls | |
- target: aarch64-unknown-linux-musl | |
os: ubuntu-latest | |
features: rustls | |
- target: aarch64-apple-darwin | |
os: macos-latest | |
- target: universal-apple-darwin | |
os: macos-latest | |
runs-on: ${{ matrix.os }} | |
steps: | |
- run: sudo apt-get install -y musl-tools | |
if: "${{ contains(matrix.target, '-musl') }}" | |
- run: sudo apt-get install -y protobuf-compiler | |
if: "${{ contains(matrix.target, '-linux-') }}" | |
- run: brew install protobuf | |
if: "${{ contains(matrix.target, '-apple-darwin') }}" | |
- uses: actions/checkout@v4 | |
- name: Install cross-compilation tools | |
uses: taiki-e/setup-cross-toolchain-action@v1 | |
with: | |
target: "${{ matrix.target }}" | |
- uses: taiki-e/upload-rust-binary-action@v1 | |
with: | |
bin: mairu | |
target: '${{ matrix.target }}' | |
tar: unix | |
no-default-features: true | |
features: ${{ matrix.features || 'default' }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
upload-debs: | |
needs: create-release | |
strategy: | |
matrix: | |
include: | |
- target: x86_64-unknown-linux-musl | |
os: ubuntu-latest | |
- target: aarch64-unknown-linux-musl | |
os: ubuntu-latest | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- run: sudo apt-get install -y musl-tools | |
if: "${{ contains(matrix.target, '-musl') }}" | |
- run: sudo apt-get install -y protobuf-compiler | |
if: "${{ contains(matrix.target, '-linux-') }}" | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: "${{ matrix.target }}" | |
- name: Install cross-compilation tools | |
uses: taiki-e/setup-cross-toolchain-action@v1 | |
with: | |
target: "${{ matrix.target }}" | |
- name: Configure cargo | |
shell: bash | |
run: | | |
mkdir -p .cargo | |
echo '[target.${{ matrix.target }}]' >> .cargo/config | |
echo 'strip = { path = "${{ matrix.target }}-strip" }' >> .cargo/config | |
echo 'objcopy = { path = "${{ matrix.target }}-objcopy" }' >> .cargo/config | |
- run: 'cargo install cargo-deb --locked' | |
- run: 'cargo deb --target=${{ matrix.target }}' | |
- run: 'gh release upload "${{ github.ref_name }}" target/${{ matrix.target }}/debian/*.deb' | |
shell: bash | |
env: | |
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' |