script-wizard 0.3.0

script-wizard is a shell script (Bash) helper program, to delegate the responsibility of asking questions to the user, asking for confirmation, making selections, etc. The normalized response is printed to stdout for the script to consume.
Documentation
name: Release

on:
  push:
    tags:
      - "v*.*.*"
  workflow_dispatch:

jobs:
  build:
    name: Build - ${{ matrix.platform.release_for }}
    runs-on: ${{ matrix.platform.os }}
    steps:
      - name: Checkout
        uses: actions/checkout@v6
      - run: rustup toolchain install stable
      - uses: Swatinem/rust-cache@v2
        with:
          save-if: ${{ github.ref == 'refs/heads/master' }}
      - name: Get version from cargo.toml
        if: startsWith( github.ref, 'refs/tags/v' )
        uses: SebRollen/toml-action@v1.0.1
        id: cargo_version
        with:
          file: 'Cargo.toml'
          field: 'package.version'
      - name: Get the tag of current release
        if: startsWith( github.ref, 'refs/tags/v' )
        id: get_version
        shell: bash
        run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> ${GITHUB_OUTPUT}
      - name: Verify package version is equal to tag version
        if: ${{ startsWith( github.ref, 'refs/tags/v' ) && steps.cargo_version.outputs.value != steps.get_version.outputs.VERSION }}
        run: |
          echo "${{ steps.cargo_version.outputs.value }}"
          echo "${{ steps.get_version.outputs.VERSION }}"
          exit 1
      - name: Build binary
        uses: houseabsolute/actions-rust-cross@v0
        with:
          command: ${{ matrix.platform.command }}
          target: ${{ matrix.platform.target }}
          args: "--locked --release"
          strip: true
      - name: Package as archive
        shell: bash
        run: |
          cd target/${{ matrix.platform.target }}/release
          if [[ "${{ matrix.platform.os }}" == "windows-latest" ]]; then
            7z a ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }}
          else
            tar czvf ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }}
          fi
          cd -
        if: startsWith( github.ref, 'refs/tags/v' ) || github.event_name == 'workflow_dispatch'
      - name: Generate SHA-256
        shell: bash
        run: sha256sum ${{ matrix.platform.name }} > ${{ matrix.platform.name }}.sha256
        if: startsWith( github.ref, 'refs/tags/v' ) || github.event_name == 'workflow_dispatch'
      - name: Publish release artifacts
        uses: actions/upload-artifact@v7
        with:
          name: ${{ matrix.platform.name }}
          path: ${{ matrix.platform.name }}
        if: startsWith( github.ref, 'refs/tags/v' ) || github.event_name == 'workflow_dispatch'
      - name: Publish release digests
        uses: actions/upload-artifact@v7
        with:
          name: ${{ matrix.platform.name }}.sha256
          path: ${{ matrix.platform.name }}.sha256
        if: startsWith( github.ref, 'refs/tags/v' ) || github.event_name == 'workflow_dispatch'
    strategy:
      matrix:
        platform:
          - release_for: Linux-x86_64
            os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            bin: script-wizard
            name: script-wizard-Linux-x86_64.tar.gz
            command: build

          - release_for: Linux-aarch64
            os: ubuntu-latest
            target: aarch64-unknown-linux-gnu
            bin: script-wizard
            name: script-wizard-Linux-aarch64.tar.gz
            command: build

          - release_for: Windows-x86_64
            os: windows-latest
            target: x86_64-pc-windows-msvc
            bin: script-wizard.exe
            name: script-wizard-Windows-x86_64.zip
            command: build

          - release_for: Windows-aarch64
            os: windows-latest
            target: aarch64-pc-windows-msvc
            bin: script-wizard.exe
            name: script-wizard-Windows-aarch64.zip
            command: build

          - release_for: macOS-x86_64
            os: macos-latest
            target: x86_64-apple-darwin
            bin: script-wizard
            name: script-wizard-Darwin-x86_64.tar.gz
            command: build

          - release_for: macOS-aarch64
            os: macos-latest
            target: aarch64-apple-darwin
            bin: script-wizard
            name: script-wizard-Darwin-aarch64.tar.gz
            command: build

  release:
    name: Release
    if: startsWith( github.ref, 'refs/tags/v' )
    needs: build
    runs-on: ubuntu-latest
    steps:
    - uses: actions/download-artifact@v8
      with:
        name: script-wizard-Linux-x86_64.tar.gz
    - uses: actions/download-artifact@v8
      with:
        name: script-wizard-Linux-x86_64.tar.gz.sha256
    - uses: actions/download-artifact@v8
      with:
        name: script-wizard-Linux-aarch64.tar.gz
    - uses: actions/download-artifact@v8
      with:
        name: script-wizard-Linux-aarch64.tar.gz.sha256
    - uses: actions/download-artifact@v8
      with:
        name: script-wizard-Windows-x86_64.zip
    - uses: actions/download-artifact@v8
      with:
        name: script-wizard-Windows-x86_64.zip.sha256
    - uses: actions/download-artifact@v8
      with:
        name: script-wizard-Windows-aarch64.zip
    - uses: actions/download-artifact@v8
      with:
        name: script-wizard-Windows-aarch64.zip.sha256
    - uses: actions/download-artifact@v8
      with:
        name: script-wizard-Darwin-x86_64.tar.gz
    - uses: actions/download-artifact@v8
      with:
        name: script-wizard-Darwin-x86_64.tar.gz.sha256
    - uses: actions/download-artifact@v8
      with:
        name: script-wizard-Darwin-aarch64.tar.gz
    - uses: actions/download-artifact@v8
      with:
        name: script-wizard-Darwin-aarch64.tar.gz.sha256
    - name: Release
      uses: softprops/action-gh-release@v2
      if: startsWith(github.ref, 'refs/tags/')
      with:
        files: |
          script-wizard-Linux-x86_64.tar.gz
          script-wizard-Linux-x86_64.tar.gz.sha256
          script-wizard-Linux-aarch64.tar.gz
          script-wizard-Linux-aarch64.tar.gz.sha256
          script-wizard-Windows-x86_64.zip
          script-wizard-Windows-x86_64.zip.sha256
          script-wizard-Windows-aarch64.zip
          script-wizard-Windows-aarch64.zip.sha256
          script-wizard-Darwin-x86_64.tar.gz
          script-wizard-Darwin-x86_64.tar.gz.sha256
          script-wizard-Darwin-aarch64.tar.gz
          script-wizard-Darwin-aarch64.tar.gz.sha256

  publish-crate:
    name: Publish to crates.io
    if: startsWith( github.ref, 'refs/tags/v' )
    needs: release
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v6
      - run: rustup toolchain install stable
      - name: Publish to crates.io
        run: cargo publish
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}