tictacrustle 1.0.0-next.2

Tic Tac Toe game with a Menace[ing] AI
Documentation
---
on:
    workflow_call:

name: Semantic Release
env:
    RUST_BACKTRACE: 1
    SEMREL_RUST_VERSION: 2.1.53
concurrency:
    group: ${{ github.workflow }}
jobs:
    build_application:
        name: Build CLI ${{ matrix.build.target }}
        runs-on: ${{ matrix.build.os }}
        env:
            CARGO: cargo
        strategy:
            matrix:
                bin:
                    - ttrustle
                build:
                    # alphabatized by target
                    - os: macOS-latest
                      target: aarch64-apple-darwin
                      cross: true
                    - os: ubuntu-latest
                      target: aarch64-unknown-linux-gnu
                      cross: true
                    - os: ubuntu-latest
                      target: aarch64-unknown-linux-musl
                      cross: true
                    - os: ubuntu-latest
                      target: i686-unknown-linux-gnu
                      cross: true
                    - os: ubuntu-latest
                      target: i686-unknown-linux-musl
                      cross: true
                    - os: macOS-latest
                      target: x86_64-apple-darwin
                      cross: false
                    - os: ubuntu-latest
                      target: x86_64-unknown-linux-gnu
                      cross: false
                    - os: ubuntu-latest
                      target: x86_64-unknown-linux-musl
                      cross: false
                    - os: ubuntu-latest
                      target: x86_64-pc-windows-gnu
                      cross: true
                    - os: ubuntu-latest
                      target: i686-pc-windows-gnu
                      cross: true
        steps:
            - name: Checkout
              uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
            - name: Install tree
              if: runner.os == 'Linux'
              run: sudo apt install tree
            - name: Install build inputs
              if: runner.os == 'Linux' && !matrix.build.cross
              run: sudo apt install musl-tools mingw-w64
            - name: Install Rust toolchain
              uses: dtolnay/rust-toolchain@master
              id: rust-toolchain
              with:
                toolchain: stable
                target: ${{ matrix.build.target }}
            - name: Cache dependencies
              uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
            - name: Install cross
              uses: taiki-e/install-action@b7add58e53e52e624966da65007ce24524f3dcf3 # v2.27.9
              with:
                tool: cross
            - name: Configure cross
              if: matrix.build.cross
              run: echo "CARGO=cross" >> "$GITHUB_ENV"
            - name: Compile release binary
              run: ${{ env.CARGO }} build --bin ${{ matrix.bin }} --release --target ${{ matrix.build.target }} --verbose
            - name: Show generated binary
              if: runner.os == 'Linux'
              run: tree target/
            - name: Create release archive - windows
              if: matrix.build.target == 'x86_64-pc-windows-gnu' || matrix.build.target == 'i686-pc-windows-gnu'
              run: |
                mkdir dist
                cp target/${{ matrix.build.target }}/release/${{ matrix.bin }}.exe dist/${{ matrix.bin }}-${{ matrix.build.target }}
            - name: Create release archive - non-windows
              if: matrix.build.target != 'x86_64-pc-windows-gnu' && matrix.build.target != 'i686-pc-windows-gnu'
              run: |
                mkdir dist
                cp target/${{ matrix.build.target }}/release/${{ matrix.bin }} dist/${{ matrix.bin }}-${{ matrix.build.target }}
            - name: Create binary checksum
              run: |
                shasum --algorithm 256 \
                --binary ${{ matrix.bin }}-${{ matrix.build.target }} | tee ${{ matrix.bin }}-${{ matrix.build.target }}-SHA256SUM.txt
              working-directory: ./dist
            - name: Upload release artifacts
              uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
              with:
                name: ${{ matrix.build.target }}
                path: |
                    dist/${{ matrix.bin }}-${{ matrix.build.target }}
                    dist/${{ matrix.bin }}-${{ matrix.build.target }}-SHA256SUM.txt
                if-no-files-found: error
                retention-days: 1
    release:
        name: Semantic Release
        runs-on: ubuntu-latest
        needs: build_application
        outputs:
            new_release_version: ${{steps.semantic.outputs.new_release_version}}
            new_release_published: ${{steps.semantic.outputs.new_release_published}}
            new_release_notes: ${{steps.semantic.outputs.new_release_notes}}
            new_release_channel: ${{steps.semantic.outputs.new_release_channel}}
        steps:
            - name: Checkout
              uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
              with:
                fetch-depth: 0
                persist-credentials: false
            - name: Import GPG key
              uses: crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 # v6.1.0
              with:
                gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
                passphrase: ${{ secrets.GPG_KEY_PASSPHRASE }}
                fingerprint: ${{ secrets.GPG_SUBKEY_FINGERPRINT }}
                trust_level: 5
                git_user_signingkey: true
                git_commit_gpgsign: true
                git_tag_gpgsign: false
                git_committer_name: ${{ vars.GIT_AUTHOR_NAME }}
                git_committer_email: ${{ vars.GIT_AUTHOR_EMAIL }}
            - name: Test GPG Key Import
              run: gpg --list-keys --keyid-format LONG
            - name: Install dependencies
              run: sudo apt install tree
            - name: Install semantic-release-cargo
              uses: taiki-e/install-action@b7add58e53e52e624966da65007ce24524f3dcf3 # v2.27.9
              with:
                tool: semantic-release-cargo@${{env.SEMREL_RUST_VERSION}}
            - name: Download release artifacts
              uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2
              with:
                path: artifacts
            - name: ls artifacts
              run: tree ./artifacts
            - name: Prepare GitHub Release artifacts
              run: |
                mkdir dist/
                mv -v artifacts/aarch64-apple-darwin dist/
                mv -v artifacts/aarch64-unknown-linux-gnu dist/
                mv -v artifacts/aarch64-unknown-linux-musl dist/
                mv -v artifacts/i686-unknown-linux-gnu dist/
                mv -v artifacts/i686-unknown-linux-musl dist/
                mv -v artifacts/x86_64-apple-darwin dist/
                mv -v artifacts/x86_64-unknown-linux-gnu dist/
                mv -v artifacts/x86_64-unknown-linux-musl dist/
                mv -v artifacts/x86_64-pc-windows-gnu dist/
                mv -v artifacts/i686-pc-windows-gnu dist/
            - name: Combine checksums
              run: cat dist/**/*-SHA256SUM.txt | tee dist/SHA256SUMS.txt
            - name: Install Conventional Commit preset
              run: npm install conventional-changelog-conventionalcommits
            - name: Semantic Release
              uses: cycjimmy/semantic-release-action@61680d0e9b02ff86f5648ade99e01be17f0260a4 # v4.0.0
              id: semantic
              with:
                semantic_version: 22.0.3
                extra_plugins: |
                    @semantic-release/exec@6
                    @semantic-release/git@10
              env:
                GITHUB_TOKEN: ${{secrets.ACTIONS_PAT_GITHUB}}
                CARGO_REGISTRY_TOKEN: ${{secrets.SEMREL_CRATES_IO}}
                GIT_AUTHOR_NAME: ${{vars.GIT_AUTHOR_NAME}}
                GIT_AUTHOR_EMAIL: ${{vars.GIT_AUTHOR_EMAIL}}