Skip to content

Add GitHub Actions workflow to auto-publish to npm on release#26

Open
identd113 wants to merge 2 commits into
OpenGarage:masterfrom
identd113:pr-npm-publish-workflow
Open

Add GitHub Actions workflow to auto-publish to npm on release#26
identd113 wants to merge 2 commits into
OpenGarage:masterfrom
identd113:pr-npm-publish-workflow

Conversation

@identd113
Copy link
Copy Markdown
Contributor

Summary

Adds a GitHub Actions workflow that automatically publishes to npm when a GitHub Release is published, or on demand via the Actions tab. Tests run first — publish is blocked if they fail.


One-time setup required

Step 1 — Create an npm Automation token

  1. Log in to npmjs.com
  2. Go to Account → Access Tokens → Generate New Token
  3. Choose Granular Access Token
  4. Set the following:
    • Package: homebridge-og → permission: Read and write
    • Bypass 2FA: enabled (required for CI automation)
  5. Copy the token — you won't see it again

Step 2 — Add the token as a GitHub secret

  1. Go to github.com/OpenGarage/homebridge-og → Settings → Secrets and variables → Actions
  2. Click New repository secret
    • Name: NPM_TOKEN
    • Value: the token from Step 1
  3. Click Add secret

That's it. The workflow will now have publish access.


How to publish a new version

  1. Bump version in package.json, update CHANGELOG.md, commit and push
  2. Go to GitHub → Releases → Draft a new release
  3. Create a new tag matching the version (e.g. v3.2.1)
  4. Add release notes, click Publish release
  5. The workflow triggers automatically → tests run → publishes to npm

Alternatively, trigger it manually any time from Actions → npm publish → Run workflow.

Test plan

  • NPM_TOKEN secret added (Steps 1–2 above)
  • Publish a release → workflow runs, tests pass, package appears on npm
  • Re-running on an already-published version fails with a clear error message
  • Manual trigger via Actions tab works

🤖 Generated with Claude Code

identd113 and others added 2 commits May 15, 2026 19:51
Triggers when a GitHub Release is published. Runs tests first, then
publishes to npm using the NPM_TOKEN repository secret. Validates the
version isn't already published before attempting.

To enable: add an npm Automation token as a repository secret named NPM_TOKEN.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Allows the workflow to be run manually from the Actions tab without
needing to create a GitHub Release first.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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