From ce0af3fd0904bd723ee246b7cf863c966c5b132d Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 3 Dec 2026 16:47:39 +0000 Subject: [PATCH] Release-workflow: npm-publicatie ook inhalen als de GitHub-release al bestaat --- .github/workflows/release.yml | 7 ++++++- tests/cli/npm-pakket.test.ts | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b4a5d1e..dde0d0e 100755 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -84,8 +84,9 @@ jobs: # npm: de eerste keer met het geheim NPM_TOKEN, daarna via trusted publishing # (npmjs.com → pakket projectx-ui → Settings → Trusted Publisher: GitHub Actions, # DafkeDD / ProjectX-UI / release.yml). Dan mag NPM_TOKEN weg. Zie README. + # Draait ook als de GitHub-release al bestaat: mislukte npm-publicatie wordt zo bij + # de volgende push naar main (of via "Run workflow") alsnog ingehaald. - name: CLI op npm publiceren - if: steps.version.outputs.exists == 'false' env: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} TAG_VERSION: ${{ steps.version.outputs.tag }} @@ -97,6 +98,10 @@ jobs: exit 0 fi # Trusted publishing heeft npm 11.5.1 of nieuwer nodig. + if [ ! -f "$PAKKET" ]; then + rm -rf packages/cli/registry && cp -r registry packages/cli/registry + (cd packages/cli && npm pack --pack-destination ../..) + fi npm install -g npm@11 --no-fund --no-audit if [ -n "$NPM_TOKEN" ]; then echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > "$HOME/.npmrc" diff --git a/tests/cli/npm-pakket.test.ts b/tests/cli/npm-pakket.test.ts index b05c003..fa6d6bb 100644 --- a/tests/cli/npm-pakket.test.ts +++ b/tests/cli/npm-pakket.test.ts @@ -73,4 +73,12 @@ describe("npm-pakket projectx-ui", () => { expect(workflow).toContain('npm view "projectx-ui@$VERSION" version'); expect(workflow).toContain("NPM_TOKEN: ${{ secrets.NPM_TOKEN }}"); }); + + it("de npm-stap hangt niet af van een nieuwe tag, zodat een mislukte publicatie ingehaald wordt", () => { + const workflow = readFileSync(join(root, ".github/workflows/release.yml"), "utf8"); + const stap = workflow.slice(workflow.indexOf("- name: CLI op npm publiceren")); + expect(stap.split("run: |")[0]).not.toContain("if:"); + // Bestaat de release al, dan is er nog geen pakket: de stap maakt het zelf. + expect(stap).toContain("npm pack --pack-destination ../.."); + }); });