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
9 changes: 6 additions & 3 deletions .github/workflows/commitlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ jobs:
permissions:
contents: read
pull-requests: read
runs-on: ubuntu-latest
strategy:
matrix:
runner: [ubuntu-latest, ubuntu-24.04-arm]
runs-on: ${{ matrix.runner }}
timeout-minutes: 8
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
Expand All @@ -33,9 +36,9 @@ jobs:
path: |
~/.npm
**/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
key: ${{ runner.os }}-${{ runner.arch }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
${{ runner.os }}-${{ runner.arch }}-node-
- run: npm ci --ignore-scripts
- uses: ./
id: run_commitlint
Expand Down
174 changes: 138 additions & 36 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ concurrency:

env:
IMAGE: ghcr.io/${{ github.repository_owner }}/commitlint-github-action
PLATFORMS: linux/amd64 linux/arm64

jobs:
release-please:
Expand Down Expand Up @@ -44,13 +45,16 @@ jobs:
config-file: release-please-config.json
manifest-file: .release-please-manifest.json

pin-image:
pin-prepare:
needs: release-please
runs-on: ubuntu-latest
timeout-minutes: 15
timeout-minutes: 5
permissions:
contents: read
packages: write
outputs:
build: ${{ steps.check.outputs.build }}
branch: ${{ steps.pr.outputs.branch }}
sha: ${{ steps.check.outputs.sha }}
steps:
- id: create_token
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
Expand Down Expand Up @@ -125,30 +129,98 @@ jobs:
subject=$(git log -1 --format=%s)
if [[ "$subject" == "chore(release): pin image digest"* ]]; then
echo "branch already ends in a pin commit; nothing to do"
echo "skip=true" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "build=true" >> "$GITHUB_OUTPUT"
echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"

pin-build:
needs: pin-prepare
if: needs.pin-prepare.outputs.build == 'true'
strategy:
matrix:
include:
- arch: amd64
runner: ubuntu-latest
- arch: arm64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.runner }}
timeout-minutes: 10
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ needs.pin-prepare.outputs.sha }}
persist-credentials: false

- name: Build and push the ${{ matrix.arch }} image
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ACTOR: ${{ github.actor }}
SHA: ${{ needs.pin-prepare.outputs.sha }}
ARCH: ${{ matrix.arch }}
run: |
set -euo pipefail
echo "$GH_TOKEN" | docker login ghcr.io -u "$ACTOR" --password-stdin
docker build --provenance=false --label "org.opencontainers.image.revision=$SHA" \
-t "$IMAGE:release-pr-$ARCH" .
docker push "$IMAGE:release-pr-$ARCH"

- if: steps.pr.outputs.skip != 'true' && steps.check.outputs.skip != 'true'
name: Build and push the image
pin-commit:
needs: [pin-prepare, pin-build]
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
packages: write
env:
SHA: ${{ needs.pin-prepare.outputs.sha }}
steps:
- name: Merge the per-arch images into one index
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ACTOR: ${{ github.actor }}
run: |
set -euo pipefail
echo "$GH_TOKEN" | docker login ghcr.io -u "$ACTOR" --password-stdin
docker build --label "org.opencontainers.image.revision=$(git rev-parse HEAD)" -t "$IMAGE:release-pr" .
docker push "$IMAGE:release-pr"
digest=$(docker image inspect --format '{{index .RepoDigests 0}}' "$IMAGE:release-pr" | cut -d@ -f2)
sources=()
for platform in $PLATFORMS; do
ref="$IMAGE:release-pr-${platform#linux/}"
revision=$(docker buildx imagetools inspect "$ref" --format '{{json .Image}}' \
| jq -r '.config.Labels["org.opencontainers.image.revision"]')
if [[ "$revision" != "$SHA" ]]; then
echo "::error::$ref was built from '$revision', not $SHA"
exit 1
fi
sources+=("$IMAGE@$(docker buildx imagetools inspect "$ref" --format '{{json .Manifest}}' | jq -r .digest)")
done
docker buildx imagetools create -t "$IMAGE:release-pr" "${sources[@]}"
digest=$(docker buildx imagetools inspect "$IMAGE:release-pr" --format '{{json .Manifest}}' | jq -r .digest)
echo "DIGEST=$digest" >> "$GITHUB_ENV"
echo "pushed $IMAGE@$digest"
echo "pushed $IMAGE@$digest from ${sources[*]}"

- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ needs.pin-prepare.outputs.sha }}
persist-credentials: false

