1- # Build the computerd image from the commit that passed CI on main. The
2- # mutable :main tag gives tests and examples that follow main a fresh binary
3- # without waiting for the changesets release flow.
1+ # Build computerd images from commits that passed CI. The mutable :main tag
2+ # follows main, while :next follows the changesets Version Packages branch.
43
5- name : Main computerd image
4+ name : Computerd branch image
65
76on :
87 workflow_run :
98 workflows : ["CI"]
10- branches : [main]
9+ branches : [main, release ]
1110 types : [completed]
1211 workflow_dispatch : {}
1312
1413concurrency :
15- group : ${{ github.workflow }}
16- # If main advances while an image is building, only the newest commit
17- # should be allowed to publish the mutable :main tag.
14+ # Keep the main and next publishers independent while allowing newer commits
15+ # on either branch to cancel stale image builds for the same tag.
16+ group : ${{ github.workflow }}-${{ github.event.workflow_run.head_branch || github.ref }}
1817 cancel-in-progress : true
1918
2019permissions :
@@ -30,11 +29,23 @@ jobs:
3029 (
3130 github.event_name == 'workflow_run' &&
3231 github.event.workflow_run.conclusion == 'success' &&
33- github.event.workflow_run.event == 'push' &&
34- github.event.workflow_run.head_branch == 'main' &&
32+ (
33+ github.event.workflow_run.event == 'push' ||
34+ github.event.workflow_run.event == 'workflow_dispatch'
35+ ) &&
36+ (
37+ github.event.workflow_run.head_branch == 'main' ||
38+ github.event.workflow_run.head_branch == 'release'
39+ ) &&
3540 github.event.workflow_run.head_repository.full_name == github.repository
3641 ) ||
37- (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main')
42+ (
43+ github.event_name == 'workflow_dispatch' &&
44+ (
45+ github.ref == 'refs/heads/main' ||
46+ github.ref == 'refs/heads/release'
47+ )
48+ )
3849 )
3950 }}
4051 runs-on : ubuntu-24.04
4758 ref : ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_sha || github.ref }}
4859 fetch-depth : 1
4960
61+ - name : Select the mutable image tag
62+ id : image
63+ env :
64+ SOURCE_BRANCH : ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_branch || github.ref_name }}
65+ run : |
66+ case "$SOURCE_BRANCH" in
67+ main)
68+ tag=main
69+ ;;
70+ release)
71+ tag=next
72+ ;;
73+ *)
74+ echo "Unsupported source branch: $SOURCE_BRANCH" >&2
75+ exit 1
76+ ;;
77+ esac
78+ echo "branch=$SOURCE_BRANCH" >> "$GITHUB_OUTPUT"
79+ echo "tag=$tag" >> "$GITHUB_OUTPUT"
80+
5081 - uses : ./.github/actions/install
5182
5283 - name : Install system dependencies
@@ -86,26 +117,30 @@ jobs:
86117 username : ${{ github.actor }}
87118 password : ${{ secrets.GITHUB_TOKEN }}
88119
89- # A slower CI run for an older main commit can finish after a newer
90- # one. Do not let that run replace the newer image.
91- - name : Verify main has not advanced
92- id : main-sha
120+ # A slower CI run for an older commit can finish after a newer one. Do
121+ # not let that run replace the newer branch image.
122+ - name : Verify the source branch has not advanced
123+ id : branch-sha
124+ env :
125+ SOURCE_BRANCH : ${{ steps.image.outputs.branch }}
93126 run : |
94- git fetch --no-tags --depth=1 origin main
95- if [[ "$(git rev-parse HEAD)" != "$(git rev-parse origin/main )" ]]; then
96- echo "main advanced while this image was building; skipping the push"
127+ git fetch --no-tags --depth=1 origin "$SOURCE_BRANCH"
128+ if [[ "$(git rev-parse HEAD)" != "$(git rev-parse FETCH_HEAD )" ]]; then
129+ echo "$SOURCE_BRANCH advanced while this image was building; skipping the push"
97130 echo "current=false" >> "$GITHUB_OUTPUT"
98131 else
99132 echo "current=true" >> "$GITHUB_OUTPUT"
100133 fi
101134
102- - name : Build and push the main image
103- if : steps.main-sha.outputs.current == 'true'
135+ - name : Build and push the branch image
136+ if : steps.branch-sha.outputs.current == 'true'
137+ env :
138+ IMAGE_TAG : ${{ steps.image.outputs.tag }}
104139 run : |
105140 docker buildx build \
106141 --platform linux/amd64 \
107142 --push \
108143 --provenance=false \
109- --tag ghcr.io/cloudflare/computer-computerd-linux-x64:main \
144+ --tag " ghcr.io/cloudflare/computer-computerd-linux-x64:$IMAGE_TAG" \
110145 --file packages/computer-computerd-linux-x64/Dockerfile \
111146 packages/computer-computerd-linux-x64
0 commit comments