rustdns 0.7.0

A DNS parsing library
Documentation
name: Release

# Publishes to crates.io and creates a GitHub release when a `v*` tag is pushed.
#
# Requires a Trusted Publisher to be configured once on crates.io for this
# repository and the `Release` workflow (no API token secret needed):
# https://crates.io/crates/rustdns/settings/trusted-publishing

on:
  push:
    tags: ["v*"]

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: false

env:
  CARGO_TERM_COLOR: always

jobs:
  release:
    name: Publish
    runs-on: ubuntu-latest
    environment: release
    permissions:
      contents: write # Create the GitHub release.
      id-token: write # Exchange for a short-lived crates.io token.
    steps:
      - uses: actions/checkout@v7
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2

      - name: Check tag matches Cargo.toml version
        run: |
          cargo_version="$(cargo metadata --no-deps --format-version 1 \
            | jq -r '.packages[] | select(.name == "rustdns") | .version')"
          tag_version="${GITHUB_REF_NAME#v}"
          if [ "$cargo_version" != "$tag_version" ]; then
            echo "Tag $GITHUB_REF_NAME does not match Cargo.toml version $cargo_version" >&2
            exit 1
          fi

      - name: Verify package
        run: cargo publish --dry-run

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

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

      - name: Create GitHub release
        run: gh release create "$GITHUB_REF_NAME" --generate-notes --verify-tag
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}