name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
verify:
name: Verify
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
- name: Install Zsh
run: |
sudo apt-get update
sudo apt-get install --yes zsh
- uses: dtolnay/rust-toolchain@1.97.1
with:
components: clippy, rustfmt
- run: cargo fmt --check
- run: cargo clippy --all-targets --all-features -- -D warnings -W clippy::pedantic
- run: cargo test --all-targets --all-features
- run: cargo package --locked
- run: zsh -n shell/ztheme.zsh shell/defaults.zsh
- name: Verify tag version
if: github.event_name == 'push'
run: |
tag_version="${GITHUB_REF_NAME#v}"
package_version=$(awk -F '"' '/^version = / { print $2; exit }' Cargo.toml)
test "$tag_version" = "$package_version"
build:
name: Build (${{ matrix.asset }})
needs: verify
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-24.04
target: x86_64-unknown-linux-gnu
asset: ztheme-x86_64-unknown-linux-gnu
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
asset: ztheme-aarch64-unknown-linux-gnu
- os: macos-15-intel
target: x86_64-apple-darwin
asset: ztheme-x86_64-apple-darwin
- os: macos-15
target: aarch64-apple-darwin
asset: ztheme-aarch64-apple-darwin
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@1.97.1
with:
targets: ${{ matrix.target }}
- run: cargo build --release --locked --target "${{ matrix.target }}"
- name: Package archive
run: |
mkdir dist
cp "target/${{ matrix.target }}/release/ztheme" dist/ztheme
cp LICENSE README.md dist/
tar -C dist -czf "${{ matrix.asset }}.tar.gz" ztheme LICENSE README.md
- uses: actions/upload-artifact@v7
with:
name: ${{ matrix.asset }}
path: ${{ matrix.asset }}.tar.gz
if-no-files-found: error
rehearse-release-assets:
name: Rehearse release assets
if: github.event_name == 'workflow_dispatch'
needs: build
runs-on: ubuntu-24.04
steps:
- uses: actions/download-artifact@v8
with:
path: release
merge-multiple: true
- name: Verify release assets
run: |
test "$(find release -maxdepth 1 -name 'ztheme-*.tar.gz' -type f | wc -l | tr -d ' ')" = 4
sha256sum release/*.tar.gz > release/SHA256SUMS
test -s release/SHA256SUMS
publish:
name: Publish release
if: github.event_name == 'push'
needs: build
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@1.97.1
- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish --locked
- uses: actions/download-artifact@v8
with:
path: release
merge-multiple: true
- name: Generate checksums
working-directory: release
run: sha256sum *.tar.gz > SHA256SUMS
- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: gh release create "$GITHUB_REF_NAME" --verify-tag --generate-notes release/*