From ccb6e6ff06f2e63b321510b9f43e72b814f4baee Mon Sep 17 00:00:00 2001 From: Lembot Date: Fri, 12 Dec 2025 03:35:05 -0500 Subject: [PATCH] fix(ci): make publish step more robust MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Check if version already exists in registry before publishing - Skip gracefully instead of failing when version is unchanged - Remove manual publish trigger for non-main branches Closes #3 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .gitlab-ci.yml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bfccbb9..4c54fc9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -47,13 +47,22 @@ publish: - echo "@peerverity:registry=${NPM_REGISTRY}" >> .npmrc - echo "//${CI_SERVER_HOST}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=${CI_JOB_TOKEN}" >> .npmrc script: - - npm publish + - | + PACKAGE_NAME=$(node -p "require('./package.json').name") + PACKAGE_VERSION=$(node -p "require('./package.json').version") + echo "Checking if ${PACKAGE_NAME}@${PACKAGE_VERSION} already exists..." + + # Check if version exists in registry (npm view exits 0 if found) + if npm view "${PACKAGE_NAME}@${PACKAGE_VERSION}" version 2>/dev/null; then + echo "Version ${PACKAGE_VERSION} already published, skipping." + else + echo "Publishing ${PACKAGE_NAME}@${PACKAGE_VERSION}..." + npm publish + fi rules: - # Automatically publish on main branch + # Only publish on main branch - if: '$CI_COMMIT_REF_NAME == "main"' when: on_success - # Allow manual publish on other branches - - when: manual tags: - public-runner-docker -- GitLab