porkbun-api 1.0.4

an async implementation of porkbun's domain management api.
Documentation
# Release pipeline for porkbun-api library
name: Release Build & Publish

on:
  # Manual trigger with inputs for tag/prerelease
  workflow_dispatch:
    inputs:
      tag:
        description: "Git tag to release (e.g., v0.1.0)"
        required: true
      prerelease:
        description: "Mark as pre-release"
        required: false
        default: false
        type: boolean

  # Auto-trigger on version tags (e.g., v1.2.3 or v1.2.3-rc1)
  push:
    tags:
      - "v*"

jobs:
  meta:
    name: derive release metadata
    runs-on: ubuntu-latest
    outputs:
      tag: ${{ steps.compute.outputs.tag }}
      prerelease: ${{ steps.compute.outputs.prerelease }}
    steps:
      - id: compute
        shell: bash
        run: |

          set -euo pipefail
          if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
            TAG="${{ inputs.tag }}"
            PRERELEASE="${{ inputs.prerelease }}"
          else
            TAG="${GITHUB_REF_NAME}"
            # If tag ends with -rcN, mark as prerelease automatically
            if [[ "$TAG" =~ -rc[0-9]*$ ]]; then
              PRERELEASE=true
            else
              PRERELEASE=false
            fi
          fi
          echo "tag=$TAG" >> "$GITHUB_OUTPUT"
          echo "prerelease=$PRERELEASE" >> "$GITHUB_OUTPUT"

  build:
    name: build (${{ matrix.os }})
    needs: meta
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        # Targets we build for; mac uses Apple Silicon (aarch64)
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
          - os: ubuntu-latest
            target: aarch64-unknown-linux-gnu
          - os: macos-14 # macOS 14+ has arm64 runners
            target: aarch64-apple-darwin
          - os: windows-latest
            target: x86_64-pc-windows-msvc

    steps:
      # Fetch repository contents
      - name: Checkout
        uses: actions/checkout@v4

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

      # Cache Cargo build artifacts to speed up repeats
      - name: Cache cargo
        uses: Swatinem/rust-cache@v2
        with:
          cache-on-failure: true

      # Ensure the target triple is installed for cross/alt builds
      - name: Add Rust target
        run: rustup target add ${{ matrix.target }}

      # Cross-compiler needed to build aarch64 GNU on Ubuntu
      - name: Install cross-compiler for linux aarch64
        if: matrix.target == 'aarch64-unknown-linux-gnu'
        run: sudo apt-get update && sudo apt-get install -y gcc-aarch64-linux-gnu

      # Build release binaries for the target triple
      - name: Build release
        run: cargo build --release --locked --target ${{ matrix.target }}

      # Run tests to ensure everything works
      - name: Test release
        run: cargo test --release --locked --target ${{ matrix.target }}

  publish:
    name: publish to crates.io
    needs: [meta, build]
    runs-on: ubuntu-latest
    if: github.event_name == 'push' && !contains(github.ref, '-rc')
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      
      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
      
      - name: Cache cargo
        uses: Swatinem/rust-cache@v2
        with:
          cache-on-failure: true
      
      - name: Publish to crates.io
        run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

  release:
    name: create github release
    needs: [meta, build]
    runs-on: ubuntu-latest
    steps:
      # Create/overwrite the GitHub Release for the provided tag
      - name: Create GitHub Release
        uses: softprops/action-gh-release@v2
        with:
          tag_name: ${{ needs.meta.outputs.tag }}
          prerelease: ${{ needs.meta.outputs.prerelease }}
          generate_release_notes: true
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}