mamediff 0.5.1

A TUI editor for managing unstaged and staged Git diffs
Documentation
name: Release

on:
  push:
    tags:
      - 'v*'

jobs:
  github-release:
    name: 'Create GitHub Release'
    runs-on: ubuntu-latest
    permissions:
      contents: write
    outputs:
      version: ${{ steps.get_version.outputs.VERSION }}
    steps:
      - name: Checkout sources
        uses: actions/checkout@v5

      - name: Get the version
        id: get_version
        run: echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_OUTPUT

      - name: Create Release
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          gh release create v${{ steps.get_version.outputs.VERSION }} \
            --title "v${{ steps.get_version.outputs.VERSION }}" \
            --generate-notes

  linux-binary:
    name: 'Upload Binary for Linux'
    strategy:
      matrix:
        platform:
          - target: x86_64-unknown-linux-musl
            runs-on: ubuntu-24.04
          - target: aarch64-unknown-linux-musl
            runs-on: ubuntu-24.04-arm
    runs-on: ${{ matrix.platform.runs-on }}
    needs: github-release
    steps:
      - name: Checkout sources
        uses: actions/checkout@v5

      - name: Install dependent packages
        run: sudo apt install -y musl-tools

      - run: rustup update stable
      - run: rustup default stable
      - run: rustup target add ${{ matrix.platform.target }}
      - run: cargo build --release --target=${{ matrix.platform.target }}

      - name: Upload Release Asset
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          mv target/${{ matrix.platform.target }}/release/mamediff mamediff-${{ needs.github-release.outputs.version }}.${{ matrix.platform.target }}
          gh release upload ${{ needs.github-release.outputs.version }} \
            mamediff-${{ needs.github-release.outputs.version }}.${{ matrix.platform.target }}

  macos-binary:
    name: 'Upload Binary for MacOS'
    runs-on: macos-latest
    needs: github-release
    strategy:
      matrix:
        target: ["aarch64-apple-darwin"]
    steps:
      - name: Checkout sources
        uses: actions/checkout@v5

      - run: rustup update stable
      - run: rustup default stable
      - run: rustup target add ${{ matrix.target }}
      - run: cargo build --release --target=${{ matrix.target }}

      - name: Upload Release Asset
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          mv target/${{ matrix.target }}/release/mamediff mamediff-${{ needs.github-release.outputs.version }}.${{ matrix.target }}
          gh release upload ${{ needs.github-release.outputs.version }} \
            mamediff-${{ needs.github-release.outputs.version }}.${{ matrix.target }}

  publish-crates:
    name: 'Publish to crates.io'
    runs-on: ubuntu-latest
    needs:
      - github-release
      - linux-binary
      - macos-binary
    permissions:
      id-token: write
    steps:
      - name: Checkout sources
        uses: actions/checkout@v5

      - run: rustup update stable
      - run: rustup default stable

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

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