11name : Docker Release
22
33on :
4- push :
5- tags :
6- - " v*"
7- - " !v*-alpha.*"
8- paths-ignore :
9- - " docs/**"
10- - " **/*.md"
11- - " **/*.mdx"
12- - " .agents/**"
13- - " skills/**"
14- workflow_dispatch :
4+ workflow_call :
155 inputs :
166 tag :
17- description : Existing stable, extended-stable, or beta release tag
7+ description : Immutable stable, extended-stable, or beta release tag
188 required : true
199 type : string
10+ release_sha :
11+ description : Full immutable commit SHA resolved from tag
12+ required : true
13+ type : string
14+ secrets :
15+ DOCKERHUB_USERNAME :
16+ required : true
17+ DOCKERHUB_TOKEN :
18+ required : true
2019
2120concurrency :
22- group : ${{ github.event_name == 'workflow_dispatch' && format('docker-release-manual-{0}', inputs.tag) || 'docker-release-publish' }}
21+ # Alias promotion checks are read-then-write; serialize every Docker publish
22+ # so an older stable run cannot overwrite a newer latest/main promotion.
23+ group : docker-release-publish
2324 cancel-in-progress : false
2425 queue : max
2526
3132 DOCKERHUB_IMAGE_NAME : openclaw/openclaw
3233
3334jobs :
34- validate_manual_backfill :
35- if : github.event_name == 'workflow_dispatch'
35+ validate_release_identity :
3636 runs-on : ubuntu-24.04
3737 permissions :
3838 contents : read
3939 steps :
40- - name : Validate tag input format
40+ - name : Validate immutable tag and SHA inputs
4141 env :
4242 RELEASE_TAG : ${{ inputs.tag }}
43+ RELEASE_SHA : ${{ inputs.release_sha }}
4344 run : |
4445 set -euo pipefail
4546 if [[ "${RELEASE_TAG}" == *"-alpha."* ]]; then
@@ -50,16 +51,38 @@ jobs:
5051 echo "Invalid release tag: ${RELEASE_TAG}"
5152 exit 1
5253 fi
54+ if [[ ! "${RELEASE_SHA}" =~ ^[a-f0-9]{40}$ ]]; then
55+ echo "Release SHA must be a full lowercase commit SHA."
56+ exit 1
57+ fi
5358
54- - name : Checkout selected tag
59+ - name : Checkout immutable release tag
5560 uses : actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
5661 with :
5762 ref : refs/tags/${{ inputs.tag }}
5863 fetch-depth : 0
64+ persist-credentials : false
65+
66+ - name : Verify tag, SHA, and package identity agree
67+ env :
68+ RELEASE_TAG : ${{ inputs.tag }}
69+ RELEASE_SHA : ${{ inputs.release_sha }}
70+ run : |
71+ set -euo pipefail
72+ tag_sha="$(git rev-parse "refs/tags/${RELEASE_TAG}^{commit}")"
73+ checkout_sha="$(git rev-parse HEAD)"
74+ package_version="$(node -p "require('./package.json').version")"
75+ if [[ "${tag_sha}" != "${RELEASE_SHA}" || "${checkout_sha}" != "${RELEASE_SHA}" ]]; then
76+ echo "Release tag ${RELEASE_TAG} must resolve to supplied SHA ${RELEASE_SHA}; got ${tag_sha}." >&2
77+ exit 1
78+ fi
79+ if [[ "v${package_version}" != "${RELEASE_TAG}" && ! "${RELEASE_TAG}" =~ ^v${package_version}-[1-9][0-9]*$ ]]; then
80+ echo "Release tag ${RELEASE_TAG} does not match package.json version ${package_version} or its correction-tag form." >&2
81+ exit 1
82+ fi
5983
6084 resolve_release_policy :
61- needs : validate_manual_backfill
62- if : ${{ always() && (github.event_name != 'workflow_dispatch' || needs.validate_manual_backfill.result == 'success') }}
85+ needs : validate_release_identity
6386 runs-on : ubuntu-24.04
6487 permissions :
6588 contents : read
78101 id : policy
79102 shell : bash
80103 env :
81- SOURCE_REF : ${{ github.event_name == 'workflow_dispatch' && format('refs/tags/{0}', inputs.tag) || github.ref }}
104+ SOURCE_REF : ${{ format('refs/tags/{0}', inputs.tag) }}
82105 run : |
83106 set -euo pipefail
84107 if [[ "${SOURCE_REF}" != refs/tags/v* ]]; then
@@ -98,20 +121,19 @@ jobs:
98121 echo "- Channel: ${channel}"
99122 } >> "$GITHUB_STEP_SUMMARY"
100123
101- approve_manual_backfill :
102- name : Approve Docker backfill ${{ inputs.tag }}
103- if : github.event_name == 'workflow_dispatch'
104- needs : [validate_manual_backfill, resolve_release_policy]
105- # WARNING: KEEP MANUAL BACKFILLS GATED BY THE docker-release ENVIRONMENT.
124+ approve_docker_publish :
125+ name : Approve Docker publication ${{ inputs.tag }}
126+ needs : [validate_release_identity, resolve_release_policy]
127+ # Docker publication remains protected even though only release orchestration can call it.
106128 runs-on : ubuntu-24.04
107129 environment : docker-release
108130 permissions : {}
109131 steps :
110- - name : Approve Docker backfill
132+ - name : Approve Docker publication
111133 env :
112134 RELEASE_TAG : ${{ inputs.tag }}
113135 run : |
114- echo "Approved immutable Docker image backfill for ${RELEASE_TAG}"
136+ echo "Approved immutable Docker image publication for ${RELEASE_TAG}"
115137
116138 validate_publish_config :
117139 runs-on : ubuntu-24.04
@@ -132,8 +154,8 @@ jobs:
132154 echo "Docker Hub publishing configured for ${DOCKERHUB_IMAGE}."
133155
134156 resolve_build_provenance :
135- needs : [approve_manual_backfill , resolve_release_policy, validate_publish_config]
136- if : ${{ always() && needs.resolve_release_policy .result == 'success' && needs.validate_publish_config .result == 'success' && (github.event_name != 'workflow_dispatch' || needs.approve_manual_backfill .result == 'success') }}
157+ needs : [approve_docker_publish , resolve_release_policy, validate_publish_config]
158+ if : ${{ always() && needs.approve_docker_publish .result == 'success' && needs.resolve_release_policy .result == 'success' && needs.validate_publish_config .result == 'success' }}
137159 runs-on : ubuntu-24.04
138160 permissions :
139161 contents : read
@@ -144,7 +166,7 @@ jobs:
144166 - name : Checkout selected source
145167 uses : actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
146168 with :
147- ref : ${{ github.event_name == 'workflow_dispatch' && format('refs/tags/{0}', inputs.tag) || github.sha }}
169+ ref : ${{ inputs.release_sha }}
148170 fetch-depth : 0
149171
150172 - name : Resolve shared build provenance
@@ -159,8 +181,8 @@ jobs:
159181 # DO NOT MOVE IT BACK TO BLACKSMITH WITHOUT RE-VALIDATING TAG BUILDS AND BACKFILLS.
160182 # Build amd64 image. Default and slim tags point to the same slim runtime.
161183 build-amd64 :
162- needs : [approve_manual_backfill , validate_publish_config, resolve_build_provenance]
163- if : ${{ always() && needs.validate_publish_config .result == 'success' && needs.resolve_build_provenance .result == 'success' && (github.event_name != 'workflow_dispatch' || needs.approve_manual_backfill .result == 'success') }}
184+ needs : [approve_docker_publish , validate_publish_config, resolve_build_provenance]
185+ if : ${{ always() && needs.approve_docker_publish .result == 'success' && needs.validate_publish_config .result == 'success' && needs.resolve_build_provenance .result == 'success' }}
164186 # WARNING: DO NOT REVERT THIS TO A BLACKSMITH RUNNER WITHOUT RE-VALIDATING TAG BACKFILLS.
165187 runs-on : ubuntu-24.04
166188 permissions :
@@ -219,7 +241,7 @@ jobs:
219241 env :
220242 GHCR_IMAGE : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
221243 DOCKERHUB_IMAGE : ${{ env.DOCKERHUB_REGISTRY }}/${{ env.DOCKERHUB_IMAGE_NAME }}
222- SOURCE_REF : ${{ github.event_name == 'workflow_dispatch' && format('refs/tags/{0}', inputs.tag) || github.ref }}
244+ SOURCE_REF : ${{ format('refs/tags/{0}', inputs.tag) }}
223245 run : |
224246 set -euo pipefail
225247 tags=()
@@ -259,7 +281,7 @@ jobs:
259281 env :
260282 BUILD_TIMESTAMP : ${{ needs.resolve_build_provenance.outputs.built_at }}
261283 SOURCE_SHA : ${{ needs.resolve_build_provenance.outputs.source_sha }}
262- SOURCE_REF : ${{ github.event_name == 'workflow_dispatch' && format('refs/tags/{0}', inputs.tag) || github.ref }}
284+ SOURCE_REF : ${{ format('refs/tags/{0}', inputs.tag) }}
263285 run : |
264286 set -euo pipefail
265287 source_sha="${SOURCE_SHA}"
@@ -386,8 +408,8 @@ jobs:
386408
387409 # Build arm64 image. Default and slim tags point to the same slim runtime.
388410 build-arm64 :
389- needs : [approve_manual_backfill , validate_publish_config, resolve_build_provenance]
390- if : ${{ always() && needs.validate_publish_config .result == 'success' && needs.resolve_build_provenance .result == 'success' && (github.event_name != 'workflow_dispatch' || needs.approve_manual_backfill .result == 'success') }}
411+ needs : [approve_docker_publish , validate_publish_config, resolve_build_provenance]
412+ if : ${{ always() && needs.approve_docker_publish .result == 'success' && needs.validate_publish_config .result == 'success' && needs.resolve_build_provenance .result == 'success' }}
391413 # WARNING: DO NOT REVERT THIS TO A BLACKSMITH RUNNER WITHOUT RE-VALIDATING TAG BACKFILLS.
392414 runs-on : ubuntu-24.04-arm
393415 permissions :
@@ -427,7 +449,7 @@ jobs:
427449 env :
428450 GHCR_IMAGE : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
429451 DOCKERHUB_IMAGE : ${{ env.DOCKERHUB_REGISTRY }}/${{ env.DOCKERHUB_IMAGE_NAME }}
430- SOURCE_REF : ${{ github.event_name == 'workflow_dispatch' && format('refs/tags/{0}', inputs.tag) || github.ref }}
452+ SOURCE_REF : ${{ format('refs/tags/{0}', inputs.tag) }}
431453 run : |
432454 set -euo pipefail
433455 tags=()
@@ -467,7 +489,7 @@ jobs:
467489 env :
468490 BUILD_TIMESTAMP : ${{ needs.resolve_build_provenance.outputs.built_at }}
469491 SOURCE_SHA : ${{ needs.resolve_build_provenance.outputs.source_sha }}
470- SOURCE_REF : ${{ github.event_name == 'workflow_dispatch' && format('refs/tags/{0}', inputs.tag) || github.ref }}
492+ SOURCE_REF : ${{ format('refs/tags/{0}', inputs.tag) }}
471493 run : |
472494 set -euo pipefail
473495 source_sha="${SOURCE_SHA}"
@@ -596,14 +618,14 @@ jobs:
596618 create-manifest :
597619 needs :
598620 [
599- approve_manual_backfill ,
621+ approve_docker_publish ,
600622 resolve_release_policy,
601623 validate_publish_config,
602624 resolve_build_provenance,
603625 build-amd64,
604626 build-arm64,
605627 ]
606- if : ${{ always() && needs.validate_publish_config .result == 'success' && needs.build-amd64 .result == 'success' && needs.build-arm64 .result == 'success' && (github.event_name != 'workflow_dispatch' || needs.approve_manual_backfill .result == 'success') }}
628+ if : ${{ always() && needs.approve_docker_publish .result == 'success' && needs.validate_publish_config .result == 'success' && needs.build-amd64 .result == 'success' && needs.build-arm64 .result == 'success' }}
607629 # WARNING: DO NOT REVERT THIS TO A BLACKSMITH RUNNER WITHOUT RE-VALIDATING TAG BACKFILLS.
608630 runs-on : ubuntu-24.04
609631 permissions :
@@ -636,7 +658,7 @@ jobs:
636658 env :
637659 GHCR_IMAGE : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
638660 DOCKERHUB_IMAGE : ${{ env.DOCKERHUB_REGISTRY }}/${{ env.DOCKERHUB_IMAGE_NAME }}
639- SOURCE_REF : ${{ github.event_name == 'workflow_dispatch' && format('refs/tags/{0}', inputs.tag) || github.ref }}
661+ SOURCE_REF : ${{ format('refs/tags/{0}', inputs.tag) }}
640662 run : |
641663 set -euo pipefail
642664 tags=()
@@ -683,7 +705,7 @@ jobs:
683705 shell : bash
684706 env :
685707 DOCKERHUB_IMAGE : ${{ env.DOCKERHUB_REGISTRY }}/${{ env.DOCKERHUB_IMAGE_NAME }}
686- SOURCE_REF : ${{ github.event_name == 'workflow_dispatch' && format('refs/tags/{0}', inputs.tag) || github.ref }}
708+ SOURCE_REF : ${{ format('refs/tags/{0}', inputs.tag) }}
687709 TAGS : ${{ steps.tags.outputs.value }}
688710 BROWSER_TAGS : ${{ steps.tags.outputs.browser }}
689711 DOCKERHUB_TAGS : ${{ steps.tags.outputs.dockerhub }}
@@ -765,7 +787,7 @@ jobs:
765787 env :
766788 GHCR_IMAGE : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
767789 DOCKERHUB_IMAGE : ${{ env.DOCKERHUB_REGISTRY }}/${{ env.DOCKERHUB_IMAGE_NAME }}
768- SOURCE_REF : ${{ github.event_name == 'workflow_dispatch' && format('refs/tags/{0}', inputs.tag) || github.ref }}
790+ SOURCE_REF : ${{ format('refs/tags/{0}', inputs.tag) }}
769791 run : |
770792 set -euo pipefail
771793 multi_refs=()
@@ -880,7 +902,7 @@ jobs:
880902 "${dockerhub_arm64_refs[@]}"
881903
882904 - name : Promote and verify channel aliases
883- if : ${{ github.event_name != 'workflow_dispatch' && needs.resolve_release_policy.outputs.channel != 'beta' }}
905+ if : ${{ needs.resolve_release_policy.outputs.channel != 'beta' }}
884906 env :
885907 VERSION : ${{ needs.resolve_release_policy.outputs.version }}
886908 GHCR_IMAGE : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
0 commit comments