publish: every version is packed onto the dist branch, so a new plugin merges without waiting for npm
A new package's first npm version can't go through trusted publishing (a Trusted Publisher is set on a package that exists, with an owner's 2FA), so reviewed plugin PRs (#84 and others) sat unmerged until an owner published by hand. Now publish.yml's dist job packs every package's version (scripts/dist.mjs, npm pack --ignore-scripts) onto the dist branch: tgz/<file> and index.json with each tarball's sha512. magpie installs a @magpie-community package from there when npm doesn't have the version. A new package without NPM_TOKEN is a notice, not a failed run; a version npm refuses still fails it, now naming the stage-only default of trusts made since 2026-09-03 and --allow-publish. Run: node scripts/dist.mjs into an empty folder packed all 22 packages (index.json 164K); the zed tarball's sha512 equals npm pack's integrity; a second run packs nothing. The workflow itself is tried on main after this push (workflow_dispatch).
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# Checks a pull request before it is merged: the tests publish.yml runs, and
|
||||
# names any package new to npm (scripts/new-to-npm.sh), which the merge
|
||||
# publishes with the NPM_TOKEN secret.
|
||||
# names any package new to npm (scripts/new-to-npm.sh). A new package
|
||||
# doesn't hold the merge: magpie installs it from the dist branch.
|
||||
name: pr
|
||||
|
||||
on:
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
# Publishes every package whose version isn't on npm yet, from GitHub
|
||||
# Actions. npm tries trusted publishing (OIDC) first: a package that names
|
||||
# this workflow as its Trusted Publisher on npmjs.com needs nothing else.
|
||||
# What OIDC can't do, the NPM_TOKEN secret does: a package's first version
|
||||
# (trusted publishing can't create one) and a package whose Trusted
|
||||
# Publisher isn't set. NPM_TOKEN is an npm granular access token of a
|
||||
# magpie-community owner: read and write to the @magpie-community scope,
|
||||
# 2FA bypassed. With it nobody publishes by hand.
|
||||
# Ships every package's version two ways, from GitHub Actions:
|
||||
# - dist: packs it onto the `dist` branch (scripts/dist.mjs), where magpie
|
||||
# installs it from when npm doesn't have it. This needs nobody: merging a
|
||||
# new plugin is all it takes to reach magpie.
|
||||
# - npm: publishes every version npm doesn't have yet (scripts/publish.sh).
|
||||
# npm tries trusted publishing (OIDC) first: a package that names this
|
||||
# workflow as its Trusted Publisher on npmjs.com, with npm publish allowed,
|
||||
# needs nothing else. A package's first version can't go that way
|
||||
# (trusted publishing can't create a package): the NPM_TOKEN secret
|
||||
# publishes it when set, else it waits for an owner (README, Publishing)
|
||||
# and magpie installs it from dist meanwhile.
|
||||
name: publish
|
||||
|
||||
on:
|
||||
@@ -15,14 +18,60 @@ on:
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
id-token: write # npm's OIDC exchange
|
||||
contents: read
|
||||
|
||||
concurrency: publish
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 24
|
||||
- name: test
|
||||
# the tests refuse a real home: no real sign-in is ever read
|
||||
run: HOME=$(mktemp -d) bun test
|
||||
- name: check
|
||||
run: bun scripts/check.mjs
|
||||
|
||||
dist:
|
||||
needs: test
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write # pushes the dist branch
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 24
|
||||
- name: pack
|
||||
run: |
|
||||
git config --global user.name "github-actions[bot]"
|
||||
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
if git fetch --depth=1 origin dist; then
|
||||
git worktree add -B dist "$RUNNER_TEMP/dist" FETCH_HEAD
|
||||
else
|
||||
git worktree add --orphan -b dist "$RUNNER_TEMP/dist"
|
||||
fi
|
||||
node scripts/dist.mjs "$RUNNER_TEMP/dist"
|
||||
cd "$RUNNER_TEMP/dist"
|
||||
git add -A .
|
||||
if git diff --cached --quiet; then
|
||||
echo "dist is current"
|
||||
else
|
||||
git commit -q -m "dist: ${GITHUB_SHA::7}"
|
||||
git push origin dist
|
||||
fi
|
||||
|
||||
npm:
|
||||
needs: test
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
id-token: write # npm's OIDC exchange
|
||||
contents: read
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
@@ -30,9 +79,6 @@ jobs:
|
||||
with:
|
||||
node-version: 24 # npm 11.5+, which speaks trusted publishing
|
||||
registry-url: https://registry.npmjs.org
|
||||
- name: test
|
||||
# the tests refuse a real home: no real sign-in is ever read
|
||||
run: HOME=$(mktemp -d) bun test
|
||||
- name: publish
|
||||
run: scripts/publish.sh
|
||||
env:
|
||||
|
||||
Reference in New Issue
Block a user