name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: read
jobs:
verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 - uses: dtolnay/rust-toolchain@4be7066ada62dd38de10e7b70166bc74ed198c30 with:
toolchain: stable
components: clippy, rustfmt
- name: Verify release metadata
shell: bash
run: |
crate_version="$(sed -n 's/^version = "\([^"]*\)"/\1/p' Cargo.toml | head -1)"
test "${GITHUB_REF_NAME}" = "v${crate_version}"
bash scripts/release-notes.sh "${GITHUB_REF_NAME}" >/dev/null
- run: cargo fmt --check
- run: cargo clippy --locked --all-targets -- -D warnings
- run: cargo test --locked
- run: cargo package --locked
- run: rustup toolchain install 1.88.0 --profile minimal
- run: cargo +1.88.0 check --locked
- run: cargo install cargo-audit --version 0.22.2 --locked
- run: cargo audit
platform-tests:
needs: verify
strategy:
matrix:
os: [macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 - uses: dtolnay/rust-toolchain@4be7066ada62dd38de10e7b70166bc74ed198c30 with:
toolchain: stable
- run: cargo test --locked
build:
needs: [verify, platform-tests]
strategy:
matrix:
include:
- target: x86_64-apple-darwin
os: macos-latest
name: sunox-x86_64-apple-darwin
- target: aarch64-apple-darwin
os: macos-latest
name: sunox-aarch64-apple-darwin
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
name: sunox-x86_64-unknown-linux-gnu
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
name: sunox-aarch64-unknown-linux-gnu
- target: x86_64-pc-windows-msvc
os: windows-latest
name: sunox-x86_64-pc-windows-msvc
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
- name: Install Rust
uses: dtolnay/rust-toolchain@4be7066ada62dd38de10e7b70166bc74ed198c30 with:
toolchain: stable
targets: ${{ matrix.target }}
- name: Install cross-compilation tools (Linux ARM)
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Build
run: cargo build --release --locked --target ${{ matrix.target }}
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
- name: Package (Unix)
if: runner.os != 'Windows'
run: |
cd target/${{ matrix.target }}/release
tar czf ../../../${{ matrix.name }}.tar.gz sunox
cd ../../..
- name: Package (Windows)
if: runner.os == 'Windows'
run: |
cd target/${{ matrix.target }}/release
# Keep Windows release zips uncompressed so older sunox builds without
# zip Deflate support can still self-update into the fixed release.
Compress-Archive -LiteralPath sunox.exe -DestinationPath ../../../${{ matrix.name }}.zip -CompressionLevel NoCompression -Force
cd ../../..
- name: Upload artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a with:
name: ${{ matrix.name }}
path: ${{ matrix.name }}.*
release:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 with:
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c with:
path: artifacts
- name: Generate release notes
shell: bash
run: |
bash scripts/release-notes.sh "${GITHUB_REF_NAME}" > release-notes.md
- name: Generate checksums
shell: bash
run: |
while IFS= read -r file; do
printf '%s %s\n' "$(sha256sum "${file}" | cut -d' ' -f1)" "$(basename "${file}")"
done < <(find artifacts -type f | sort) > SHA256SUMS
mv SHA256SUMS artifacts/SHA256SUMS
- name: Create release
uses: softprops/action-gh-release@7c4723f7a335432393329f8f1c564994ce50185d with:
body_path: release-notes.md
files: artifacts/**/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-crate:
needs: release
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 - uses: dtolnay/rust-toolchain@4be7066ada62dd38de10e7b70166bc74ed198c30 with:
toolchain: stable
- name: Authenticate with crates.io
id: auth
uses: rust-lang/crates-io-auth-action@c6f97d42243bad5fab37ca0427f495c86d5b1a18 - name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
run: cargo publish --locked