ci: publish npm package to GitGudLab registry on release using CI_JOB_TOKEN

8eba2f3aa443873611e5223ce69eddd637ee5144

permissionBRICK <40219477+permissionBRICK@users.noreply.github.com>

1 files changed, +32 -0Ignore whitespace
.gitlab-ci.yml+32 -0
@@ -1,5 +1,6 @@
1stages:1stages:
2 - build2 - build
3 - publish
34
4build-image:5build-image:
5 stage: build6 stage: build
@@ -23,3 +24,34 @@ build-image:
23 - docker build --cache-from "$CI_REGISTRY_IMAGE:latest" -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA" -t "$CI_REGISTRY_IMAGE:latest" .24 - docker build --cache-from "$CI_REGISTRY_IMAGE:latest" -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA" -t "$CI_REGISTRY_IMAGE:latest" .
24 - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA"25 - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA"
25 - docker push "$CI_REGISTRY_IMAGE:latest"26 - docker push "$CI_REGISTRY_IMAGE:latest"
27
28# Publishes the sillytavern npm package to this project's GitGudLab npm
29# registry on pushes to release, but only when package.json's version isn't
30# published yet. Authenticates with CI_JOB_TOKEN (accepted by the package
31# registry since gitgudlab 218062e — own project only, pusher needs Push);
32# an NPM_TOKEN project CI variable overrides it. allow_failure until the
33# patched gitgudlab server is deployed — flip to false after the next
34# forge deploy.
35publish-npm:
36 stage: publish
37 allow_failure: true
38 only:
39 - release
40 image: node:24
41 variables:
42 npm_config_cache: .npm
43 ST_NPM_REGISTRY: git.nas.home.htl-sky.net/api/v1/projects/permissionBRICK/SillyTavern/packages/npm/
44 cache:
45 key: npm
46 paths:
47 - .npm
48 script:
49 - echo "//${ST_NPM_REGISTRY}:_authToken=${NPM_TOKEN:-$CI_JOB_TOKEN}" > .npmrc
50 - npm ci --omit=dev --ignore-scripts
51 - VERSION=$(node -p "require('./package.json').version")
52 - |
53 if npm view "sillytavern@${VERSION}" version --registry "https://${ST_NPM_REGISTRY}" >/dev/null 2>&1; then
54 echo "Version ${VERSION} is already published; nothing to do."
55 exit 0
56 fi
57 - npm publish --registry "https://${ST_NPM_REGISTRY}"