| 23 | 24 | - docker build --cache-from "$CI_REGISTRY_IMAGE:latest" -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA" -t "$CI_REGISTRY_IMAGE:latest" . |
| 24 | 25 | - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA" |
| 25 | 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. |
| 35 | +publish-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}" |