deezconfigs 0.18.0

Manage deez config files.
Documentation
name: Release

on:
  push:
    tags:
      - '*.*.*'

jobs:
  ci:
    name: CI
    uses: ./.github/workflows/ci.yml

  build:
    name: Build
    needs: ci
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest]

    steps:
      - name: Checkout repository
        uses: actions/checkout@v6
        with:
          fetch-depth: 0 # Full tag annotation.

      - name: Set up Rust
        uses: dtolnay/rust-toolchain@stable

      - name: Set up Just
        uses: taiki-e/install-action@just

      - name: Cache cargo and target
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry/
            ~/.cargo/git/
            target/
          key: ${{ runner.os }}-release-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-release-
            ${{ runner.os }}-

      - name: Build release binary
        run: just build

      - name: Prepare artifact
        run: |
          mkdir -p dist/
          bin=$(just ci-bin-name)
          platform=$(echo "${{ runner.os }}" | tr '[:upper:]' '[:lower:]')
          cp "target/release/$bin" "dist/${bin}-${{ github.ref_name }}-${platform}"
        shell: bash

      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: ${{ github.event.repository.name }}-${{ runner.os }}
          path: dist/
          if-no-files-found: error

  release:
    name: Create GitHub Release
    needs: build
    runs-on: ubuntu-latest
    permissions:
      contents: write

    steps:
      - name: Checkout repository
        uses: actions/checkout@v6

      # `actions/checkout@v6` somehow transforms annotated tags into
      # lightweight tags, which prevents us from reading release notes.
      # This fetches annotated tags and overrides existing mangled tags.
      - name: Fetch annotated tags
        run: git fetch --tags --force

      - name: Extract tag annotation
        id: tag
        run: |
          title=$(git tag -l --format='%(contents:subject)' ${{ github.ref_name }})
          body=$(git tag -l --format='%(contents:body)' ${{ github.ref_name }})
          echo "title=$title" >> $GITHUB_OUTPUT
          echo 'body<<EOF' >> $GITHUB_OUTPUT
          echo "$body" >> $GITHUB_OUTPUT
          echo 'EOF' >> $GITHUB_OUTPUT

      - name: Download all artifacts
        uses: actions/download-artifact@v4
        with:
          path: artifacts/

      - name: Publish GitHub Release
        uses: softprops/action-gh-release@v1
        with:
          tag_name: ${{ github.ref_name }}
          name: ${{ steps.tag.outputs.title }}
          body: ${{ steps.tag.outputs.body }}
          files: |
            artifacts/**/*
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  publish-crate:
    name: Publish crate
    needs: release
    runs-on: ubuntu-latest
    permissions:
      contents: read
      id-token: write

    steps:
      - name: Checkout repository
        uses: actions/checkout@v6

      - name: Set up Rust
        uses: dtolnay/rust-toolchain@stable

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

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