Skip to content

ci: fix npm upgrade in publish job + add workflow_dispatch fallback#3

Merged
ktamas77 merged 1 commit intomainfrom
fix/ci-publish-npx
May 4, 2026
Merged

ci: fix npm upgrade in publish job + add workflow_dispatch fallback#3
ktamas77 merged 1 commit intomainfrom
fix/ci-publish-npx

Conversation

@ktamas77
Copy link
Copy Markdown
Member

@ktamas77 ktamas77 commented May 4, 2026

Summary

  • Replace the broken npm install -g npm@latest step (Node 22.22.2's bundled npm corrupts itself mid-install with Cannot find module 'promise-retry') with npx -y npm@11.5.2 publish --provenance --access public. This still satisfies the Trusted Publisher OIDC requirement of npm >= 11.5.1 without trying to upgrade the global npm.
  • Add a workflow_dispatch trigger with a tag input so a failed publish can be re-run against an existing tag (e.g. v0.1.3) without having to bump versions.

Why

  • The 0.1.3 publish run failed at npm install -g npm@latest, leaving the tag created on git but never pushed to npm. Once this lands, dispatching the workflow with tag=v0.1.3 will publish 0.1.3 to npm.

Test plan

  • After merge, run gh workflow run release.yml -f tag=v0.1.3 and confirm npm view @squidcode/timebook version reports 0.1.3.

`npm install -g npm@latest` is broken on Node 22.22.2's bundled npm
(missing 'promise-retry'), which broke the 0.1.3 publish. Switch to
`npx -y npm@11.5.2 publish` — pinned for Trusted Publisher OIDC, no
broken global install needed.

Also add a workflow_dispatch trigger with a `tag` input so a publish
can be re-run for an existing tag (e.g. v0.1.3) when CI flaked,
without having to bump versions.
@ktamas77 ktamas77 merged commit dfd92d5 into main May 4, 2026
0 of 3 checks passed
id-token: write
steps:
- uses: actions/checkout@v4
with:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In workflow_dispatch, inputs.tag is passed directly to actions/checkout as ref, which can be any branch/commit/ref string, not necessarily a release tag. This makes it possible to accidentally (or intentionally) publish arbitrary code to npm instead of an immutable release tag.

Suggested change
with:
ref: refs/tags/${{ inputs.tag }}
Fix prompt (copy to your AI agent)
Update `.github/workflows/release.yml` so manual publish only accepts real tags: use `ref: refs/tags/${{ inputs.tag }}` (not raw input), and add a validation step before publish that fails unless `inputs.tag` matches your release pattern (for example `^v[0-9]+\.[0-9]+\.[0-9]+$`) and exists in `refs/tags/`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant