ci: add scripts/deploy.sh — publish to npm without GitHub Actions - #15
Merged
Conversation
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.
A shell equivalent of the
publishworkflow, for releasing when Actions is unavailable, broken, or simply not wanted.What it does
Same sequence as the workflow: fetch the latest release tag (or the one you pass), validate it as semver, refuse if that version is already on npm, check the tag out into a temporary git worktree,
npm ci,npm test, set the version from the tag, publish, and post to Slack. Pre-releases go out under thenextdist-tag.Building from a worktree rather than the working tree means your local edits, branch and dirty files are irrelevant to what ships — and untouched afterwards. The worktree is removed on exit, including on failure.
Deployments
It records a GitHub Deployment against the
npmenvironment —in_progress→success/failure— so a local release shows up in the repo's Deployments list exactly like a workflow release does. Verified against the live API (created, transitioned, deleted; the repo has no leftover records).Slack
Reads
SLACK_WEBHOOK_URLfrom the environment or from a gitignored.env.releaseat the repo root. Start / success / failure messages match the workflow's, tagged as a local deploy. Without a webhook the script runs silently rather than failing.One real difference from CI
The workflow authenticates with OIDC trusted publishing, which only works from a CI runner. Locally you publish as yourself, so the script requires
npm loginand supports--otpfor 2FA. That's checked in preflight, along withgit/gh/npm/node/jq/curlandgh auth status.Safety
-y).--dry-runruns everything up to and includingnpm pack --dry-run, publishing nothing — exercised end-to-end while writing this.failure, Slack notified, worktree removed.shellcheckclean.