acm-cli 0.3.2

A dead-simple AI-powered CLI tool for effortlessly crafting meaningful Git commit messages.
name: Publish

permissions:
  contents: write

on:
  push:
    tags:
      - "v[0-9]+.[0-9]+.[0-9]+"

jobs:
  publish-to-github:
    name: ${{ matrix.target }}
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            use-cross: false

          - os: ubuntu-latest
            target: aarch64-unknown-linux-gnu
            use-cross: true

          - os: windows-latest
            target: x86_64-pc-windows-gnu
            use-cross: false

          - os: windows-latest
            target: x86_64-pc-windows-msvc
            use-cross: false

          - os: windows-latest
            target: aarch64-pc-windows-msvc
            use-cross: false

          - os: macos-latest
            target: x86_64-apple-darwin
            use-cross: false

          - os: macos-latest
            target: aarch64-apple-darwin
            use-cross: false

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

      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Cargo build
        uses: actions-rs/cargo@v1
        with:
          command: build
          use-cross: ${{ matrix.use-cross }}
          args: --release --target ${{ matrix.target }}

      - name: Package binaries
        shell: bash
        env:
          PACKAGE_NAME: acm
        run: |
          package="${{ env.PACKAGE_NAME }}-${{ github.ref_name }}-${{ matrix.target }}"

          mkdir -p "$package"

          if [ "${{ matrix.os }}" = "windows-latest" ]; then
            cp "target/${{ matrix.target }}/release/${{ env.PACKAGE_NAME }}.exe" "$package/"
            7z a "$package.zip" "$package"
            7z h -scrcSHA256 "$package.zip" > "$package.zip.sha256"
          else
            cp "target/${{ matrix.target }}/release/${{ env.PACKAGE_NAME }}" "$package/"
            tar czf "$package.tar.gz" "$package"
            openssl dgst -sha256 "$package.tar.gz" > "$package.tar.gz.sha256"
          fi

      - name: Upload binaries to release
        uses: softprops/action-gh-release@v1
        with:
          files: "*-${{ github.ref_name }}-${{ matrix.target }}.*"

  publish-to-cargo:
    name: Publish to Cargo
    runs-on: ubuntu-latest
    steps:
      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable

      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Cargo publish
        uses: actions-rs/cargo@v1
        with:
          command: publish
          args: --token ${{ secrets.CARGO_REGISTRY_TOKEN }}