alf_tui 0.5.0

A smolderingly-nimble Rust TUI to rediscover your custom shell.
Documentation
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 # v5.0.0
            # https://github.com/actions/checkout
            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 # v6.3.1
            # https://github.com/TriPSs/conventional-changelog-action
            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
               # TODO: add a Windows build target (e.g. windows-latest / x86_64-pc-windows-msvc)
      steps:
         -  name: Check out repo at new tag
            uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
            # https://github.com/actions/checkout
            with:
               ref: ${{ needs.create_tag.outputs.tag }}

         -  name: Install Rust toolchain
            uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
            with:
               targets: ${{ matrix.target }}

         -  name: Cache cargo registry & build
            uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
            with:
               key: ${{ matrix.target }}
               save-if: false

         -  name: Install cross
            if: ${{ matrix.cross }}
            uses: taiki-e/install-action@a6b2e2dcd845ddd7f509ce4f3ed3d922b80cc5d9 # v2.84.0
            # https://github.com/taiki-e/install-action
            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 # v2.6.2
            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 # v5.0.0
            # https://github.com/actions/checkout
            with:
               ref: ${{ needs.create_tag.outputs.tag }}

         -  name: Install Rust toolchain
            uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable

         -  name: Cache cargo registry & build
            uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2

         -  name: Publish to crates.io
            env:
               CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
            run: cargo publish