Skip to content

Commit f9151ee

Browse files
authored
ci: harden alpha release publishing (#282)
## Summary - Block alpha train completion when Changesets only creates the Version Packages PR and npm did not publish. - Preserve GoReleaser recovery when the release tag already exists. - Treat npm CLI dist-tag promotion as best-effort so OIDC dist-tag auth failures do not block GitHub Release/GHCR recovery. ## Validation - `corepack pnpm nx test @zitadel/cli` - `corepack pnpm changeset status --output /tmp/nextgen-changeset-status.json && node scripts/check-alpha-release-plan.mjs /tmp/nextgen-changeset-status.json` - `corepack pnpm run check -- --only node` - `corepack pnpm --filter @zitadel/cli test -- --run tests/unit/scripts/check-alpha-release-plan.test.ts tests/unit/scripts/release-alpha-train.test.ts` ## Release notes / changeset - Empty changesets added for CI-only release workflow fixes. ## Notes - Existing remote artifacts for `v0.1.0-alpha.4` were not deleted or modified. - The npm packages for `0.1.0-alpha.4` published successfully in the observed run; the failure was the follow-up dist-tag mutation.
1 parent d841b61 commit f9151ee

4 files changed

Lines changed: 26 additions & 6 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -881,8 +881,8 @@ jobs:
881881
# so bare `npx @zitadel/cli` must reach the supported local workflow.
882882
# Keep `alpha` as the canonical prerelease tag, and do not move
883883
# `latest` for SDKs/components, Docker images, or GitHub Releases.
884-
npm dist-tag add "@zitadel/cli@$version" alpha
885-
npm dist-tag add "@zitadel/cli@$version" latest
884+
npm dist-tag add "@zitadel/cli@$version" alpha || echo "::warning::Unable to refresh @zitadel/cli@$version npm alpha dist-tag"
885+
npm dist-tag add "@zitadel/cli@$version" latest || echo "::warning::Unable to promote @zitadel/cli@$version to npm latest dist-tag"
886886
887887
- name: Restore changesets after publish decision
888888
run: git restore -- .changeset

apps/cli/tests/unit/scripts/check-alpha-release-plan.test.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ describe("check-alpha-release-plan script", () => {
189189
" - name: Promote CLI alpha to npm latest",
190190
" if: ${{ steps.changesets.outputs.published == 'true' }}",
191191
" run: |",
192-
" npm dist-tag add \"@zitadel/cli@$version\" alpha",
193-
" npm dist-tag add \"@zitadel/cli@$version\" latest",
192+
' npm dist-tag add "@zitadel/cli@$version" alpha || echo "::warning::Unable to refresh @zitadel/cli@$version npm alpha dist-tag"',
193+
' npm dist-tag add "@zitadel/cli@$version" latest || echo "::warning::Unable to promote @zitadel/cli@$version to npm latest dist-tag"',
194194
"",
195195
].join("\n"),
196196
"",
@@ -225,6 +225,19 @@ describe("check-alpha-release-plan script", () => {
225225
).rejects.toThrow("must keep the CLI alpha dist-tag on the published train");
226226
});
227227

228+
it("rejects a workflow that fails the train when npm latest promotion fails", async () => {
229+
const { cwd, statusPath } = await fixtureRepo({
230+
ciWorkflow: validCiWorkflow().replace(
231+
' npm dist-tag add "@zitadel/cli@$version" latest || echo "::warning::Unable to promote @zitadel/cli@$version to npm latest dist-tag"',
232+
' npm dist-tag add "@zitadel/cli@$version" latest',
233+
),
234+
});
235+
236+
await expect(
237+
checkAlphaReleasePlanModule.checkAlphaReleasePlan({ cwd, statusPath }),
238+
).rejects.toThrow("must not fail the alpha train when npm latest dist-tag promotion fails");
239+
});
240+
228241
it("rejects a workflow that moves the CLI latest tag outside the release job", async () => {
229242
const { cwd, statusPath } = await fixtureRepo({
230243
ciWorkflow: validCiWorkflow()
@@ -382,8 +395,8 @@ function validCiWorkflow(): string {
382395
" - name: Promote CLI alpha to npm latest",
383396
" if: ${{ steps.changesets.outputs.published == 'true' }}",
384397
" run: |",
385-
" npm dist-tag add \"@zitadel/cli@$version\" alpha",
386-
" npm dist-tag add \"@zitadel/cli@$version\" latest",
398+
' npm dist-tag add "@zitadel/cli@$version" alpha || echo "::warning::Unable to refresh @zitadel/cli@$version npm alpha dist-tag"',
399+
' npm dist-tag add "@zitadel/cli@$version" latest || echo "::warning::Unable to promote @zitadel/cli@$version to npm latest dist-tag"',
387400
"",
388401
" - name: Restore changesets after publish decision",
389402
" run: git restore -- .changeset",

scripts/check-alpha-release-plan.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,11 @@ function assertCliLatestPromotion(ciWorkflow) {
286286
throw new Error("only @zitadel/cli may move the npm latest dist-tag during alpha");
287287
}
288288
}
289+
assertContains(
290+
releaseJob,
291+
'npm dist-tag add "@zitadel/cli@$version" latest ||',
292+
"release-alpha-train must not fail the alpha train when npm latest dist-tag promotion fails",
293+
);
289294
}
290295

291296
function assertNoUnexpectedPublishOnlyGates(ciWorkflow) {

0 commit comments

Comments
 (0)