|
| 1 | +# Trusted-path attestation: signed conformance certificate + validation. |
| 2 | +# Mirrors intentproof-api/.github/workflows/conformance-attestation.yml. |
| 3 | +# PR checks stay on spec-conformance.yml (no signing secrets required). |
| 4 | +name: Conformance Attestation |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: [main, master] |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + |
| 14 | +concurrency: |
| 15 | + group: conformance-attestation-${{ github.ref }} |
| 16 | + cancel-in-progress: true |
| 17 | + |
| 18 | +jobs: |
| 19 | + conformance-attestation: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + timeout-minutes: 30 |
| 22 | + env: |
| 23 | + PUBLISH_CONFORMANCE_ROOT: ${{ github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'master') && github.actor != 'github-actions[bot]' && github.actor != 'intentproof-cert-bot[bot]' }} |
| 24 | + steps: |
| 25 | + - name: Checkout SDK repository |
| 26 | + uses: actions/checkout@v6 |
| 27 | + with: |
| 28 | + persist-credentials: false |
| 29 | + |
| 30 | + - name: Resolve pinned intentproof-spec revision |
| 31 | + id: spec_pin |
| 32 | + run: | |
| 33 | + set -euo pipefail |
| 34 | + python3 - <<'PY' |
| 35 | + import os |
| 36 | + import tomllib |
| 37 | + from pathlib import Path |
| 38 | + c = tomllib.loads(Path("pyproject.toml").read_text(encoding="utf-8"))["tool"]["intentproof"]["spec-commit"] |
| 39 | + with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as f: |
| 40 | + f.write(f"sha={c}\n") |
| 41 | + PY |
| 42 | +
|
| 43 | + - name: Checkout intentproof-spec |
| 44 | + uses: actions/checkout@v6 |
| 45 | + with: |
| 46 | + repository: IntentProof/intentproof-spec |
| 47 | + ref: ${{ steps.spec_pin.outputs.sha }} |
| 48 | + fetch-depth: 0 |
| 49 | + path: intentproof-spec |
| 50 | + |
| 51 | + - uses: ./.github/actions/setup-python-pip |
| 52 | + with: |
| 53 | + python-version: "3.x" |
| 54 | + check-latest: true |
| 55 | + |
| 56 | + - name: Install tox |
| 57 | + run: pip install "tox>=4" |
| 58 | + |
| 59 | + # secrets context is not allowed in step `if:`; pass PEMs via env and verify in shell. |
| 60 | + - name: Require attestation secrets |
| 61 | + env: |
| 62 | + INTENTPROOF_CERTIFICATE_SIGNING_KEY_PEM: ${{ secrets.INTENTPROOF_CERTIFICATE_SIGNING_KEY_PEM }} |
| 63 | + INTENTPROOF_CERTIFICATE_PUBLIC_KEY_PEM: ${{ secrets.INTENTPROOF_CERTIFICATE_PUBLIC_KEY_PEM }} |
| 64 | + INTENTPROOF_SPEC_INTEGRITY_PUBLIC_KEY_PEM: ${{ secrets.INTENTPROOF_SPEC_INTEGRITY_PUBLIC_KEY_PEM }} |
| 65 | + run: | |
| 66 | + if [[ -z "${INTENTPROOF_CERTIFICATE_SIGNING_KEY_PEM}" || -z "${INTENTPROOF_CERTIFICATE_PUBLIC_KEY_PEM}" ]]; then |
| 67 | + echo '::error::Configure repository secrets INTENTPROOF_CERTIFICATE_SIGNING_KEY_PEM and INTENTPROOF_CERTIFICATE_PUBLIC_KEY_PEM.' |
| 68 | + exit 1 |
| 69 | + fi |
| 70 | + if [[ -z "${INTENTPROOF_SPEC_INTEGRITY_PUBLIC_KEY_PEM}" ]]; then |
| 71 | + echo '::error::Configure repository secret INTENTPROOF_SPEC_INTEGRITY_PUBLIC_KEY_PEM (spec integrity verify during oracle).' |
| 72 | + exit 1 |
| 73 | + fi |
| 74 | +
|
| 75 | + - name: SDK quality gates (tox static + cov) |
| 76 | + env: |
| 77 | + INTENTPROOF_SPEC_ROOT: ${{ github.workspace }}/intentproof-spec |
| 78 | + run: tox run -e static,cov |
| 79 | + |
| 80 | + - name: Set up Node.js for spec oracle |
| 81 | + uses: actions/setup-node@v6 |
| 82 | + with: |
| 83 | + node-version-file: intentproof-spec/.nvmrc |
| 84 | + cache: npm |
| 85 | + cache-dependency-path: intentproof-spec/package-lock.json |
| 86 | + |
| 87 | + - name: Conformance (trusted attestation gate) |
| 88 | + env: |
| 89 | + INTENTPROOF_SPEC_ROOT: ${{ github.workspace }}/intentproof-spec |
| 90 | + INTENTPROOF_SDK_ID: python |
| 91 | + INTENTPROOF_REPLAY_VERIFY: "1" |
| 92 | + INTENTPROOF_CONFORMANCE_JSON: "1" |
| 93 | + INTENTPROOF_CERTIFICATE_SCHEMA_VERSION: "v2" |
| 94 | + INTENTPROOF_SPEC_INTEGRITY_PUBLIC_KEY_PEM: ${{ secrets.INTENTPROOF_SPEC_INTEGRITY_PUBLIC_KEY_PEM }} |
| 95 | + INTENTPROOF_CERTIFICATE_SIGNING_KEY_PEM: ${{ secrets.INTENTPROOF_CERTIFICATE_SIGNING_KEY_PEM }} |
| 96 | + INTENTPROOF_CERTIFICATE_SIGNING_KEY_ID: intentproof-ci-ed25519-v1 |
| 97 | + run: bash scripts/spec-conformance.sh |
| 98 | + |
| 99 | + - name: Validate conformance certificate |
| 100 | + working-directory: intentproof-spec |
| 101 | + env: |
| 102 | + INTENTPROOF_CERTIFICATE_PUBLIC_KEY_PEM: ${{ secrets.INTENTPROOF_CERTIFICATE_PUBLIC_KEY_PEM }} |
| 103 | + INTENTPROOF_CERTIFICATE_REQUIRE_SIGNATURE: "1" |
| 104 | + INTENTPROOF_CERTIFICATE_SCHEMA_VERSION: "v2" |
| 105 | + run: npm run validate:conformance-certificate |
| 106 | + |
| 107 | + - name: Upload conformance report and certificate |
| 108 | + uses: actions/upload-artifact@v7 |
| 109 | + with: |
| 110 | + name: conformance-artifacts |
| 111 | + path: | |
| 112 | + intentproof-spec/conformance-report.json |
| 113 | + intentproof-spec/conformance-certificate.json |
| 114 | + if-no-files-found: error |
| 115 | + |
| 116 | + - name: Mint cert-bot installation token |
| 117 | + id: cert_bot_token |
| 118 | + if: ${{ env.PUBLISH_CONFORMANCE_ROOT == 'true' }} |
| 119 | + uses: actions/create-github-app-token@v1 |
| 120 | + with: |
| 121 | + app-id: ${{ vars.INTENTPROOF_CERT_BOT_ID }} |
| 122 | + private-key: ${{ secrets.INTENTPROOF_CERT_BOT_PRIVATE_KEY }} |
| 123 | + |
| 124 | + - name: Publish conformance certificate and report at repo root |
| 125 | + if: ${{ env.PUBLISH_CONFORMANCE_ROOT == 'true' }} |
| 126 | + env: |
| 127 | + INTENTPROOF_CERT_BOT_TOKEN: ${{ steps.cert_bot_token.outputs.token }} |
| 128 | + run: | |
| 129 | + set -euo pipefail |
| 130 | + cp intentproof-spec/conformance-certificate.json conformance-certificate.json |
| 131 | + cp intentproof-spec/conformance-report.json conformance-report.json |
| 132 | + if git diff --quiet -- conformance-certificate.json conformance-report.json; then |
| 133 | + echo "No conformance artifact updates to commit." |
| 134 | + exit 0 |
| 135 | + fi |
| 136 | + git config user.name "intentproof-cert-bot[bot]" |
| 137 | + git config user.email "intentproof-cert-bot[bot]@users.noreply.github.com" |
| 138 | + git config --local --unset-all http.https://github.com/.extraheader || true |
| 139 | + git remote set-url origin "https://x-access-token:${INTENTPROOF_CERT_BOT_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" |
| 140 | + git add conformance-certificate.json conformance-report.json |
| 141 | + git commit -m "chore(ci): update conformance certificate and report" |
| 142 | + git push |
0 commit comments