Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
196 changes: 88 additions & 108 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ concurrency:
jobs:
activation:
runs-on: ubuntu-latest
permissions: {}
outputs:
enabled: ${{ steps.gate.outputs.enabled }}
steps:
Expand All @@ -39,7 +40,6 @@ jobs:
permissions:
contents: read
outputs:
artifact_name: ${{ steps.identity.outputs.artifact_name }}
previous_version: ${{ steps.intent.outputs.previous_version }}
released: ${{ steps.intent.outputs.released }}
release_sha: ${{ steps.identity.outputs.release_sha }}
Expand Down Expand Up @@ -116,29 +116,8 @@ jobs:
echo "release_sha=$release_sha"
echo "tag=$tag"
echo "version=$EXPECTED_VERSION"
echo "artifact_name=release-$EXPECTED_VERSION-$release_sha"
echo "source_artifact_name=release-source-$EXPECTED_VERSION-$release_sha"
} >> "$GITHUB_OUTPUT"
- name: Reject an already-published PyPI version
if: steps.intent.outputs.released == 'true'
env:
VERSION: ${{ steps.identity.outputs.version }}
run: |
status="$(curl --silent --show-error --output /dev/null \
--connect-timeout 10 --max-time 30 \
--write-out '%{http_code}' \
"https://pypi.org/pypi/hermes-plugin-kit/$VERSION/json")"
case "$status" in
404) ;;
200)
echo "Refusing existing PyPI version $VERSION" >&2
exit 1
;;
*)
echo "PyPI version preflight was inconclusive: HTTP $status" >&2
exit 1
;;
esac
- name: Materialize the immutable release source bundle before tests
if: steps.intent.outputs.released == 'true'
env:
Expand Down Expand Up @@ -323,10 +302,11 @@ jobs:
needs: [materialize, unit-public-tests, hermes-contract]
if: needs.materialize.outputs.released == 'true'
runs-on: ubuntu-latest
environment: private-artifacts
permissions:
contents: read
outputs:
artifact_name: ${{ needs.materialize.outputs.artifact_name }}
bundle_reference: ${{ steps.stage.outputs.bundle_reference }}
release_sha: ${{ needs.materialize.outputs.release_sha }}
tag: ${{ needs.materialize.outputs.tag }}
version: ${{ needs.materialize.outputs.version }}
Expand All @@ -346,6 +326,10 @@ jobs:
uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4
with:
just-version: "1.58.0"
- name: Install ORAS
uses: oras-project/setup-oras@1d808f7d7f6995cc68b7bf507bfe5c5446e1dc9d # v2.0.1
with:
version: "1.3.4"
- name: Download the immutable release source
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
Expand Down Expand Up @@ -385,7 +369,7 @@ jobs:
test "$(git rev-parse HEAD^)" = "$TRIGGER_SHA"
test "$(git rev-list -n 1 "$TAG")" = "$RELEASE_SHA"
test -z "$(git status --porcelain --untracked-files=no)"
- name: Create and verify the prepublication manifest
- name: Create and verify the tested artifact manifest
env:
PREVIOUS_VERSION: ${{ needs.materialize.outputs.previous_version }}
RELEASE_SHA: ${{ needs.materialize.outputs.release_sha }}
Expand All @@ -410,18 +394,25 @@ jobs:
run: |
sha256sum release-source.bundle release-manifest.json dist/* \
> release-payload.sha256
- name: Upload the tested release payload
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ needs.materialize.outputs.artifact_name }}
path: |
dist/
release-manifest.json
release-payload.sha256
release-source.bundle
if-no-files-found: error
compression-level: 0
retention-days: 90
- name: Stage and read back the exact payload in private GHCR
id: stage
env:
GH_TOKEN: ${{ secrets.PRIVATE_ARTIFACTS_TOKEN }}
RELEASE_SHA: ${{ needs.materialize.outputs.release_sha }}
run: |
: "${GH_TOKEN:?PRIVATE_ARTIFACTS_TOKEN must be configured in private-artifacts}"
python scripts/private_release.py check-private \
--repository ghcr.io/offendingcommit/hermes-plugin-kit
python scripts/private_release.py stage \
--repository ghcr.io/offendingcommit/hermes-plugin-kit \
--tag "candidate-${{ github.run_id }}-$RELEASE_SHA" \
--manifest release-manifest.json \
--artifact-dir dist \
--source-bundle release-source.bundle \
--payload-checksums release-payload.sha256 \
--output staged-release.json
reference="$(jq -er '.bundle_reference | select(test("^ghcr\\.io/offendingcommit/hermes-plugin-kit@sha256:[0-9a-f]{64}$"))' staged-release.json)"
echo "bundle_reference=$reference" >> "$GITHUB_OUTPUT"

promote-source:
needs: [materialize, build, immutable-release-control]
Expand All @@ -431,7 +422,7 @@ jobs:
permissions:
contents: read
outputs:
artifact_name: ${{ needs.materialize.outputs.artifact_name }}
bundle_reference: ${{ needs.build.outputs.bundle_reference }}
release_sha: ${{ needs.materialize.outputs.release_sha }}
tag: ${{ needs.materialize.outputs.tag }}
version: ${{ needs.materialize.outputs.version }}
Expand All @@ -442,10 +433,19 @@ jobs:
fetch-depth: 0
persist-credentials: false
ref: ${{ github.sha }}
- name: Download the tested release payload
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
- name: Install ORAS
uses: oras-project/setup-oras@1d808f7d7f6995cc68b7bf507bfe5c5446e1dc9d # v2.0.1
with:
name: ${{ needs.materialize.outputs.artifact_name }}
version: "1.3.4"
- name: Fetch the privately staged payload by immutable digest
env:
GH_TOKEN: ${{ secrets.PRIVATE_ARTIFACTS_TOKEN }}
BUNDLE_REFERENCE: ${{ needs.build.outputs.bundle_reference }}
run: |
: "${GH_TOKEN:?PRIVATE_ARTIFACTS_TOKEN must be configured in source-promotion}"
python scripts/private_release.py fetch \
--reference "$BUNDLE_REFERENCE" \
--output-dir .
- name: Validate and atomically push only the tested source
env:
GH_TOKEN: ${{ secrets.SOURCE_PROMOTION_TOKEN }}
Expand Down Expand Up @@ -491,90 +491,65 @@ jobs:
test "$remote_main" = "$RELEASE_SHA"
test "$remote_tag" = "$RELEASE_SHA"

publish:
publish-private:
needs: promote-source
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/hermes-plugin-kit/${{ needs.promote-source.outputs.version }}/
permissions:
id-token: write
steps:
- name: Download the tested release payload
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ needs.promote-source.outputs.artifact_name }}
- name: Recheck the immutable payload before publication
run: sha256sum --check release-payload.sha256
- name: Publish the tested distributions with Trusted Publishing
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
with:
packages-dir: dist/
# Safe because the next job downloads and hash-verifies every PyPI file.
skip-existing: true

verify-pypi:
needs: [promote-source, publish]
runs-on: ubuntu-latest
environment: private-artifacts
permissions:
contents: read
outputs:
receipt_artifact_name: ${{ steps.receipt.outputs.artifact_name }}
bundle_reference: ${{ steps.publish.outputs.bundle_reference }}
receipt_reference: ${{ steps.publish.outputs.receipt_reference }}
steps:
- name: Check out the published source identity
- name: Check out the promoted source identity without credentials
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
ref: ${{ needs.promote-source.outputs.release_sha }}
- name: Download the published release payload
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
- name: Install ORAS
uses: oras-project/setup-oras@1d808f7d7f6995cc68b7bf507bfe5c5446e1dc9d # v2.0.1
with:
name: ${{ needs.promote-source.outputs.artifact_name }}
- name: Verify PyPI bytes and finalize the discoverable receipt
id: receipt
version: "1.3.4"
- name: Publish the exact staged manifest and a private verified receipt
id: publish
env:
GH_TOKEN: ${{ secrets.PRIVATE_ARTIFACTS_TOKEN }}
BUNDLE_REFERENCE: ${{ needs.promote-source.outputs.bundle_reference }}
RELEASE_SHA: ${{ needs.promote-source.outputs.release_sha }}
TAG: ${{ needs.promote-source.outputs.tag }}
run: |
: "${GH_TOKEN:?PRIVATE_ARTIFACTS_TOKEN must be configured in private-artifacts}"
test "$(git rev-parse HEAD)" = "$RELEASE_SHA"
test "$(git rev-list -n 1 "$TAG")" = "$RELEASE_SHA"
test -z "$(git status --porcelain --untracked-files=no)"
sha256sum --check release-payload.sha256
python scripts/release_contract.py finalize-receipt \
--manifest release-manifest.json \
--output release-receipt.json
python scripts/private_release.py check-private \
--repository ghcr.io/offendingcommit/hermes-plugin-kit
python scripts/private_release.py publish \
--reference "$BUNDLE_REFERENCE" \
--output release-receipt.json \
--references publication.json
python scripts/release_contract.py verify-final-receipt \
--receipt release-receipt.json
echo "artifact_name=release-receipt-$RELEASE_SHA" >> "$GITHUB_OUTPUT"
- name: Upload the finalized discoverable receipt
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ steps.receipt.outputs.artifact_name }}
path: release-receipt.json
if-no-files-found: error
retention-days: 90
bundle_reference="$(jq -er '.bundle_reference | select(test("^ghcr\\.io/offendingcommit/hermes-plugin-kit@sha256:[0-9a-f]{64}$"))' publication.json)"
receipt_reference="$(jq -er '.receipt_reference | select(test("^ghcr\\.io/offendingcommit/hermes-plugin-kit@sha256:[0-9a-f]{64}$"))' publication.json)"
test "$bundle_reference" = "$BUNDLE_REFERENCE"
{
echo "bundle_reference=$bundle_reference"
echo "receipt_reference=$receipt_reference"
} >> "$GITHUB_OUTPUT"

github-release:
needs: [promote-source, publish, verify-pypi]
needs: [promote-source, publish-private]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download the published release payload
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ needs.promote-source.outputs.artifact_name }}
- name: Download the finalized discoverable receipt
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ needs.verify-pypi.outputs.receipt_artifact_name }}
path: final-receipt
- name: Verify the payload published by the preceding job
run: sha256sum --check release-payload.sha256
- name: Create the immutable discoverable GitHub Release and receipt
- name: Create or verify an immutable metadata-only GitHub Release
env:
GH_TOKEN: ${{ github.token }}
BUNDLE_REFERENCE: ${{ needs.publish-private.outputs.bundle_reference }}
RECEIPT_REFERENCE: ${{ needs.publish-private.outputs.receipt_reference }}
RELEASE_SHA: ${{ needs.promote-source.outputs.release_sha }}
TAG: ${{ needs.promote-source.outputs.tag }}
VERSION: ${{ needs.promote-source.outputs.version }}
Expand All @@ -585,20 +560,25 @@ jobs:
remote_tag="$(git ls-remote "$repository_url" "refs/tags/$TAG" | cut -f1)"
fi
test "$remote_tag" = "$RELEASE_SHA"
if gh release view "$TAG" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
test "$(gh release view "$TAG" --repo "$GITHUB_REPOSITORY" --json isImmutable --jq '.isImmutable')" = "true"
mkdir existing-release
gh release download "$TAG" --repo "$GITHUB_REPOSITORY" \
--dir existing-release
cmp final-receipt/release-receipt.json existing-release/release-receipt.json
for artifact in dist/*; do
cmp "$artifact" "existing-release/$(basename "$artifact")"
done
else
gh release create "$TAG" dist/* final-receipt/release-receipt.json \
jq -en --arg bundle "$BUNDLE_REFERENCE" --arg receipt "$RECEIPT_REFERENCE" \
'[$bundle, $receipt] | all(test("^ghcr\\.io/offendingcommit/hermes-plugin-kit@sha256:[0-9a-f]{64}$"))'
body="$(printf '%s\n' \
'Release artifacts are private; authenticated package access is required.' \
'' \
"Bundle: \`$BUNDLE_REFERENCE\`" \
"Receipt: \`$RECEIPT_REFERENCE\`" \
'' \
'Pin these immutable digests, not discovery tags. See README installation instructions.')"
if ! gh release view "$TAG" --repo "$GITHUB_REPOSITORY" \
--json isImmutable,isDraft,tagName,body,assets > existing-release.json; then
gh release create "$TAG" \
--repo "$GITHUB_REPOSITORY" \
--verify-tag \
--title "hermes-plugin-kit $VERSION" \
--generate-notes
test "$(gh release view "$TAG" --repo "$GITHUB_REPOSITORY" --json isImmutable --jq '.isImmutable')" = "true"
--notes "$body"
gh release view "$TAG" --repo "$GITHUB_REPOSITORY" \
--json isImmutable,isDraft,tagName,body,assets > existing-release.json
fi
jq -e --arg tag "$TAG" --arg body "$body" \
'.isImmutable == true and .isDraft == false and .tagName == $tag
and .body == $body and .assets == []' existing-release.json
48 changes: 39 additions & 9 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ plugin.
deployment configuration; explicit-name selection remains mutually exclusive
for narrow legacy surfaces. Registration preflight must finish before the
first `ctx.register_*` mutation, and receipts must name selected capabilities.
- Consumer plugins must pin this package to an immutable commit, not a moving
branch. Profiles that install multiple plugins into one Python environment
must keep every consumer on the same kit revision.
- Consumer deployments must pin this package's private OCI bundle/receipt
digests and verified wheel SHA-256, never a moving branch or registry tag.
Source-based development pins an immutable commit. Profiles that install
multiple plugins into one Python environment must use one qualified kit
revision for every consumer.
- Use `invoke_host_tool` for host-managed capabilities such as `send_message`;
do not assume every Hermes capability is registered in `tools.registry`.
Nested host calls must remain visible to `pre_tool_call` and `post_tool_call`.
Expand Down Expand Up @@ -83,12 +85,40 @@ Keep `skills/hermes-plugins/references/plugin-kit.md` aligned with public API
and contract changes so the repo-owned authoring skill does not teach stale
behavior.

Release authentication uses `SOURCE_PROMOTION_TOKEN` from the main-only
The source repository stays public; release wheels, sdists, and receipts stay
private in `ghcr.io/offendingcommit/hermes-plugin-kit`. Source visibility never
authorizes public artifact publication. Public-repository Actions artifacts
are not private distribution: upload only public source/test evidence there.
GitHub Releases are immutable metadata only, with private digest references
and zero assets, including receipts.

Package privacy is independent of source access. Keep the GHCR package
unlinked, with its own explicit ACL; never grant this public repository Actions
access or add `org.opencontainers.image.source`. Do not use the built-in
`GITHUB_TOKEN` for package access: associating a private package with a public
repository can expose it to fork workflows. Registry steps use step-scoped
`GH_TOKEN` from protected environment secret `PRIVATE_ARTIFACTS_TOKEN`; writers
use the main-only `private-artifacts` environment, and source-promotion fetch
uses a read-capable secret in its own main-only environment.

Require a positive package API `visibility=private` check before any sensitive
upload. An absent package may receive metadata-only bootstrap content, then
must be rechecked. API errors and public/internal visibility fail closed.
Use ORAS with stdin/temporary authentication; preserve deterministic OCI
identities, digest-pinned retrieval, exact tested bytes, both test gates,
metadata checks, and downloaded-byte verification. Discovery tags cannot
replace digest identity; retries must refuse conflicting existing tags.

Source authentication uses `SOURCE_PROMOTION_TOKEN` from the main-only
`source-promotion` environment. A suitable PAT or existing GitHub credential
is valid; a particular token-minting mechanism is not a release invariant.
Keep the Administration-read immutability check, tested-source identity,
atomic guarded push, PyPI OIDC and published-byte verification intact.
Never expose the promotion credential to source-testing/build jobs, silently
fall back to the default Actions token, or change branch-policy bypasses as
part of credential wiring. An environment restriction narrows availability,
not the underlying token's permissions.
atomic guarded push, and immutable metadata-only GitHub Release control intact.
Never expose the promotion credential to source-testing/build or registry
steps, silently fall back to the default Actions token, or change branch-policy
bypasses as part of credential wiring. Environment restrictions narrow token
availability, not underlying permissions.

Keep `SEMANTIC_RELEASE_ENABLED=false` until the private cutover is reviewed.
The tagged `v0.9.0` publication failed before publishing: never retag, rebuild,
or retry its old PyPI workflow. The next reviewed normal release is the cutover.
Loading
Loading