diff --git a/docs/forgejo-actions-workflow-templates.md b/docs/forgejo-actions-workflow-templates.md index 79e6795..34c398b 100644 --- a/docs/forgejo-actions-workflow-templates.md +++ b/docs/forgejo-actions-workflow-templates.md @@ -31,6 +31,7 @@ Org secrets (set on `coulomb` org): `REGISTRY_USER`, `REGISTRY_TOKEN`. | `workflows/ci-smoke.yaml` | 1 | Git+CI routing drill; infra/docs repos | | `workflows/container-build-push.yaml` | 2 | Single-repo `Dockerfile` image publish | | `workflows/container-build-push-multirepo.yaml` | 3 prep | Docker build with named contexts (e.g. `state-hub` + `hub-core`) | +| `workflows/npm-publish.yaml` | 2+ | Publish `@coulomb/*` npm package on version tag | ## Adoption diff --git a/workflows/npm-publish.yaml b/workflows/npm-publish.yaml new file mode 100644 index 0000000..22ca4a3 --- /dev/null +++ b/workflows/npm-publish.yaml @@ -0,0 +1,33 @@ +# Publish npm package to Forgejo org registry (@coulomb scope). +# Copy to REPO/.forgejo/workflows/npm-publish.yaml and set secrets: +# FORGEJO_NPM_TOKEN — PAT with write:package (org coulomb) +name: npm-publish +on: + push: + tags: + - 'v*' +jobs: + publish: + runs-on: docker + steps: + - name: Checkout + run: | + git clone --depth 1 "${{ github.server_url }}/${{ github.repository }}.git" . + git checkout "${{ github.sha }}" + - name: Setup Node + run: | + command -v npm >/dev/null 2>&1 || { echo "npm not on runner image" >&2; exit 1; } + npm --version + - name: Install and test + run: | + if [ -f package-lock.json ]; then npm ci; else npm install; fi + npm test --if-present + - name: Publish to Forgejo npm + env: + FORGEJO_NPM_TOKEN: ${{ secrets.FORGEJO_NPM_TOKEN }} + run: | + REGISTRY="${{ github.server_url }}/api/packages/coulomb/npm/" + npm config set @coulomb:registry "${REGISTRY}" + HOST="${REGISTRY#https:}" + npm config set -- "${HOST}:_authToken" "${FORGEJO_NPM_TOKEN}" + npm publish --scope=@coulomb --access public \ No newline at end of file