From 9398a5a2dfc04775b4d238039b451dfc510378c3 Mon Sep 17 00:00:00 2001 From: Diego Resendez Date: Sun, 2 Aug 2026 22:42:39 -0500 Subject: [PATCH] fix(ci): keep Verdaccio staging mutable Replace an existing prerelease before publishing the refreshed candidate. Verdaccio remains mutable for validation while npmjs release versions stay immutable. Signed-off-by: Diego Resendez --- .github/workflows/stage.yml | 16 +++------------- scripts/staging-integrity.ts | 13 ------------- test/staging-integrity.test.ts | 19 ------------------- test/staging-workflow.test.ts | 6 +++--- 4 files changed, 6 insertions(+), 48 deletions(-) delete mode 100644 scripts/staging-integrity.ts delete mode 100644 test/staging-integrity.test.ts diff --git a/.github/workflows/stage.yml b/.github/workflows/stage.yml index 792f854..993ed1c 100644 --- a/.github/workflows/stage.yml +++ b/.github/workflows/stage.yml @@ -2,8 +2,8 @@ name: Stage → Verdaccio # Staging publish. Runs on GITEA ONLY (the `if` guards against GitHub) for release # branches. Publishes prereleases to the internal Verdaccio under the `stg` dist-tag. -# Existing versions are skipped only when the packed contents are identical; changed -# contents under an existing version fail and require a prerelease bump. +# Staging versions are intentionally mutable: an existing prerelease is removed before +# publishing the updated release candidate under the same version. on: push: branches: ['release/**'] @@ -31,15 +31,5 @@ jobs: *-*) ;; *) echo "Refusing to stage non-prerelease version: $VER" >&2; exit 1 ;; esac - - PACK_JSON=$(npm pack --json --dry-run --ignore-scripts) - LOCAL_INTEGRITY=$(node -e "let s='';process.stdin.on('data',d=>s+=d);process.stdin.on('end',()=>console.log(JSON.parse(s)[0].integrity))" <<< "$PACK_JSON") - EXISTING_INTEGRITY=$(npm view "@green-tea/core@$VER" dist.integrity --registry https://npm.svc.zoit.services 2>/dev/null || true) - ACTION=$(npx tsx scripts/staging-integrity.ts "$LOCAL_INTEGRITY" ${EXISTING_INTEGRITY:+"$EXISTING_INTEGRITY"}) - - if [ "$ACTION" = "skip" ]; then - echo "@green-tea/core@$VER is already staged with identical contents" - exit 0 - fi - + npm unpublish "@green-tea/core@$VER" --registry https://npm.svc.zoit.services --force 2>/dev/null || true npm publish --ignore-scripts --registry https://npm.svc.zoit.services --tag stg diff --git a/scripts/staging-integrity.ts b/scripts/staging-integrity.ts deleted file mode 100644 index e24199d..0000000 --- a/scripts/staging-integrity.ts +++ /dev/null @@ -1,13 +0,0 @@ -export type StagingAction = 'publish' | 'skip'; - -export function decideStagingPublish(localIntegrity: string, existingIntegrity?: string): StagingAction { - if (existingIntegrity === undefined) return 'publish'; - if (existingIntegrity === localIntegrity) return 'skip'; - - throw new Error('Version already exists in Verdaccio with different contents'); -} - -if (require.main === module) { - const [, , localIntegrity, existingIntegrity] = process.argv; - console.log(decideStagingPublish(localIntegrity, existingIntegrity)); -} diff --git a/test/staging-integrity.test.ts b/test/staging-integrity.test.ts deleted file mode 100644 index ea71f4c..0000000 --- a/test/staging-integrity.test.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { describe, expect, it } from 'vitest'; - -import { decideStagingPublish } from '../scripts/staging-integrity'; - -describe('decideStagingPublish', () => { - it('publishes a version that is not in Verdaccio', () => { - expect(decideStagingPublish('sha512-local')).toBe('publish'); - }); - - it('skips an existing version with identical package contents', () => { - expect(decideStagingPublish('sha512-local', 'sha512-local')).toBe('skip'); - }); - - it('rejects an existing version with different package contents', () => { - expect(() => decideStagingPublish('sha512-local', 'sha512-other')).toThrow( - 'Version already exists in Verdaccio with different contents', - ); - }); -}); diff --git a/test/staging-workflow.test.ts b/test/staging-workflow.test.ts index 3d2e4f4..e216dc6 100644 --- a/test/staging-workflow.test.ts +++ b/test/staging-workflow.test.ts @@ -6,12 +6,12 @@ import { describe, expect, it } from 'vitest'; const workflow = readFileSync(resolve(process.cwd(), '.github/workflows/stage.yml'), 'utf8'); describe('Verdaccio staging workflow', () => { - it('publishes immutable prereleases only from release branches', () => { + it('replaces mutable prereleases only from release branches', () => { expect(workflow).toContain("branches: ['release/**']"); expect(workflow).toContain('npm audit'); expect(workflow).toContain('npm run prepublishOnly'); - expect(workflow).toContain('scripts/staging-integrity.ts'); + expect(workflow).toContain('npm unpublish'); expect(workflow).toContain('npm publish --ignore-scripts'); - expect(workflow).not.toContain('npm unpublish'); + expect(workflow).not.toContain('scripts/staging-integrity.ts'); }); });