Repository navigation
feat(release): sign OCI images and Helm charts with cosign #5451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
alangou
wants to merge
3
commits into
main
Choose a base branch
from
feat/sign-oci-artifacts/alangou
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+203
−11
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| # Keyless-sign the images and charts this run built, then require a valid | ||
| # signature on every tag it publishes. Image digests come from the build | ||
| # archives and chart digests from helm push (PUSHED_CHARTS). A tag is verified | ||
| # and never signed, so an artifact this run did not build cannot obtain a | ||
| # signature. | ||
|
|
||
| REGISTRY="quay.io/ai-openshell" | ||
| WORKFLOWS="https://github.com/ai-openshell/openshell/.github/workflows" | ||
|
|
||
| # The certificate identity names the workflow file, and any repository can call | ||
| # the reusable release-publish.yml. Also require the repository that ran it and, | ||
| # for a stable release, the main branch. | ||
| policy=(--certificate-oidc-issuer https://token.actions.githubusercontent.com --certificate-github-workflow-repository ai-openshell/openshell) | ||
| case "${RELEASE_CHANNEL}" in | ||
| dev) policy+=(--certificate-identity "${WORKFLOWS}/release-dev.yml@refs/heads/main") ;; | ||
| stable) policy+=(--certificate-identity "${WORKFLOWS}/release-publish.yml@refs/heads/main" --certificate-github-workflow-ref refs/heads/main) ;; | ||
| # cosign matches the regexp unanchored, hence ^...$ and the escaped dots. | ||
| prerelease) policy+=(--certificate-identity-regexp '^https://github\.com/ai-openshell/openshell/\.github/workflows/release-publish\.yml@refs/(heads/main|tags/v[0-9]+\.[0-9]+\.[0-9]+-pre\.[1-9][0-9]*)$') ;; | ||
| *) echo "::error::Unknown RELEASE_CHANNEL '${RELEASE_CHANNEL}'."; exit 1 ;; | ||
| esac | ||
|
|
||
| # Quay can briefly return 404 for a manifest or signature it just accepted. | ||
| retry() { "$@" || { sleep 15; "$@"; } || { sleep 45; "$@"; }; } | ||
|
|
||
| read -ra digests <<<"${PUSHED_CHARTS}" | ||
| tags=() | ||
| for image in gateway sandbox supervisor; do | ||
| digest="$(tar -xOf "artifacts/images/${image}.tar" index.json | jq -er '.manifests[0].digest')" | ||
| digests+=("${REGISTRY}/${image}@${digest}") | ||
| tags+=("${REGISTRY}/${image}:${IMAGE_TAG}") | ||
| done | ||
| for version in ${CHART_VERSIONS}; do | ||
| tags+=("${REGISTRY}/charts/openshell:${version}" "${REGISTRY}/charts/openshell-workspace:${version}") | ||
| done | ||
|
|
||
| for ref in "${digests[@]}"; do | ||
| if [[ ! "${ref}" =~ ^quay\.io/ai-openshell/(gateway|sandbox|supervisor|charts/openshell(-workspace)?)@sha256:[0-9a-f]{64}$ ]]; then | ||
| echo "::error::Refusing to sign '${ref}': not a digest in a published repository." | ||
| exit 1 | ||
| fi | ||
| # A kept image is another run's build, and a later dev run moves the | ||
| # 0.0.0-dev charts. This run's digest is then not in the registry and stays | ||
| # unsigned; the tag check requires the signature of the run that owns the tag. | ||
| if docker buildx imagetools inspect "${ref}" >/dev/null 2>&1; then | ||
|
SDAChess marked this conversation as resolved.
Resolved
|
||
| retry cosign sign --yes "${ref}" | ||
| fi | ||
| done | ||
|
|
||
| for tag in "${tags[@]}"; do | ||
| if ! retry cosign verify "${policy[@]}" "${tag}" >/dev/null; then | ||
| echo "::error::${tag} has no valid ${RELEASE_CHANNEL} signature. Re-run the failed jobs of the run that published it; another run cannot sign it." | ||
| exit 1 | ||
| fi | ||
| done | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.