sbpf-linker 0.2.0

Upstream BPF linker for SBPF V0/V3 programs
name: Release

run-name: "Release ${{ github.ref_name }}"

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

jobs:
  crates:
    name: Publish crates
    runs-on: ubuntu-latest
    concurrency:
      group: release-crates
      cancel-in-progress: false
    environment: release
    permissions:
      contents: write
      id-token: write
    steps:
      - name: Checkout
        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false

      - name: Verify tag matches Cargo.toml version
        run: |
          v=$(yq -e '.package.version' Cargo.toml)
          tag="v${GITHUB_REF_NAME#v}"
          test "$tag" = "v$v" \
            || { echo "::error::tag ${tag} does not match Cargo.toml version v$v"; exit 1; }
          echo "tag=$tag" >> "$GITHUB_ENV"

      - name: Install Rust
        uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0
        with:
          toolchain: stable
          cache: false
          rustflags: ""       # don't force -D warnings on the publish build

      - name: Install cargo-release
        uses: taiki-e/install-action@67729d5c413db75907f0ad1e39bb04b9c868ff60 # v2.85.7
        with:
          tool: cargo-release@1.1.5

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

      - name: Publish crates
        env:
          CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
        run: cargo release --unpublished --workspace --no-tag --no-push --execute --no-confirm --allow-branch '*,HEAD'

      - name: Publish release
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          if gh release view "$tag" >/dev/null 2>&1; then
            echo "release $tag already exists; skipping creation"
          else
            gh release create "$tag" --generate-notes
          fi