pq-map 0.2.2

Domain service and cryptography discovery from Certificate Transparency and DNS
Documentation
name: release

on:
  push:
    tags:
      - "v*"

permissions:
  contents: write

env:
  CARGO_TERM_COLOR: always

jobs:
  build:
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
          - os: ubuntu-24.04-arm
            target: aarch64-unknown-linux-gnu
          - os: macos-latest
            target: aarch64-apple-darwin
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4
      - 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
        run: |
          version="${GITHUB_REF_NAME#v}"
          dir="pq-map-v${version}-${{ matrix.target }}"
          mkdir "${dir}"
          cp "target/${{ matrix.target }}/release/pq-map" "${dir}/"
          cp README.md LICENSE "${dir}/"
          tar -czf "${dir}.tar.gz" "${dir}"
          if command -v sha256sum >/dev/null; then
            sha256sum "${dir}.tar.gz" > "${dir}.tar.gz.sha256"
          else
            shasum -a 256 "${dir}.tar.gz" > "${dir}.tar.gz.sha256"
          fi
      - uses: actions/upload-artifact@v4
        with:
          name: pq-map-${{ matrix.target }}
          path: |
            pq-map-*.tar.gz
            pq-map-*.tar.gz.sha256
          if-no-files-found: error

  release:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          ref: main
          fetch-depth: 0
      - uses: dtolnay/rust-toolchain@stable
      - name: Verify tag matches Cargo.toml version
        run: |
          version="$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')"
          if [ "v${version}" != "${GITHUB_REF_NAME}" ]; then
            echo "::error::tag ${GITHUB_REF_NAME} does not match Cargo.toml version v${version}"
            exit 1
          fi
      - name: Generate changelog
        uses: orhun/git-cliff-action@v4
        with:
          config: cliff.toml
          args: --verbose
        env:
          OUTPUT: CHANGELOG.md
          GITHUB_REPO: ${{ github.repository }}
      - name: Commit changelog
        run: |
          git config user.name "github-actions[bot]"
          git config user.email "github-actions[bot]@users.noreply.github.com"
          git add CHANGELOG.md
          if git diff --cached --quiet; then
            echo "CHANGELOG.md unchanged"
          else
            git commit -m "chore(release): update CHANGELOG.md for ${GITHUB_REF_NAME}"
            git push origin HEAD:main
          fi
      - name: Generate release notes
        uses: orhun/git-cliff-action@v4
        with:
          config: cliff.toml
          args: --latest --strip header
        env:
          OUTPUT: RELEASE_NOTES.md
          GITHUB_REPO: ${{ github.repository }}
      - uses: actions/download-artifact@v4
        with:
          path: dist
          pattern: pq-map-*
          merge-multiple: true
      - name: Create GitHub release
        env:
          GH_TOKEN: ${{ github.token }}
        run: |
          gh release create "${GITHUB_REF_NAME}" \
            --title "${GITHUB_REF_NAME}" \
            --notes-file RELEASE_NOTES.md \
            dist/pq-map-*.tar.gz dist/pq-map-*.tar.gz.sha256

  publish:
    needs: release
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - name: Publish to crates.io
        run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}