gvc 0.1.1

CLI manager for Gradle version catalogs—check, list, update, and add dependencies with automatic version aliases
name: Release

on:
  push:
    tags:
      - 'v*'

env:
  CARGO_TERM_COLOR: always

permissions:
  contents: write
  id-token: write

jobs:
  build-release:
    name: Build Release
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            artifact_name: gvc
            asset_name: gvc-linux-x86_64
          - os: ubuntu-24.04-arm
            target: aarch64-unknown-linux-gnu
            artifact_name: gvc
            asset_name: gvc-linux-aarch64
          - os: macos-latest
            target: x86_64-apple-darwin
            artifact_name: gvc
            asset_name: gvc-macos-x86_64
          - os: macos-latest
            target: aarch64-apple-darwin
            artifact_name: gvc
            asset_name: gvc-macos-aarch64
          - os: windows-latest
            target: x86_64-pc-windows-msvc
            artifact_name: gvc.exe
            asset_name: gvc-windows-x86_64.exe
    steps:
      - uses: actions/checkout@v5

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

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

      - name: Strip binary (Linux/macOS)
        if: matrix.os != 'windows-latest'
        run: strip target/${{ matrix.target }}/release/${{ matrix.artifact_name }}

      - name: Rename binary
        run: |
          mkdir -p release
          cp target/${{ matrix.target }}/release/${{ matrix.artifact_name }} release/${{ matrix.asset_name }}
        shell: bash

      - name: Upload build artifact
        uses: actions/upload-artifact@v4
        with:
          name: ${{ matrix.asset_name }}
          path: release/${{ matrix.asset_name }}
          if-no-files-found: error

  create-release:
    name: Create GitHub Release
    needs:
      - build-release
      - publish-crate
    runs-on: ubuntu-latest
    steps:
      - name: Download artifacts
        uses: actions/download-artifact@v4
        with:
          path: artifacts

      - name: Gather release assets
        run: |
          mkdir -p release
          find artifacts -type f -exec cp {} release/ \;

      - name: Publish Release
        uses: softprops/action-gh-release@v2
        with:
          files: release/*
          draft: false
          prerelease: false
          generate_release_notes: true

  publish-crate:
    name: Publish to crates.io
    needs: build-release
    runs-on: ubuntu-latest
    environment: release
    permissions:
      contents: read
      id-token: write
    steps:
      - uses: actions/checkout@v5

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

      - name: Authenticate with crates.io
        id: auth
        uses: rust-lang/crates-io-auth-action@v1

      - name: Publish
        run: cargo publish
        env:
          CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}