From 6a75878d6717f3fe284766ff9298ce795b011d6a Mon Sep 17 00:00:00 2001 From: identd113 Date: Fri, 15 May 2026 19:51:38 -0500 Subject: [PATCH 1/2] Add GitHub Actions workflow to publish to npm on release 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 --- .github/workflows/npm-publish.yml | 41 +++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/npm-publish.yml diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 0000000..1b16a94 --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,41 @@ +name: npm publish + +on: + release: + types: [published] + +permissions: + contents: read + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + - run: npm ci + - run: npm test + + publish: + needs: test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + registry-url: https://registry.npmjs.org/ + - run: npm ci + - name: Validate version is unpublished + run: | + VERSION=$(node -p "require('./package.json').version") + if npm view "homebridge-og@$VERSION" version >/dev/null 2>&1; then + echo "Version $VERSION is already published. Bump package.json version first." + exit 1 + fi + echo "Publishing homebridge-og@$VERSION" + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} From f6964e127e11c99179c6450bd235c13554bf971c Mon Sep 17 00:00:00 2001 From: identd113 Date: Fri, 15 May 2026 19:54:08 -0500 Subject: [PATCH 2/2] Add workflow_dispatch trigger to npm publish workflow 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 --- .github/workflows/npm-publish.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 1b16a94..10e3e61 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -3,6 +3,7 @@ name: npm publish on: release: types: [published] + workflow_dispatch: {} permissions: contents: read