argmend 0.4.2

Argmend repairs broken tool-call arguments into JSON.
Documentation
name: Release

on:
  push:
    branches: [main]
  workflow_dispatch:
    inputs:
      tag:
        description: "Release tag, for example v0.2.9"
        required: true
        type: string

permissions:
  contents: read

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

jobs:
  release-please:
    name: Release Please
    if: github.event_name == 'push'
    runs-on: ubuntu-latest
    timeout-minutes: 10
    outputs:
      release_created: ${{ steps.rp.outputs.release_created }}
      tag_name: ${{ steps.rp.outputs.tag_name }}
    permissions:
      contents: write
      pull-requests: write
    steps:
      - uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2
        with:
          egress-policy: audit
      - uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
        id: app-token
        with:
          client-id: ${{ vars.AUTO_APPROVE_CLIENT_ID }}
          private-key: ${{ secrets.AUTO_APPROVE_PRIVATE_KEY }}
      - uses: googleapis/release-please-action@45996ed1f6d02564a971a2fa1b5860e934307cf7 # v5.0.0
        id: rp
        with:
          token: ${{ steps.app-token.outputs.token }}
          config-file: release-please-config.json
          manifest-file: .release-please-manifest.json

  release:
    name: Publish release
    needs: release-please
    if: >-
      always() && !failure() && !cancelled() &&
      (needs.release-please.outputs.release_created == 'true' ||
       (github.event_name == 'workflow_dispatch' && startsWith(github.event.inputs.tag, 'v')))
    runs-on: ubuntu-24.04
    timeout-minutes: 30
    permissions:
      actions: write
      attestations: write
      contents: write
      id-token: write
    env:
      TAG: ${{ needs.release-please.outputs.tag_name || inputs.tag }}
    steps:
      - uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2
        with:
          egress-policy: audit
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
          ref: ${{ github.sha }}
          path: publisher
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
          ref: ${{ env.TAG }}
          path: crate
      - uses: ./publisher/.github/actions/setup-rust
        with:
          workspace: crate
      - name: Package, SBOM, and provenance
        working-directory: crate
        run: |
          set -euo pipefail
          cargo package --locked --allow-dirty
          cargo install cargo-cyclonedx --version 0.5.9 --locked
          cargo cyclonedx --format json
          crate_file=$(find target/package -name 'argmend-*.crate' -print -quit)
          sbom=$(find . -name '*.cdx.json' -print -quit)
          if [ -z "$crate_file" ] || [ -z "$sbom" ]; then
            echo "FAIL: crate=${crate_file:-missing} sbom=${sbom:-missing}"
            find . -name '*.json' -o -name '*.crate' | head
            exit 1
          fi
          echo "OK: crate ${crate_file} sbom ${sbom}"
          cp "$crate_file" "$GITHUB_WORKSPACE/argmend.crate"
          cp "$sbom" "$GITHUB_WORKSPACE/sbom.cdx.json"
      - uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2
        id: attest
        with:
          subject-path: |
            argmend.crate
            sbom.cdx.json
      - name: Attach SBOM and provenance to the GitHub release
        env:
          GH_TOKEN: ${{ github.token }}
        run: |
          set -euo pipefail
          mkdir -p attestation-bundles
          for asset in argmend.crate sbom.cdx.json; do
            tmpdir=$(mktemp -d)
            pushd "$tmpdir" >/dev/null
            if gh attestation download "$GITHUB_WORKSPACE/$asset" --repo "${{ github.repository }}"; then
              for bundle in *.jsonl; do
                [ -f "$bundle" ] || continue
                cp "$bundle" "$GITHUB_WORKSPACE/attestation-bundles/${asset}.intoto.jsonl"
                break
              done
            fi
            popd >/dev/null
            rm -rf "$tmpdir"
          done
          gh release upload "$TAG" \
            "$GITHUB_WORKSPACE/argmend.crate" \
            "$GITHUB_WORKSPACE/sbom.cdx.json" \
            "$GITHUB_WORKSPACE"/attestation-bundles/*.intoto.jsonl \
            --repo "${{ github.repository }}" \
            --clobber
      # Curated notes live on release-note-<semver> or in Actions vars.
      # After a successful apply the notes branch is deleted. Missing
      # source leaves the auto changelog. continue-on-error so a notes
      # miss does not fail the crate publish.
      - name: Apply curated release notes
        continue-on-error: true
        env:
          GH_TOKEN: ${{ github.token }}
          GH_REPO: ${{ github.repository }}
          RELEASE_NOTES: ${{ vars.RELEASE_NOTES }}
          RELEASE_NOTES_TAG: ${{ vars.RELEASE_NOTES_TAG }}
        run: bash publisher/scripts/apply-release-notes.sh
      - name: Publish the crate
        env:
          GH_TOKEN: ${{ github.token }}
          GH_REPO: ${{ github.repository }}
        run: |
          set -euo pipefail
          case "$TAG" in
            v[0-9]*.[0-9]*.[0-9]*) ;;
            *)
              echo "FAIL: tag ${TAG} is not a release version"
              exit 1
              ;;
          esac
          gh workflow run publish-crates.yml --repo "$GH_REPO" --ref main -f "tag=${TAG}"
          echo "OK: started publish-crates.yml for ${TAG}"