ci(release): stage a tag on Gitea before it can reach production

A `v*` tag did two things at once: `promote.yml` mirrored it to GitHub, and GitHub's
`release.yml` published it to npm and JSR. Creating the tag *was* the release, so the only
place to catch a bad one was a registry where npm gives 72 hours to unpublish and JSR gives
nothing — a version number spent on a mistake is spent for good.

The tag now means something different on each forge. On Gitea it triggers `stage.yml`,
which runs the real publish path — same `prepublishOnly` gate, same tarball, same commit —
against the internal Verdaccio, where a version can be overwritten. On GitHub it still
publishes for real. Nothing carries the tag between them; that push is a decision made
after reading the staging run.

`--tags` comes off the branch push in the same change, and it is the part that mattered
most. Removing the tag trigger alone would have left any tag in the runner's clone riding
along with the next promotion of `main` — a production publish as a side effect of a
merge, which is the exact failure the split is meant to prevent.

The refusal to stage a stable version is left as it is, with a note. It will first bite at
the release most worth staging, and the fix there is a suffixed staging version rather than
dropping a guard that keeps a stable number from mutating under an internal consumer.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
chrnx committed 2026-09-04 08:10:17 -05:00
1 parent aa15862f3b
commit cd4a9f65f6
3 files changed
+50 -19

No files matched your search

+17 -13
View File
@@ -1,13 +1,22 @@
name: Promote → GitHub
# Promotion. Runs on GITEA ONLY. Mirrors ONLY `main` + version tags to the public GitHub
# repo — develop and feature branches stay Gitea-private (this is why we don't use Gitea's
# push-mirror, which would expose every branch). A pushed tag lands on GitHub and triggers
# its release workflow (production publish).
# Promotion. Runs on GITEA ONLY. Mirrors ONLY `main` to the public GitHub repo — develop and
# feature branches stay Gitea-private (this is why we don't use Gitea's push-mirror, which
# would expose every branch).
#
# Tags are deliberately NOT mirrored. The same `v*` tag means two different things on the two
# forges: on Gitea it stages to Verdaccio (`stage.yml`), on GitHub it publishes to npm and
# JSR, and a JSR version can never be replaced or removed. Promoting the tag is therefore a
# decision a person takes after reading the staging run, not a side effect of creating it:
#
# git push gh v<version>
#
# `--tags` is left off the branch push for the same reason. It used to ride along here, which
# meant any tag sitting in the runner's clone could reach production as a side effect of
# promoting `main` — a publish nobody chose, of a commit nobody was looking at.
on:
push:
branches: [main]
tags: ['v*']
jobs:
push-github:
@@ -16,15 +25,10 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # full history + tags for a clean push
- name: Push main + tags to GitHub
fetch-depth: 0 # full history for a clean push
- name: Push main to GitHub
env:
GH_TOKEN: ${{ secrets.GH_PROMOTE_TOKEN }}
run: |
git remote add github "https://x-access-token:${GH_TOKEN}@github.com/Expressive-Tea/green-tea.git"
if [ "${{ github.ref_type }}" = "tag" ]; then
git push github "refs/tags/${{ github.ref_name }}"
else
git push github "HEAD:refs/heads/main"
git push github --tags
fi
git push github "HEAD:refs/heads/main"
+13 -2
View File
@@ -1,12 +1,18 @@
name: Stage → Verdaccio
# Staging publish. Runs on GITEA ONLY (the `if` guards against GitHub) for release
# branches. Publishes prereleases to the internal Verdaccio under the `stg` dist-tag.
# Staging publish. Runs on GITEA ONLY (the `if` guards against GitHub). Publishes to the
# internal Verdaccio under the `stg` dist-tag, from a `release/**` branch or from a `v*` tag.
# Staging versions are intentionally mutable: an existing prerelease is removed before
# publishing the updated release candidate under the same version.
#
# The tag trigger is what makes creating a tag on Gitea safe. It runs the real publish path —
# the same `prepublishOnly` gate, the same tarball, the same commit — against a registry we
# can overwrite, so the release is proven before the tag is promoted to GitHub, where npm
# allows 72 hours to unpublish and JSR allows nothing at all.
on:
push:
branches: ['release/**']
tags: ['v*']
jobs:
publish-stg:
@@ -32,6 +38,11 @@ jobs:
run: |
npm config set //npm.svc.zoit.services/:_authToken "$NODE_AUTH_TOKEN"
VER=$(node -p "require('./package.json').version")
# Staging overwrites the version it publishes, and a stable number that changes
# under an internal consumer is worse than no staging at all. This will need
# revisiting at the first stable release, which is exactly the one most worth
# staging: the answer is probably to stage it under a suffixed version rather
# than to drop the guard.
case "$VER" in
*-*) ;;
*) echo "Refusing to stage non-prerelease version: $VER" >&2; exit 1 ;;
+20 -4
View File
@@ -29,16 +29,19 @@ Run the first four before proposing anything as finished. The runtime suites sta
## Two forges
Development lives on a private Gitea instance. GitHub is a downstream mirror that receives `main` and release tags, nothing else.
Development lives on a private Gitea instance. GitHub is a downstream mirror that receives `main` automatically and release tags only by hand.
```
feature/* → develop → main → [promote.yml] → GitHub main
↑ ↓
lead dev GitHub contrib ← external PRs
↑ │ ↓
lead dev │ GitHub contrib ← external PRs
│
v* tag ────┴─── Gitea: [stage.yml] → Verdaccio
└─── GitHub (pushed by hand): [release.yml] → npm + JSR
```
- **Gitea `develop`** — active development.
- **Gitea `main`** — staging. Merging here publishes nothing; only a `v*` tag publishes.
- **Gitea `main`** — staging. Merging here publishes nothing. A `v*` tag here publishes to the internal Verdaccio, never to a public registry.
- **GitHub `main`** — production mirror. No human touches it. Protected against force-push and deletion, with no review requirement, because `promote.yml` pushes to it directly and a review rule would block that.
- **`contrib`** — exists on *both* forges. Where outside contributions land.
@@ -85,6 +88,19 @@ Bumping `package.json` and `deno.json` ahead of the tag is fine and necessary
*next* publish will be called, and the docs repo's `verify:release` compares the tag against them.
A version number is a plan; a changelog heading is a receipt.
**A tag is created twice, on purpose.** Pushing `v*` to Gitea stages that exact commit to
Verdaccio through the real publish path; pushing the same tag to GitHub publishes it to npm and
JSR. Nothing promotes the tag for you — `promote.yml` mirrors `main` and only `main`, so the
second push is a decision made after reading the first run:
```bash
git push origin v<version> # Gitea → Verdaccio, reversible
git push gh v<version> # GitHub → npm + JSR, permanent on JSR
```
The split exists because a mistake caught on Verdaccio costs a re-tag, and the same mistake
caught on JSR costs the version number forever.
**After a beta release, move the channel tag by hand.** A publish sets exactly one dist-tag, and it
is the only npm write the release workflow can make — Trusted Publishing's OIDC exchange lives inside
`npm publish`, so the token it hands back is rejected by `npm dist-tag` (`E401`, learned the hard way