name: Release and Publish
on:
push:
tags:
- 'v*'
env:
BINARY_NAME: base256
jobs:
build:
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact: base256-linux-x64
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
artifact: base256-linux-arm64
- os: macos-latest
target: x86_64-apple-darwin
artifact: base256-macos-x64
- os: macos-latest
target: aarch64-apple-darwin
artifact: base256-macos-arm64
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact: base256-windows-x64.exe
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Build
run: |
if [ "${{ matrix.target }}" = "aarch64-unknown-linux-gnu" ]; then
cross build --release --target ${{ matrix.target }}
else
cargo build --release --target ${{ matrix.target }}
fi
shell: bash
- name: Package
run: |
cd target/${{ matrix.target }}/release
if [ "${{ matrix.os }}" = "windows-latest" ]; then
cp base256.exe ../../../${{ matrix.artifact }}
else
cp base256 ../../../${{ matrix.artifact }}
fi
cd ../../..
tar czf ${{ matrix.artifact }}.tar.gz ${{ matrix.artifact }}
shell: bash
- name: Upload
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: ${{ matrix.artifact }}.tar.gz
release:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
- name: Create Release
run: |
gh release create ${{ github.ref_name }} \
--title "${{ github.ref_name }}" \
--generate-notes \
base256-*/*.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo publish --locked
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_TOKEN }}