Repository navigation
ci: add tag-triggered npm release workflow for keygate-client - #4
Merged
Merged
Conversation
The package was only installable from git. A tag push now installs from the lockfile, checks, builds, publishes with provenance, and creates the release; a tag that disagrees with package.json fails before either of those run. Generated with Codebuff 🤖 Co-Authored-By: Codebuff <noreply@codebuff.com>
The release step needs contents: write, which the publish step should not have, so the two are separate jobs. A manual run now stops before upload, which makes the tag check and the tarball check testable without a token; npm is upgraded first because Node 20's npm 10 cannot do trusted publishing. Generated with Codebuff 🤖 Co-Authored-By: Codebuff <noreply@codebuff.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The SDK could only be installed from git because there was no release workflow, even though package.json already declares its published files (dist, README.md, LICENSE). This PR adds a release workflow triggered on
v*tags that checks the tag against the package version, runs checks and the build, publishes to npm with provenance, and creates a GitHub release. It also documents the process in CONTRIBUTING.md.Closes #3
Validation
Both runs are real GitHub Actions runs of this workflow, not a local replay.
actwas not usable from my environment (the Docker socket is not accessible), so I added a rehearsal entry point instead: a manual run executes every step except the upload and the release, which are gated ongithub.event_name == 'push'. A branch cannot publish.v0.1.0— success: https://github.com/nonchalanttee22-lgtm/keygate-client/actions/runs/41603043328Steps, in order: install from the lockfile,
Tag matches package.json,pnpm check,pnpm build, npm upgrade,npm publish --dry-runplus tarball assertions.Publish to npmshows as skipped because this was a manual run, and the release job is skipped for the same reason.v0.2.0— failure, as required: https://github.com/nonchalanttee22-lgtm/keygate-client/actions/runs/41603251363Check,Build, the npm upgrade, the tarball check andPublish to npmare all skipped after the guard fails.npm name
keygate-clientis free:npm view keygate-clientreturnsE404 Not Found - GET https://registry.npmjs.org/keygate-client. No scoped name is needed andpackage.jsonis unchanged.What changed
.github/workflows/release.yml (new)
v*, plusworkflow_dispatchwith ataginput for rehearsal (upload and release are skipped on manual runs).publishjob:contents: readandid-token: write; the separatereleasejob getscontents: write, so the step that publishes to npm never holds write access.corepack enable, thenpnpm install --frozen-lockfile.v+ the version in package.json, beforecheck,buildor any publish step.pnpm check, thenpnpm build, thennpm publish --dry-run+npm pack --dry-runassertions thatdist/index.js,dist/index.d.ts,LICENSEandREADME.mdship.^11.5.1before publishing: Node 20 bundles npm 10, and npm's OIDC/trusted publishing needs 11.5.1 or later.npm publish --provenance --access public.NPM_TOKENsecret (passed asNODE_AUTH_TOKEN), or npm trusted publishing when the maintainer configures it and leaves the secret unset.repository.urlin package.json to match the repository running the workflow (case-sensitively). It does:git+https://github.com/TeethakingBuilds/keygate-client.git. Releases must therefore run upstream; a fork publishing the same name would be rejected with E422.CONTRIBUTING.md
How to verify
Contents: read(visible near the top of the failing run's log).Checklist