Skip to content
Draft
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
39 changes: 39 additions & 0 deletions .github/workflows/bump-cli-version.yml
Original file line number Diff line number Diff line change
@@ -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 }}
14 changes: 13 additions & 1 deletion .github/workflows/publish-dockerhub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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"
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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"
139 changes: 139 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 }}
42 changes: 41 additions & 1 deletion .github/workflows/sign.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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 }}
Expand Down Expand Up @@ -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" \
Expand All @@ -128,6 +146,28 @@ jobs:

Squash-merge, then tag the resulting commit \`<kit>-v<semver>\`. 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"
Comment thread
cloudsmith-iduffy marked this conversation as resolved.
Resolved

- name: Upload signed release bundle
if: inputs.amend_release
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
Expand Down
11 changes: 9 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <version>`. 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
Expand Down
15 changes: 15 additions & 0 deletions cloudsmith-cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
12 changes: 8 additions & 4 deletions cloudsmith-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions cloudsmith-cli/spec.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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]+)$'

Expand Down
Loading
Loading