Skip to content

Commit 286f10b

Browse files
committed
feat: publish and test via the shared ci-workflows reusable workflows
1 parent 6191504 commit 286f10b

3 files changed

Lines changed: 41 additions & 29 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,22 @@ on:
33
pull_request:
44
push:
55
branches: [main]
6+
permissions:
7+
contents: read
68
jobs:
7-
version-sync:
8-
runs-on: ubuntu-latest
9-
steps:
10-
- uses: actions/checkout@v4
11-
- run: |
12-
pkg=$(node -p "require('./package.json').version")
13-
plg=$(node -p "require('./plugin.json').version")
14-
if [ "$pkg" != "$plg" ]; then
15-
echo "version mismatch: package.json=$pkg plugin.json=$plg"
16-
exit 1
17-
fi
9+
test:
10+
# ci-workflows python-ci @ main
11+
uses: img2threejs/ci-workflows/.github/workflows/python-ci.yml@4b7a0612d2c52815792124a18ae3f9032a4f0a88
12+
with:
13+
python-version: '3.12'
14+
test-command: |
15+
pkg="$(node -p 'require("./package.json").version')"
16+
plg="$(node -p 'require("./plugin.json").version')"
17+
if [ "$pkg" != "$plg" ]; then
18+
echo "version mismatch: package.json=$pkg plugin.json=$plg"
19+
exit 1
20+
fi
21+
git clone --depth 1 https://github.com/img2threejs/img2 ../img2-harness
22+
mkdir -p ../img2home
23+
ln -s "$(cd ../img2-harness && pwd)" ../img2home/harness
24+
IMG2_HOME="$(cd ../img2home && pwd)" python3 -m unittest discover -s tests

‎.github/workflows/publish.yml‎

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,22 @@ on:
44
tags: ['v*']
55
permissions:
66
contents: read
7-
id-token: write
87
jobs:
98
publish:
10-
runs-on: ubuntu-latest
11-
steps:
12-
- uses: actions/checkout@v4
13-
- uses: actions/setup-node@v4
14-
with:
15-
node-version: 24
16-
registry-url: https://registry.npmjs.org
17-
- run: npm install -g npm@latest
18-
- run: |
19-
pkg=$(node -p "require('./package.json').version")
20-
plg=$(node -p "require('./plugin.json').version")
21-
[ "$pkg" = "$plg" ] || { echo "version mismatch: package.json=$pkg plugin.json=$plg"; exit 1; }
22-
[ "v$pkg" = "$GITHUB_REF_NAME" ] || { echo "tag $GITHUB_REF_NAME != v$pkg"; exit 1; }
23-
- run: npm publish --provenance --access public
9+
# ci-workflows npm-publish (feat/reusable-npm-publish); re-pin to the merged main SHA once img2threejs/ci-workflows#2 lands
10+
uses: img2threejs/ci-workflows/.github/workflows/npm-publish.yml@27da7a68505591492cb4ef7358968890c6e39844
11+
permissions:
12+
contents: read
13+
id-token: write
14+
with:
15+
tag: ${{ github.ref_name }}
16+
version-file: plugin.json
17+
node-version: '24'
18+
python-version: '3.12'
19+
test-command: |
20+
git clone --depth 1 https://github.com/img2threejs/img2 ../img2-harness
21+
mkdir -p ../img2home
22+
ln -s "$(cd ../img2-harness && pwd)" ../img2home/harness
23+
IMG2_HOME="$(cd ../img2home && pwd)" python3 -m unittest discover -s tests
24+
secrets:
25+
npm-token: ${{ secrets.NPM_TOKEN }}

‎README.md‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,14 @@ to enumerate what matters, and the point of an oracle is to catch the change nob
6161

6262
## Publishing to npm
6363

64-
1. Bump the version in **both** `plugin.json` and `package.json` — CI's `version-sync` job fails the build if they disagree.
64+
CI and publishing run through the org's shared [`img2threejs/ci-workflows`](https://github.com/img2threejs/ci-workflows) reusable workflows; this repo owns only its triggers and its test command.
65+
66+
1. Bump the version in **both** `plugin.json` and `package.json` — the `ci` workflow's version-sync check fails the build if they disagree.
6567
2. Update `CHANGELOG.md`.
6668
3. Commit the bump.
67-
4. Tag the commit `vX.Y.Z` (matching the new version) and push the tag.
68-
5. The `publish` workflow picks up the tag, re-checks the version match, and runs `npm publish --provenance --access public` against `@img2threejs/plugin-character`.
69+
4. Tag the commit `vX.Y.Z` (matching the new version) and push the tag. A prerelease tag (`v1.2.3-beta.1`) publishes under the matching npm dist-tag (`beta`); a stable tag publishes under `latest`.
70+
5. The shared `npm-publish.yml` workflow re-validates the tag against `package.json` and `plugin.json`, runs this repo's tests in a job with no access to the publish credential, and runs `npm publish --provenance` using the org's `NPM_TOKEN` secret (a granular npm automation token with publish rights on the `@img2threejs` scope, configured once at the org or repo level — no per-repo trusted-publisher setup needed). Re-pushing a tag whose version is already on the registry is a no-op, not a failure.
71+
6. Workflow references in `.github/workflows/` are pinned to a specific `ci-workflows` commit SHA, per that repo's pinning policy.
6972

7073
## Licence
7174

0 commit comments

Comments
 (0)