arisusay 1.0.1

An ASCII teabag player for Tendou Aris — like momoisay, but she teabags. Homage to 청세치/세치혀.
name: Release

on:
  push:
    tags: ["v*"]

permissions:
  contents: write

env:
  CARGO_TERM_COLOR: always

jobs:
  build:
    name: build ${{ matrix.target }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            archive: tar.gz
          - os: ubuntu-24.04-arm
            target: aarch64-unknown-linux-gnu
            archive: tar.gz
          - os: macos-latest
            target: aarch64-apple-darwin
            archive: tar.gz
          - os: windows-latest
            target: x86_64-pc-windows-msvc
            archive: zip
    steps:
      - uses: actions/checkout@v4

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

      - uses: Swatinem/rust-cache@v2
        with:
          key: ${{ matrix.target }}

      - name: Build
        run: cargo build --release --target ${{ matrix.target }}

      - name: Package (unix)
        if: matrix.archive == 'tar.gz'
        run: |
          cd target/${{ matrix.target }}/release
          tar czf arisusay-${{ github.ref_name }}-${{ matrix.target }}.tar.gz arisusay
          mv arisusay-${{ github.ref_name }}-${{ matrix.target }}.tar.gz "$GITHUB_WORKSPACE"

      - name: Package (windows)
        if: matrix.archive == 'zip'
        shell: pwsh
        run: |
          Compress-Archive -Path "target/${{ matrix.target }}/release/arisusay.exe" `
            -DestinationPath "$env:GITHUB_WORKSPACE/arisusay-${{ github.ref_name }}-${{ matrix.target }}.zip"

      - uses: actions/upload-artifact@v4
        with:
          name: dist-${{ matrix.target }}
          path: arisusay-${{ github.ref_name }}-${{ matrix.target }}.*
          if-no-files-found: error

  publish-crate:
    name: publish crates.io
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

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

      - uses: Swatinem/rust-cache@v2

      - name: Verify tag matches Cargo.toml version
        run: |
          version="$(cargo metadata --no-deps --format-version 1 | python3 -c 'import json,sys; print(json.load(sys.stdin)["packages"][0]["version"])')"
          test "${GITHUB_REF_NAME}" = "v${version}"

      - name: Publish crate
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CRETES_PUBLISH_API_KEY }}
        run: cargo publish

  publish-release:
    name: publish GitHub Release
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/download-artifact@v4
        with:
          path: dist
          merge-multiple: true

      - name: List release assets
        run: find dist -type f -maxdepth 1 -print

      - name: Create release
        uses: softprops/action-gh-release@v2
        with:
          files: dist/*
          fail_on_unmatched_files: true
          generate_release_notes: true