name: Release
on:
workflow_dispatch:
inputs:
ref:
description: 'Git ref/branch to base the tag on'
required: false
default: 'main'
jobs:
create_tag:
name: Create Tag & Changelog
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
tag: ${{ steps.changelog.outputs.tag }}
clean_changelog: ${{ steps.changelog.outputs.clean_changelog }}
skipped: ${{ steps.changelog.outputs.skipped }}
steps:
- name: Check out repo
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 with:
ref: ${{ github.event.inputs.ref }}
fetch-depth: 0
token: ${{ secrets.RELEASE_TOKEN }}
- name: Create tag & generate changelog
id: changelog
uses: TriPSs/conventional-changelog-action@952b14bbc4be87e8458a6ac5926fc655608b1b19 with:
git-message: 'chore(release): Creating release tag {version} & adding CHANGELOG entry...'
git-user-email: 'mecha-bot@anewlevelmedia.com'
git-user-name: 'mecha-bot'
github-token: ${{ secrets.RELEASE_TOKEN }}
output-file: 'CHANGELOG.md'
preset: conventionalcommits
release-count: '10'
skip-bump: 'true'
skip-git-pull: 'true'
skip-on-empty: 'false'
tag-prefix: 'v'
version-file: './Cargo.toml'
version-path: 'package.version'
build_binary:
name: Build Binary
needs: create_tag
if: ${{ needs.create_tag.outputs.skipped != 'true' }}
runs-on: ${{ matrix.os }}
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
cross: false
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
cross: true
- os: macos-latest
target: aarch64-apple-darwin
cross: false
- os: macos-latest
target: x86_64-apple-darwin
cross: false
steps:
- name: Check out repo at new tag
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 with:
ref: ${{ needs.create_tag.outputs.tag }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 with:
targets: ${{ matrix.target }}
- name: Cache cargo registry & build
uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 with:
key: ${{ matrix.target }}
save-if: false
- name: Install cross
if: ${{ matrix.cross }}
uses: taiki-e/install-action@a6b2e2dcd845ddd7f509ce4f3ed3d922b80cc5d9 with:
tool: cross
- name: Build release binary
run: |
if [ "${{ matrix.cross }}" = "true" ]; then
cross build --release --target ${{ matrix.target }}
else
cargo build --release --target ${{ matrix.target }}
fi
- name: Package tarball & checksum
run: |
ARCHIVE="alf-${{ needs.create_tag.outputs.tag }}-${{ matrix.target }}.tar.gz"
tar -czf "$ARCHIVE" -C target/${{ matrix.target }}/release alf
shasum -a 256 "$ARCHIVE" > "$ARCHIVE.sha256"
echo "ARCHIVE=$ARCHIVE" >> "$GITHUB_ENV"
- name: Publish release & upload artifact
uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 with:
tag_name: ${{ needs.create_tag.outputs.tag }}
body: ${{ needs.create_tag.outputs.clean_changelog }}
files: |
${{ env.ARCHIVE }}
${{ env.ARCHIVE }}.sha256
publish_crate:
name: Publish to crates.io
needs: create_tag
if: ${{ needs.create_tag.outputs.skipped != 'true' }}
runs-on: ubuntu-latest
steps:
- name: Check out repo at new tag
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 with:
ref: ${{ needs.create_tag.outputs.tag }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8
- name: Cache cargo registry & build
uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32
- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish