diff --git a/.github/workflows/promote.yml b/.github/workflows/promote.yml index 4758498..8506325 100644 --- a/.github/workflows/promote.yml +++ b/.github/workflows/promote.yml @@ -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 +# +# `--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" diff --git a/.github/workflows/stage.yml b/.github/workflows/stage.yml index 6b1bc36..3dcaacd 100644 --- a/.github/workflows/stage.yml +++ b/.github/workflows/stage.yml @@ -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 ;; diff --git a/AGENTS.md b/AGENTS.md index 9294f9a..1b136cb 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -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 # Gitea → Verdaccio, reversible +git push gh v # 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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a514aa..1edf726 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). green-tea uses calendar versioning: `YY.M.PATCH` — the month is not zero-padded, since npm treats versions as semver and semver forbids leading zeros. -## [26.9.0-beta.1] - 2026-09-03 +## [26.9.0-beta.1] - 2026-09-04 ### Added