publish #26
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: publish | |
on: | |
release: | |
types: [published] | |
env: | |
CARGO_TERM_COLOR: always | |
permissions: | |
contents: write | |
jobs: | |
build-and-upload: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- build: linux-x86_64-musl | |
os: ubuntu-latest | |
target: x86_64-unknown-linux-musl | |
- build: linux-x86_64-gnu | |
os: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
- build: linux-aarch64-musl | |
os: ubuntu-latest | |
target: aarch64-unknown-linux-musl | |
- build: linux-aarch64-gnu | |
os: ubuntu-latest | |
target: aarch64-unknown-linux-gnu | |
- build: macos-x86_64 | |
os: macos-latest | |
target: x86_64-apple-darwin | |
- build: macos-aarch64 | |
os: macos-latest | |
target: aarch64-apple-darwin | |
- build: windows-x86_64-gnu | |
os: windows-latest | |
target: x86_64-pc-windows-gnu | |
- build: windows-aarch64-gnu | |
os: windows-latest | |
target: aarch64-pc-windows-gnu | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust Tools | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: ${{ matrix.target }} | |
components: rustfmt, clippy, llvm-tools | |
- name: Install cargo-llvm-cov | |
uses: taiki-e/install-action@cargo-llvm-cov | |
- name: Format with rustfmt | |
run: | | |
make format-check | |
- name: Lint with clippy | |
run: | | |
make lint | |
- name: Test with llvm-cov | |
run: | | |
make test | |
- name: Get the release version from the tag | |
id: tag_version | |
shell: bash | |
run: | | |
echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> "$GITHUB_OUTPUT" | |
- name: Build | |
run: | | |
cargo build --release --verbose --target ${{ matrix.target }} | |
- name: Build archive | |
shell: bash | |
run: | | |
# Replace with the name of your binary | |
binary_name="${{ github.event.repository.name }}" | |
dirname="$binary_name-${{ steps.tag_version.outputs.VERSION }}-${{ matrix.target }}" | |
mkdir "$dirname" | |
if [ "${{ matrix.os }}" = "windows-latest" ]; then | |
mv "target/${{ matrix.target }}/release/$binary_name.exe" "$dirname" | |
else | |
mv "target/${{ matrix.target }}/release/$binary_name" "$dirname" | |
fi | |
if [ "${{ matrix.os }}" = "windows-latest" ]; then | |
7z a "$dirname.zip" "$dirname" | |
echo "ASSET=$dirname.zip" >> $GITHUB_ENV | |
else | |
tar -czf "$dirname.tar.gz" "$dirname" | |
echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV | |
fi | |
- name: Upload the binaries | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: | | |
${{ env.ASSET }} | |
Publish: | |
needs: build-and-upload | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
profile: minimal | |
override: true | |
- name: Publish to Cargo | |
uses: actions-rs/cargo@v1 | |
with: | |
command: publish | |
args: --allow-dirty | |
env: | |
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_API_KEY }} |