diff --git a/.github/workflows/bump-cli-version.yml b/.github/workflows/bump-cli-version.yml new file mode 100644 index 0000000..a741f28 --- /dev/null +++ b/.github/workflows/bump-cli-version.yml @@ -0,0 +1,39 @@ +name: Bump Cloudsmith CLI + +# Opens a pull request that pins the default cli-version of the cloudsmith-cli +# kit to a Cloudsmith CLI release. The CLI release workflow sends the +# cloudsmith-cli-release event. Run the workflow by hand to pin a specific +# version. +on: + repository_dispatch: + types: + - cloudsmith-cli-release + workflow_dispatch: + inputs: + version: + description: The Cloudsmith CLI version to pin, for example 1.31.3. + required: true + +permissions: {} + +concurrency: + group: bump-cli-version + cancel-in-progress: false + queue: max + +jobs: + bump: + name: Open the bump pull request + permissions: + contents: read + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Open the bump pull request + uses: cloudsmith-io/cloudsmith-cli/.github/actions/open-cli-bump-pr@34f5fd967daaab552a66dd9a890d550c47a39b0c # master + with: + version: ${{ github.event.client_payload.version || inputs.version }} + bump-command: bash scripts/bump-cli-version.sh "$VERSION" + merge: "true" + token: ${{ secrets.CLOUDSMITH_BOT_TOKEN }} + ssh-signing-key: ${{ secrets.CLOUDSMITH_BOT_SSH_SIGNING_KEY }} diff --git a/.github/workflows/publish-dockerhub.yml b/.github/workflows/publish-dockerhub.yml index 76f052b..846d39c 100644 --- a/.github/workflows/publish-dockerhub.yml +++ b/.github/workflows/publish-dockerhub.yml @@ -3,6 +3,17 @@ name: Publish kits to Docker Hub on: push: tags: ["*-v*"] + workflow_call: + inputs: + tag: + description: Existing kit tag, e.g. cloudsmith-repo-v0.1.0 + required: true + type: string + secrets: + DOCKERHUB_PUBLISH_USER: + required: true + DOCKERHUB_PUBLISH_TOKEN: + required: true workflow_dispatch: inputs: tag: @@ -106,8 +117,9 @@ jobs: sbx kit push --sign "./${KIT_DIR}" "$ref" digest=$(oras manifest fetch --descriptor "$ref" | jq -er '.digest') [[ "$digest" =~ ^sha256:[a-f0-9]{64}$ ]] + # The certificate names this workflow file, also when another workflow calls it. sbx kit verify \ - --certificate-identity "https://github.com/${GITHUB_WORKFLOW_REF}" \ + --certificate-identity "https://github.com/${REPOSITORY}/.github/workflows/publish-dockerhub.yml@${GITHUB_REF}" \ --certificate-oidc-issuer https://token.actions.githubusercontent.com \ "${ref%:*}@${digest}" printf 'Published and verified %s@%s\n' "${ref%:*}" "$digest" >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f45abfb..97088d4 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -3,6 +3,12 @@ name: Publish kit artifacts on: push: tags: ["*-v*"] + workflow_call: + inputs: + tag: + description: Existing kit tag, e.g. cloudsmith-repo-v0.1.0 + required: true + type: string workflow_dispatch: inputs: tag: @@ -124,8 +130,9 @@ jobs: sbx kit push --sign "./${KIT_DIR}" "$ref" digest=$(oras manifest fetch --descriptor "$ref" | jq -er '.digest') [[ "$digest" =~ ^sha256:[a-f0-9]{64}$ ]] + # The certificate names this workflow file, also when another workflow calls it. sbx kit verify \ - --certificate-identity "https://github.com/${GITHUB_WORKFLOW_REF}" \ + --certificate-identity "https://github.com/${REPOSITORY}/.github/workflows/publish.yml@${GITHUB_REF}" \ --certificate-oidc-issuer https://token.actions.githubusercontent.com \ "${ref%:*}@${digest}" printf 'Published and verified %s@%s\n' "${ref%:*}" "$digest" >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..f4c84d4 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,139 @@ +name: Release cloudsmith-cli kit + +# Releases the newest version in cloudsmith-cli/CHANGELOG.md when no tag exists +# for it yet. A kit whose signature does not verify is signed first; the merge +# of the signature pull request starts this workflow again. A tag that +# GITHUB_TOKEN creates starts no workflows, so this workflow calls the publish +# workflows itself. +on: + push: + branches: + - main + paths: + - cloudsmith-cli/CHANGELOG.md + - cloudsmith-cli/kit.sig.bundle + workflow_dispatch: {} + +permissions: {} + +concurrency: + group: release-cloudsmith-cli + cancel-in-progress: false + queue: max + +jobs: + version: + name: Find the version to release + if: github.ref == 'refs/heads/main' + permissions: + contents: read + runs-on: ubuntu-latest + timeout-minutes: 10 + outputs: + tag: ${{ steps.version.outputs.tag }} + released: ${{ steps.version.outputs.released }} + signed: ${{ steps.signature.outputs.signed }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 2 + persist-credentials: false + + - name: Read the newest CHANGELOG version + id: version + run: | + set -euo pipefail + version="$(sed -n 's/^## \[\([0-9]*\.[0-9]*\.[0-9]*\)\].*/\1/p' cloudsmith-cli/CHANGELOG.md | head -n 1)" + grep -Fxq "version: \"$version\"" cloudsmith-cli/spec.yaml || + { echo "::error::cloudsmith-cli/spec.yaml does not have version $version"; exit 1; } + tag="cloudsmith-cli-v$version" + echo "tag=$tag" >> "$GITHUB_OUTPUT" + status=0 + git ls-remote --exit-code --tags origin "refs/tags/$tag" > /dev/null || status=$? + case "$status" in + 0) echo "$tag is already released"; echo "released=true" >> "$GITHUB_OUTPUT" ;; + 2) echo "$tag is not released yet"; echo "released=false" >> "$GITHUB_OUTPUT" ;; + *) exit "$status" ;; + esac + + - name: Install sbx + if: steps.version.outputs.released == 'false' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CLI_ONLY: "1" + run: ./scripts/install-sbx.sh >> "$GITHUB_PATH" + + - name: Verify the kit signature + id: signature + if: steps.version.outputs.released == 'false' + env: + REPOSITORY: ${{ github.repository }} + run: | + set -euo pipefail + if sbx kit verify \ + --certificate-identity "https://github.com/${REPOSITORY}/.github/workflows/sign.yml@refs/heads/main" \ + --certificate-oidc-issuer https://token.actions.githubusercontent.com ./cloudsmith-cli; then + echo "signed=true" >> "$GITHUB_OUTPUT" + elif git diff --quiet HEAD^ HEAD -- cloudsmith-cli/kit.sig.bundle; then + echo "signed=false" >> "$GITHUB_OUTPUT" + else + echo "::error::The new signature of the cloudsmith-cli kit does not verify" + exit 1 + fi + + sign: + name: Sign the kits + needs: version + if: needs.version.outputs.released == 'false' && needs.version.outputs.signed == 'false' + permissions: + contents: read + id-token: write + uses: ./.github/workflows/sign.yml + with: + merge: true + secrets: + CLOUDSMITH_BOT_TOKEN: ${{ secrets.CLOUDSMITH_BOT_TOKEN }} + CLOUDSMITH_BOT_NAME: ${{ secrets.CLOUDSMITH_BOT_NAME }} + CLOUDSMITH_BOT_EMAIL: ${{ secrets.CLOUDSMITH_BOT_EMAIL }} + CLOUDSMITH_BOT_SSH_SIGNING_KEY: ${{ secrets.CLOUDSMITH_BOT_SSH_SIGNING_KEY }} + + tag: + name: Create the release tag + needs: version + if: needs.version.outputs.released == 'false' && needs.version.outputs.signed == 'true' + permissions: + contents: write + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - name: Create the release tag + env: + GH_TOKEN: ${{ github.token }} + TAG: ${{ needs.version.outputs.tag }} + run: | + gh api --method POST "repos/$GITHUB_REPOSITORY/git/refs" \ + -f "ref=refs/tags/$TAG" -f "sha=$GITHUB_SHA" + + publish: + name: Publish to Cloudsmith + needs: [version, tag] + permissions: + contents: read + id-token: write + uses: ./.github/workflows/publish.yml + with: + tag: ${{ needs.version.outputs.tag }} + + publish-dockerhub: + name: Publish to Docker Hub + needs: [version, tag] + if: vars.DOCKERHUB_PUBLISH_ENABLED == 'true' + permissions: + contents: read + id-token: write + uses: ./.github/workflows/publish-dockerhub.yml + with: + tag: ${{ needs.version.outputs.tag }} + secrets: + DOCKERHUB_PUBLISH_USER: ${{ secrets.DOCKERHUB_PUBLISH_USER }} + DOCKERHUB_PUBLISH_TOKEN: ${{ secrets.DOCKERHUB_PUBLISH_TOKEN }} diff --git a/.github/workflows/sign.yml b/.github/workflows/sign.yml index a868777..d198d87 100644 --- a/.github/workflows/sign.yml +++ b/.github/workflows/sign.yml @@ -4,6 +4,21 @@ name: Sign kits # invalidate the signatures. on: + workflow_call: + inputs: + merge: + description: Squash-merge the signature pull request when its checks pass + type: boolean + default: false + secrets: + CLOUDSMITH_BOT_TOKEN: + required: true + CLOUDSMITH_BOT_NAME: + required: true + CLOUDSMITH_BOT_EMAIL: + required: true + CLOUDSMITH_BOT_SSH_SIGNING_KEY: + required: true workflow_dispatch: inputs: amend_release: @@ -21,7 +36,7 @@ jobs: sign: if: github.ref == 'refs/heads/main' runs-on: ubuntu-latest - timeout-minutes: 20 + timeout-minutes: 60 permissions: contents: read id-token: write @@ -61,6 +76,7 @@ jobs: done - name: Commit signatures and prepare delivery + id: commit env: GH_TOKEN: ${{ secrets.CLOUDSMITH_BOT_TOKEN }} BOT_NAME: ${{ secrets.CLOUDSMITH_BOT_NAME }} @@ -119,6 +135,8 @@ jobs: git commit -m "Sign kits (keyless, bound to the sign workflow identity)" git -c credential.helper= -c 'credential.helper=!gh auth git-credential' \ push "https://github.com/${REPOSITORY}.git" "$branch" + echo "branch=$branch" >> "$GITHUB_OUTPUT" + echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" gh pr create --repo "$REPOSITORY" --base "$BASE" --head "$branch" \ --title "Sign kits" \ @@ -128,6 +146,28 @@ jobs: Squash-merge, then tag the resulting commit \`-v\`. The signature covers the exact bytes of each \`spec.yaml\` and \`files/\`, so any edit after this merge invalidates it." + - name: Merge the signature pull request + if: inputs.merge && steps.commit.outputs.branch != '' + env: + GH_TOKEN: ${{ secrets.CLOUDSMITH_BOT_TOKEN }} + REPOSITORY: ${{ github.repository }} + BRANCH: ${{ steps.commit.outputs.branch }} + HEAD_SHA: ${{ steps.commit.outputs.sha }} + run: | + set -euo pipefail + # gh pr checks fails when no checks are registered yet. + sleep 60 + gh pr checks "$BRANCH" --repo "$REPOSITORY" --watch --fail-fast + git fetch --quiet origin main + if ! git diff --quiet "${HEAD_SHA}^" FETCH_HEAD -- '*/spec.yaml' '*/files/*'; then + gh pr close "$BRANCH" --repo "$REPOSITORY" \ + --comment "A kit on main changed after this signature. The next release run signs the kits again." + gh api --method DELETE "repos/${REPOSITORY}/git/refs/heads/${BRANCH}" + echo "::error::A kit on main changed after this signature." + exit 1 + fi + gh pr merge "$BRANCH" --repo "$REPOSITORY" --admin --squash --match-head-commit "$HEAD_SHA" + - name: Upload signed release bundle if: inputs.amend_release uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a7eef60..d282892 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -103,8 +103,15 @@ Do not vendor or rebuild the harness because the CLI releases separately. `cloudsmith-cli` pins Cloudsmith's installer script in its spec. To move to a new installer, set `INSTALLER_VERSION` and take the matching `INSTALLER_SHA256` -from that release's `SHA256SUMS`. To move the default CLI release, change the -`cli-version` default. +from that release's `SHA256SUMS`. To move the default CLI release, run +`scripts/bump-cli-version.sh `. The script also bumps the kit version +and adds an entry to `cloudsmith-cli/CHANGELOG.md`. The `Bump Cloudsmith CLI` +workflow runs it for each CLI release and merges the pull request when the +checks pass. A new major CLI release needs a manual change. + +The `Release cloudsmith-cli kit` workflow releases the newest version in +`cloudsmith-cli/CHANGELOG.md` when it has no tag. It signs the kit if the +signature does not verify, then creates the tag and publishes the kit. ## Per-Kit README diff --git a/cloudsmith-cli/CHANGELOG.md b/cloudsmith-cli/CHANGELOG.md new file mode 100644 index 0000000..b3eb16f --- /dev/null +++ b/cloudsmith-cli/CHANGELOG.md @@ -0,0 +1,15 @@ +# Changelog + +This file records the changes in each release of the cloudsmith-cli kit. + +## [0.1.1] - 2026-11-18 + +### Changed + +- Pin the default `cli-version` to Cloudsmith CLI 1.31.3. + +## [0.1.0] - 2026-09-11 + +### Added + +- Install the Cloudsmith CLI with Cloudsmith's pinned installer. diff --git a/cloudsmith-cli/README.md b/cloudsmith-cli/README.md index f408915..fb7debd 100644 --- a/cloudsmith-cli/README.md +++ b/cloudsmith-cli/README.md @@ -47,10 +47,14 @@ organization-governance rule. | Argument | Default | Value | | --- | --- | --- | -| `cli-version` | `1.27.0` | A release number, or `latest` | - -Keep the default or pin another release for reproducible installs. `latest` -resolves at install time even when the kit itself is pinned. +| `cli-version` | The release in [`spec.yaml`](./spec.yaml) | A release number, or `latest` | + +The default is an exact CLI release, so installs are reproducible. Maintainers +bump it to each new CLI release with the same major version and release a new +kit version. [CHANGELOG.md](./CHANGELOG.md) names the release that each kit +version pins. Pass another release number to pin a different release. `latest` +is still accepted. It resolves at install time even when the kit itself is +pinned. ## Authentication diff --git a/cloudsmith-cli/spec.yaml b/cloudsmith-cli/spec.yaml index aa18a55..43ec293 100644 --- a/cloudsmith-cli/spec.yaml +++ b/cloudsmith-cli/spec.yaml @@ -1,5 +1,5 @@ schemaVersion: "2" -version: "0.1.0" +version: "0.1.1" sourceURL: https://github.com/cloudsmith-io/cloudsmith-sbx-kits licenses: - Apache-2.0 @@ -11,7 +11,7 @@ description: Installs the cloudsmith CLI with Cloudsmith's verified installer; t # Arguments are substituted before shell parsing; keep the pattern restrictive. args: cli-version: - default: "1.27.0" + default: "1.31.3" description: cloudsmith CLI version to install, a release number or "latest" pattern: '^(latest|[0-9]+\.[0-9]+\.[0-9]+)$' diff --git a/scripts/bump-cli-version.sh b/scripts/bump-cli-version.sh new file mode 100755 index 0000000..55be295 --- /dev/null +++ b/scripts/bump-cli-version.sh @@ -0,0 +1,60 @@ +#!/usr/bin/env bash +# Pins the default cli-version of the cloudsmith-cli kit to a new Cloudsmith +# CLI release, bumps the patch version of the kit and records the release in +# cloudsmith-cli/CHANGELOG.md. Prints the new kit version. +# Prints nothing and changes nothing when the release is not newer than the +# pinned release or has a different major version. +# Usage: scripts/bump-cli-version.sh CLI_VERSION +set -euo pipefail + +cli_version="${1:-}" +[[ "$cli_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] \ + || { echo "usage: $0 MAJOR.MINOR.PATCH" >&2; exit 1; } + +spec=cloudsmith-cli/spec.yaml +changelog=cloudsmith-cli/CHANGELOG.md +pinned_version="$(awk ' + /^ cli-version:/ { in_cli_version = 1 } + in_cli_version && /^ default:/ { gsub(/"/, "", $2); print $2; exit } +' "$spec")" +[[ -n "$pinned_version" ]] || { echo "no cli-version default in $spec" >&2; exit 1; } +if [[ "${cli_version%%.*}" != "${pinned_version%%.*}" ]]; then + echo "$spec pins Cloudsmith CLI $pinned_version; change the major version by hand" >&2 + exit 0 +fi +newest_version="$(printf '%s\n' "$pinned_version" "$cli_version" | sort -V | tail -n 1)" +if [[ "$pinned_version" == "$newest_version" ]]; then + echo "$spec already pins Cloudsmith CLI $pinned_version" >&2 + exit 0 +fi + +kit_version="$(sed -n 's/^version: "\([0-9]*\.[0-9]*\.[0-9]*\)"$/\1/p' "$spec")" +[[ -n "$kit_version" ]] || { echo "no kit version in $spec" >&2; exit 1; } +IFS=. read -r major minor patch <<< "$kit_version" +kit_version="$major.$minor.$(( patch + 1 ))" + +awk -v kit_version="$kit_version" -v cli_version="$cli_version" ' + /^version: / { $0 = "version: \"" kit_version "\"" } + /^ cli-version:/ { in_cli_version = 1 } + in_cli_version && /^ default:/ { sub(/".*"/, "\"" cli_version "\""); in_cli_version = 0 } + { print } +' "$spec" > "$spec.new" + +awk -v kit_version="$kit_version" -v cli_version="$cli_version" -v today="$(date -u +%Y-%m-%d)" ' + !inserted && /^## \[/ { + print "## [" kit_version "] - " today + print "" + print "### Changed" + print "" + print "- Pin the default `cli-version` to Cloudsmith CLI " cli_version "." + print "" + inserted = 1 + } + { print } + END { if (!inserted) exit 1 } +' "$changelog" > "$changelog.new" \ + || { rm -f "$spec.new" "$changelog.new"; echo "no release heading in $changelog" >&2; exit 1; } + +mv "$spec.new" "$spec" +mv "$changelog.new" "$changelog" +echo "$kit_version" diff --git a/tck/bump_cli_version_test.go b/tck/bump_cli_version_test.go new file mode 100644 index 0000000..eee0765 --- /dev/null +++ b/tck/bump_cli_version_test.go @@ -0,0 +1,68 @@ +package tck_test + +import ( + "bytes" + "context" + "os" + "os/exec" + "path/filepath" + "testing" + "time" + + "github.com/stretchr/testify/require" +) + +func TestBumpCLIVersion(t *testing.T) { + const spec = "version: \"0.1.0\"\nargs:\n cli-version:\n default: \"1.27.0\"\n" + const changelog = "# Changelog\n\n## [0.1.0] - 2026-09-11\n\n### Added\n\n- The first release.\n" + bumpedSpec := "version: \"0.1.1\"\nargs:\n cli-version:\n default: \"1.28.0\"\n" + bumpedChangelog := "# Changelog\n\n## [0.1.1] - " + time.Now().UTC().Format(time.DateOnly) + + "\n\n### Changed\n\n- Pin the default `cli-version` to Cloudsmith CLI 1.28.0.\n\n" + + "## [0.1.0] - 2026-09-11\n\n### Added\n\n- The first release.\n" + script, err := filepath.Abs("../scripts/bump-cli-version.sh") + require.NoError(t, err) + for _, tc := range []struct { + name string + version string + stdout string + spec string + changelog string + ok bool + }{ + {"newer", "1.28.0", "0.1.1\n", bumpedSpec, bumpedChangelog, true}, + {"older", "1.26.9", "", spec, changelog, true}, + {"new-major", "2.0.0", "", spec, changelog, true}, + {"not-a-release", "latest", "", spec, changelog, false}, + } { + t.Run(tc.name, func(t *testing.T) { + dir := t.TempDir() + kit := filepath.Join(dir, "cloudsmith-cli") + require.NoError(t, os.Mkdir(kit, 0o755)) + require.NoError(t, os.WriteFile(filepath.Join(kit, "spec.yaml"), []byte(spec), 0o644)) + require.NoError(t, os.WriteFile(filepath.Join(kit, "CHANGELOG.md"), []byte(changelog), 0o644)) + ctx, cancel := context.WithTimeout(t.Context(), 10*time.Second) + defer cancel() + var stdout, stderr bytes.Buffer + cmd := exec.CommandContext(ctx, "bash", script, tc.version) + cmd.Dir = dir + cmd.Stdout = &stdout + cmd.Stderr = &stderr + err := cmd.Run() + if tc.ok { + require.NoError(t, err, "%s", stderr.String()) + } else { + require.Error(t, err) + } + require.Equal(t, tc.stdout, stdout.String()) + if tc.stdout == "" { + require.NotEmpty(t, stderr.String()) + } + gotSpec, err := os.ReadFile(filepath.Join(kit, "spec.yaml")) + require.NoError(t, err) + require.Equal(t, tc.spec, string(gotSpec)) + gotChangelog, err := os.ReadFile(filepath.Join(kit, "CHANGELOG.md")) + require.NoError(t, err) + require.Equal(t, tc.changelog, string(gotChangelog)) + }) + } +} diff --git a/tck/publishing_test.go b/tck/publishing_test.go index 0002367..dc58953 100644 --- a/tck/publishing_test.go +++ b/tck/publishing_test.go @@ -46,17 +46,22 @@ func TestPublishingRegistryLookup(t *testing.T) { {"publish-dockerhub.yml", "docker.io/example/cloudsmith-repo-kit:v0.1.0"}, } { t.Run(publisher.workflow, func(t *testing.T) { - for _, trigger := range []string{"refs/heads/main", "refs/tags/cloudsmith-repo-v0.1.0"} { - t.Run(trigger, func(t *testing.T) { - workflowRef := "example/kits/.github/workflows/" + publisher.workflow + "@" + trigger - testPublishingRegistryLookup(t, publishingStep(t, publisher.workflow, "Push the kit artifact"), publisher.ref, workflowRef) + for _, trigger := range []struct{ caller, ref string }{ + {publisher.workflow, "refs/heads/main"}, + {publisher.workflow, "refs/tags/cloudsmith-repo-v0.1.0"}, + {"release.yml", "refs/heads/main"}, + } { + t.Run(trigger.caller+"@"+trigger.ref, func(t *testing.T) { + workflowRef := "example/kits/.github/workflows/" + trigger.caller + "@" + trigger.ref + identity := "https://github.com/example/kits/.github/workflows/" + publisher.workflow + "@" + trigger.ref + testPublishingRegistryLookup(t, publishingStep(t, publisher.workflow, "Push the kit artifact"), publisher.ref, workflowRef, trigger.ref, identity) }) } }) } } -func testPublishingRegistryLookup(t *testing.T, script, ref, workflowRef string) { +func testPublishingRegistryLookup(t *testing.T, script, ref, workflowRef, gitRef, identity string) { t.Helper() const digest = "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" missing := `Error response from registry: failed to find "` + ref + `": ` + ref + `: not found` @@ -78,7 +83,7 @@ func testPublishingRegistryLookup(t *testing.T, script, ref, workflowRef string) {name: "unrelated-not-found", message: "credential helper: executable not found", status: "1"}, {name: "signing-failure", message: missing, status: "1", push: true, signFail: true}, {name: "verification-failure", message: missing, status: "1", push: true, verifyFail: true}, - {name: "authorized-replacement", status: "0", push: strings.Contains(workflowRef, "/publish.yml@"), replace: true}, + {name: "authorized-replacement", status: "0", push: strings.Contains(identity, "/publish.yml@"), replace: true}, {name: "replacement-auth-failure", message: "401 Unauthorized", status: "1", replace: true}, } { t.Run(tc.name, func(t *testing.T) { @@ -107,7 +112,7 @@ case "$2" in ;; verify) [ "$#" = 7 ] && [ "$3" = --certificate-identity ] && - [ "$4" = "https://github.com/$GITHUB_WORKFLOW_REF" ] && + [ "$4" = "$EXPECTED_IDENTITY" ] && [ "$5" = --certificate-oidc-issuer ] && [ "$6" = https://token.actions.githubusercontent.com ] && [ "$7" = "$EXPECTED_DIGEST_REF" ] || exit 1 @@ -141,6 +146,7 @@ printf 'sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\ "DOCKERHUB_PUBLISH_NAMESPACE=example", "EXPECTED_REF="+ref, "KIT_DIR=cloudsmith-repo", "KIT_VERSION=0.1.0", "GITHUB_STEP_SUMMARY="+summary, "GITHUB_WORKFLOW_REF="+workflowRef, + "REPOSITORY=example/kits", "GITHUB_REF="+gitRef, "EXPECTED_IDENTITY="+identity, "EXPECTED_DIGEST_REF="+digestRef, "VERIFIED="+verified, "SIGN_FAIL="+strconv.FormatBool(tc.signFail), "VERIFY_FAIL="+strconv.FormatBool(tc.verifyFail), "REPLACE_EXISTING="+strconv.FormatBool(tc.replace),