Skip to content

Commit f19c2bc

Browse files
committed
ci: pick npm dist-tag and image :latest from the release tag
The release workflow used to hardcode --tag alpha when publishing @cloudflare/workspace, which would have silently mis-tagged a stable release as a prerelease (and conversely kept the latest dist-tag pointing at whatever was last published manually). Compute the dist-tag from the version itself: a version with a prerelease suffix (-alpha.N, -beta.N, -rc.N) publishes under the matching channel (alpha, beta, rc) and leaves the npm latest pointer alone; a stable version (no suffix) publishes under latest. The same is_stable flag gates the wsd image's :latest registry tag so a prerelease push can't displace the last stable image either. Reword the header comment to match.
1 parent 8188fca commit f19c2bc

1 file changed

Lines changed: 37 additions & 14 deletions

File tree

.github/workflows/release.yml

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
# Tag-triggered release. Push a `v0.1.0-alpha.N` tag and CI:
1+
# Tag-triggered release. Push a `v<semver>` tag and CI:
22
#
33
# 1. Builds every workspace.
44
# 2. Runs all package tests.
55
# 3. Builds the wsd linux-x64 SEA binary (build-only — proves the
66
# release tag still produces a working binary; not published).
77
# 4. Stamps the tag's version into the publishable package.
8-
# 5. Publishes @cloudflare/workspace with --tag alpha (so plain
9-
# `npm i @cloudflare/workspace` doesn't pick up alphas).
8+
# 5. Publishes @cloudflare/workspace under a dist-tag picked from
9+
# the version: prerelease tags (`-alpha.N`, `-beta.N`, `-rc.N`)
10+
# publish under the matching suffix (`alpha`, `beta`, `rc`)
11+
# so plain `npm i @cloudflare/workspace` doesn't pick them up;
12+
# stable tags (no suffix) publish under `latest`.
13+
# 6. Pushes the wsd binary image to registry.cloudflare.com.
14+
# Stable releases also move the `:latest` registry tag;
15+
# prereleases only push the version-specific tag.
1016
#
1117
# The wsd binary is shipped two ways:
1218
# - inside the @cloudflare/workspace npm tarball at dist/bin/
@@ -119,8 +125,30 @@ jobs:
119125
- name: Sync versions
120126
run: node scripts/set-versions.mjs "${RELEASE_TAG}"
121127

128+
# Pick the npm dist-tag and decide whether this release moves
129+
# the `:latest` pointers. A stable semver (no `-` suffix)
130+
# publishes under `latest` and bumps the image's :latest tag;
131+
# a prerelease publishes under its prerelease channel
132+
# (`alpha`, `beta`, `rc`) and leaves :latest alone so a stale
133+
# alpha can't displace a real release.
134+
- name: Compute release metadata
135+
id: release-meta
136+
run: |
137+
version="${RELEASE_TAG#v}"
138+
if [[ "$version" == *-* ]]; then
139+
suffix="${version#*-}"
140+
npm_tag="${suffix%%.*}"
141+
is_stable=false
142+
else
143+
npm_tag=latest
144+
is_stable=true
145+
fi
146+
echo "version=${version}" >> "$GITHUB_OUTPUT"
147+
echo "npm_tag=${npm_tag}" >> "$GITHUB_OUTPUT"
148+
echo "is_stable=${is_stable}" >> "$GITHUB_OUTPUT"
149+
122150
- name: Publish @cloudflare/workspace
123-
run: npm publish --workspace @cloudflare/workspace --tag alpha --provenance --access public
151+
run: npm publish --workspace @cloudflare/workspace --tag "${{ steps.release-meta.outputs.npm_tag }}" --provenance --access public
124152

125153
# Stage the SEA binary into the wsd-linux-x64 package's bin/
126154
# directory — that package's Dockerfile copies from `bin/wsd`
@@ -148,14 +176,9 @@ jobs:
148176
echo "$CF_REGISTRY_PASSWORD" | docker login registry.cloudflare.com \
149177
-u "$CF_REGISTRY_USERNAME" --password-stdin
150178
151-
# Strip the leading `v` from the release tag so the image
152-
# tag matches the npm version (e.g. v0.1.0-alpha.1 -> 0.1.0-alpha.1).
153-
- name: Compute image version
154-
id: image-version
155-
run: |
156-
version="${RELEASE_TAG#v}"
157-
echo "version=${version}" >> "$GITHUB_OUTPUT"
158-
179+
# The version-specific tag always goes out. The `:latest` tag
180+
# only moves on stable releases; an empty trailing line in the
181+
# `tags` list is tolerated by build-push-action.
159182
- name: Build and push wsd-linux-x64 image
160183
uses: docker/build-push-action@v6
161184
with:
@@ -164,6 +187,6 @@ jobs:
164187
platforms: linux/amd64
165188
push: true
166189
tags: |
167-
registry.cloudflare.com/library/workspace-wsd-linux-x64:${{ steps.image-version.outputs.version }}
168-
registry.cloudflare.com/library/workspace-wsd-linux-x64:latest
190+
registry.cloudflare.com/library/workspace-wsd-linux-x64:${{ steps.release-meta.outputs.version }}
191+
${{ steps.release-meta.outputs.is_stable == 'true' && 'registry.cloudflare.com/library/workspace-wsd-linux-x64:latest' || '' }}
169192
provenance: false

0 commit comments

Comments
 (0)