# Publishing npm releases from Gitea The [manual workflow](../.gitea/workflows/npm-publish.yml) publishes the exact reviewed npm tarball attached to a Gitea release. It does not rebuild the plugin, synchronise GitHub or run on pushes, tags or release creation. Its default input is **HOLD**, which verifies the package and previews publication without uploading anything. The workflow is restricted to `sysadmin/codeblock-studio-public`. Keeping the same file in the private development source does not enable private-repository publication. The 1.8.4 installer and package were built and tested before being preserved; the workflow pins that package's SHA-256 rather than packing a new archive during publication. ## One-time setup 1. Register a **repository-scoped runner** in the public-source repository's **Settings → Actions → Runners**. Use a dedicated runner on the Gitea server, with label `codeblock-studio:docker://node:24-bookworm`. Docker runs each job in a Node container. The runner uses its own Docker-in-Docker daemon; its outer container is privileged, so keep this runner limited to trusted repository workflows. The host Docker socket and user-note folders are not mounted. Give the runner only this repository; avoid running untrusted pull-request jobs on it. Keep registration credentials outside Git. 2. Confirm the runner is online and can reach the Gitea instance and `registry.npmjs.org`. Run the workflow with **HOLD** first. This requires no npm publishing secret. 3. When npm publication is ready, create a short-lived **granular npm token** limited to read/write access for `joplin-plugin-code-block-studio`, with no organisation or account administration permissions. Gitea is outside npm's documented trusted-publishing providers, so unattended token publication requires the token's **Bypass 2FA** permission. This lets the token publish without a separate 2FA prompt: the owner must explicitly approve that access before it is created. Retain normal account 2FA. 4. Store it as **NPM_TOKEN** in the public-source repository's **Settings → Actions → Secrets**. Enter it directly into Gitea through an encrypted connection; never paste it into chat, a source file or a command log. Rotate/revoke it when it expires or is no longer needed. The dedicated server runner is online. HOLD run #13 passed with upload skipped. The owner approved a package-only NPM_TOKEN credential, expiring 21 November 2026, and PUBLISH run #14 succeeded. npm published 1.8.4 and its latest tag, integrity and downloaded tarball have been verified against the reviewed original. Joplin catalogue ingestion is a separate, pending check. Do not rerun a successful upload while it is being processed. ## Publish a reviewed release 1. Complete the clean build, tests, package review and private-first/public-source release sequence in [PUBLISHING.md](PUBLISHING.md). 2. Attach the reviewed `.tgz` to the corresponding Gitea release alongside the installer, metadata, examples, source ZIP and checksums. Update the workflow's `RELEASE_TAG`, `PACKAGE_FILE` and `PACKAGE_SHA256` for each new release; commit and review those values before running it. The 1.8.4 values match the preserved 74-file npm package. 3. In **Actions → Publish reviewed npm package → Run workflow**, choose the reviewed **main** branch and leave **HOLD** for verification. The job checks the tarball hash, package name/version and npm's dry-run output. It does not install dependencies or execute package lifecycle scripts. 4. After the owner authorises the npm upload, run again with **PUBLISH**. Only that exact input enables the upload step; an absent `NPM_TOKEN` fails clearly. The secret is exposed only to that step and npm's temporary configuration is removed afterwards. 5. Check registry availability, integrity and downloaded bytes against the reviewed tarball. npm scanning can delay availability after a successful upload; do not repeatedly publish or change versions to bypass that delay. Check Joplin catalogue ingestion separately. GitHub synchronisation remains the owner's manual action. Git mirroring transfers source/tags; GitHub release descriptions and attached installers need their own publication step. References: [Gitea runner setup](https://docs.gitea.com/usage/actions/quickstart/), [npm automation authentication](https://docs.npmjs.com/using-private-packages-in-a-ci-cd-workflow/), [granular tokens](https://docs.npmjs.com/creating-and-viewing-access-tokens/).