From 6543b954efc29290df827b4652b93e31aecd03b0 Mon Sep 17 00:00:00 2001 From: Paul Hitt Date: Mon, 28 Sep 2026 15:07:02 -0400 Subject: [PATCH] Publish to the GitLab package registry on version tags Co-Authored-By: Claude Opus 5.5 --- .gitlab-ci.yml | 17 ++++++++++++++++- package.json | 5 ++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e5a37d2..0b43836 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,21 @@ -stages: [test] +stages: [test, publish] test: stage: test image: node:22-alpine script: [npm ci, npm run build, npm test] + +# Publishes to this project's package registry on a version tag (v1.2.3). +# CI_JOB_TOKEN has write access to the project's own registry, so no stored +# secret is needed. +publish: + stage: publish + image: node:22-alpine + rules: + - if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/ + script: + - npm ci + - npm run build + - echo "@extant2000:registry=${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/npm/" > .npmrc + - echo "${CI_API_V4_URL#https:}/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=${CI_JOB_TOKEN}" >> .npmrc + - npm publish diff --git a/package.json b/package.json index f8c6d22..3d1e7d1 100644 --- a/package.json +++ b/package.json @@ -39,5 +39,8 @@ "typescript": "^5.6.0", "vitest": "^2.1.0" }, - "module": "./dist/index.js" + "module": "./dist/index.js", + "publishConfig": { + "@extant2000:registry": "https://gitlab.com/api/v4/projects/87000311/packages/npm/" + } }