- id: create_token
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
with:
client-id: ${{ secrets.SEMANTIC_RELEASE_APP_CLIENT_ID }}
private-key: ${{ secrets.SEMANTIC_RELEASE_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
repositories: ${{ github.event.repository.name }}
permission-contents: write

# API commits are signed by the App, as the required_signatures rule on main demands.
- if: steps.pr.outputs.skip != 'true' && steps.check.outputs.skip != 'true'
name: Commit the digest to action.yml
- name: Commit the digest to action.yml
env:
GH_TOKEN: ${{ steps.create_token.outputs.token }}
REPO: ${{ github.repository }}
BRANCH: ${{ steps.pr.outputs.branch }}
BRANCH: ${{ needs.pin-prepare.outputs.branch }}
run: |
set -euo pipefail
sed -E -i "s|^( image: docker://$IMAGE@)sha256:[0-9a-f]{64}\$|\1$DIGEST|" action.yml
Expand All @@ -169,37 +241,41 @@ jobs:
--arg query "$query" \
--arg repo "$REPO" \
--arg branch "$BRANCH" \
--arg sha "$(git rev-parse HEAD)" \
--arg sha "$SHA" \
--arg headline "chore(release): pin image digest ${DIGEST:7:12}" \
--arg content "$(base64 -w0 < action.yml)" \
'{query: $query, variables: {repo: $repo, branch: $branch, sha: $sha, headline: $headline, content: $content}}' \
> "$RUNNER_TEMP/graphql.json"
gh api graphql --input "$RUNNER_TEMP/graphql.json"

publish:
verify:
needs: release-please
if: needs.release-please.outputs.release_created == 'true'
runs-on: ubuntu-latest
strategy:
matrix:
runner: [ubuntu-latest, ubuntu-24.04-arm]
runs-on: ${{ matrix.runner }}
timeout-minutes: 10
permissions:
contents: read
packages: write
packages: read
env:
VERSION: ${{ needs.release-please.outputs.version }}
MAJOR: ${{ needs.release-please.outputs.major }}
SHA: ${{ needs.release-please.outputs.sha }}
outputs:
digest: ${{ steps.digest.outputs.digest }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ needs.release-please.outputs.sha }}
fetch-depth: 0
persist-credentials: false

- name: Read the digest the release pins
- id: digest
name: Read the digest the release pins
run: |
set -euo pipefail
if git diff --quiet HEAD^ HEAD -- action.yml; then
echo "::error::Release commit $SHA does not change action.yml, so it still pins the previous release's image. Nothing was tagged; release a patch once pin-image has committed to the release PR."
echo "::error::Release commit $SHA does not change action.yml, so it still pins the previous release's image. Nothing was tagged; release a patch once pin-commit has committed to the release PR."
exit 1
fi
image=$(yq '.runs.image' action.yml)
Expand All @@ -209,8 +285,9 @@ jobs:
exit 1
fi
echo "DIGEST=$digest" >> "$GITHUB_ENV"
echo "digest=$digest" >> "$GITHUB_OUTPUT"

- name: Check the pinned image was built from the released source
- name: Check this runner's image was built from the released source
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ACTOR: ${{ github.actor }}
Expand All @@ -220,35 +297,60 @@ jobs:
docker pull -q "$IMAGE@$DIGEST" > /dev/null
revision=$(docker image inspect --format '{{index .Config.Labels "org.opencontainers.image.revision"}}' "$IMAGE@$DIGEST")
if [[ ! "$revision" =~ ^[0-9a-f]{40}$ ]]; then
echo "::error::$IMAGE@$DIGEST has no org.opencontainers.image.revision label, so its source cannot be checked. Nothing was tagged."
echo "::error::$IMAGE@$DIGEST has no org.opencontainers.image.revision label for $(uname -m), so its source cannot be checked. Nothing was tagged."
exit 1
fi
git fetch -q origin "$revision"
if ! git diff --quiet "$revision" "$SHA" -- . ':(exclude)action.yml'; then
echo "::error::$IMAGE@$DIGEST was built from $revision, which differs from release commit $SHA outside action.yml:"
echo "::error::$IMAGE@$DIGEST ($(uname -m)) was built from $revision, which differs from release commit $SHA outside action.yml:"
git diff --stat "$revision" "$SHA" -- . ':(exclude)action.yml'
echo "::error::Nothing was tagged. Release a patch once pin-image has rebuilt the release PR."
echo "::error::Nothing was tagged. Release a patch once pin-commit has repinned the release PR."
exit 1
fi
echo "$IMAGE@$DIGEST was built from $revision, the released source"
echo "$IMAGE@$DIGEST ($(uname -m)) was built from $revision, the released source"

- name: Tag the pinned image
- name: Smoke test the pinned image
run: |
set -euo pipefail
docker buildx imagetools create -t "$IMAGE:$VERSION" -t "$IMAGE:$MAJOR" "$IMAGE@$DIGEST"
echo "pinned image runs node $(docker run --rm --entrypoint node "$IMAGE@$DIGEST" --version) on $(uname -m)"
docker run --rm --entrypoint node "$IMAGE@$DIGEST" \
-e 'console.log("commitlint " + require("/node_modules/@commitlint/lint/package.json").version)'

- name: Smoke test the published image
publish:
needs: [release-please, verify]
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
packages: write
env:
VERSION: ${{ needs.release-please.outputs.version }}
MAJOR: ${{ needs.release-please.outputs.major }}
SHA: ${{ needs.release-please.outputs.sha }}
DIGEST: ${{ needs.verify.outputs.digest }}
steps:
- name: Tag the pinned image
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ACTOR: ${{ github.actor }}
run: |
set -euo pipefail
docker pull "$IMAGE:$VERSION"
published=$(docker image inspect --format '{{index .RepoDigests 0}}' "$IMAGE:$VERSION" | cut -d@ -f2)
if [[ "$published" != "$DIGEST" ]]; then
echo "::error::$IMAGE:$VERSION is $published, but action.yml pins $DIGEST"
echo "$GH_TOKEN" | docker login ghcr.io -u "$ACTOR" --password-stdin
platforms=$(docker buildx imagetools inspect "$IMAGE@$DIGEST" --format '{{json .Manifest}}' \
| jq -r '[.manifests[].platform | "\(.os)/\(.architecture)"] | sort | join(" ")')
if [[ "$platforms" != "$PLATFORMS" ]]; then
echo "::error::$IMAGE@$DIGEST holds '$platforms', expected '$PLATFORMS'. Nothing was tagged."
exit 1
fi
echo "published image runs node $(docker run --rm --entrypoint node "$IMAGE:$VERSION" --version)"
docker run --rm --entrypoint node "$IMAGE:$VERSION" \
-e 'console.log("commitlint " + require("/node_modules/@commitlint/lint/package.json").version)'
docker buildx imagetools create -t "$IMAGE:$VERSION" -t "$IMAGE:$MAJOR" "$IMAGE@$DIGEST"
for tag in "$VERSION" "$MAJOR"; do
published=$(docker buildx imagetools inspect "$IMAGE:$tag" --format '{{json .Manifest}}' | jq -r .digest)
if [[ "$published" != "$DIGEST" ]]; then
echo "::error::$IMAGE:$tag is $published, but action.yml pins $DIGEST"
exit 1
fi
done
echo "tagged $IMAGE@$DIGEST ($platforms) as $VERSION and $MAJOR"

- id: create_token
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
Expand Down
16 changes: 16 additions & 0 deletions decisions/2026-11-11-release-please-pins-image-on-release-pr.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,20 @@ landing between a push to `main` and the rebuild it triggers.
- `build` commits are shown in the changelog here, unlike the other repos: for a Docker action the
runtime and its build are what users get.

## Amended 2026-11-11: the image is built for linux/amd64 and linux/arm64

Until v7.0.0 the image was amd64 only, as upstream's was, so the action failed on arm64 runners
with `no matching manifest for linux/arm64/v8`. `pin-image` is split into `pin-prepare`, a
`pin-build` matrix that builds each architecture natively (`ubuntu-latest`, `ubuntu-24.04-arm`) and
pushes it as `release-pr-<arch>`, and `pin-commit`, which checks both carry the expected revision
label, merges them into one index with `docker buildx imagetools create`, and pins the index digest.
Native runners were chosen over a single QEMU-emulated `buildx --platform` build, which runs
`npm ci` under emulation on every release-PR update. The images are built with
`--provenance=false` so the index holds only the two platform manifests.

Before tagging, a `verify` matrix pulls the pinned index on each architecture, checks that
architecture's revision label against the release commit, and smoke tests it natively. `publish`
then checks the index holds exactly both platforms, tags it, and confirms each tag resolves to the
pinned digest.

## Supersedes: none
Loading