1212 branches :
1313 - beta-*.*.*
1414 - alpha-*.*.*
15+ workflow_dispatch :
1516
1617permissions :
1718 id-token : write
@@ -22,71 +23,93 @@ concurrency:
2223 cancel-in-progress : true
2324
2425jobs :
25- determine-npm-tag :
26- name : Determine NPM Tag
26+ determine-release-type :
27+ name : Determine Release Type
2728 runs-on : ubuntu-latest
28- if : ${{ github.repository == 'homebridge/hap-nodejs ' }}
29+ if : ${{ github.repository == 'homebridge/HAP-NodeJS ' }}
2930 outputs :
30- npm_tag : ${{ steps.npm-tag.outputs.tag }}
31+ release_type : ${{ steps.release-type.outputs.type }}
32+ npm_tag : ${{ steps.release-type.outputs.tag }}
33+ version : ${{ steps.get_version.outputs.version }}
3134 steps :
32- - name : Determine NPM Tag
33- id : npm-tag
35+ - name : Determine release type
36+ id : release-type
3437 run : |
3538 if [[ "${{ github.event_name }}" == "release" ]]; then
39+ echo "type=latest" >> $GITHUB_OUTPUT
3640 echo "tag=latest" >> $GITHUB_OUTPUT
3741 elif [[ "${{ github.ref }}" == refs/heads/beta-* ]]; then
42+ echo "type=beta" >> $GITHUB_OUTPUT
3843 echo "tag=beta" >> $GITHUB_OUTPUT
3944 elif [[ "${{ github.ref }}" == refs/heads/alpha-* ]]; then
45+ echo "type=alpha" >> $GITHUB_OUTPUT
4046 echo "tag=alpha" >> $GITHUB_OUTPUT
4147 else
48+ echo "type=none" >> $GITHUB_OUTPUT
4249 echo "tag=none" >> $GITHUB_OUTPUT
4350 echo "No valid release type detected - skipping publish"
4451 fi
4552
46- lint :
47- needs : determine-npm-tag
48- name : Lint
49- if : needs.determine-npm-tag.outputs.npm_tag != 'none'
50- uses : homebridge/.github/.github/workflows/eslint.yml@latest
53+ - name : Get Release Tag (Latest Only)
54+ if : steps.release-type.outputs.type == 'latest'
55+ id : get_version
56+ uses : jannemattila/get-version-from-tag@v3
57+
58+ - name : Tag Info (Latest Only)
59+ if : steps.release-type.outputs.type == 'latest'
60+ run : |
61+ echo "Release Tag: ${{github.ref}}"
62+ echo "Latest Tag: ${{ steps.get_version.outputs.version }}"
63+
64+ - name : Tag Info Matches (Latest Only)
65+ if : steps.release-type.outputs.type == 'latest' && endsWith(github.ref, steps.get_version.outputs.version)
66+ run : |
67+ echo Latest Tag matches Release tag
68+
69+ - name : Tag Info Doesn't Match (Latest Only)
70+ if : steps.release-type.outputs.type == 'latest' && !endsWith(github.ref, steps.get_version.outputs.version)
71+ run : |
72+ echo Latest Tag does not matches Release tag
73+ exit 1
5174
5275 build_and_test_latest :
53- needs : [ determine-npm-tag, lint]
54- name : Build & Test (Latest)
55- if : needs.determine-npm-tag .outputs.npm_tag == 'latest'
76+ needs : determine-release-type
77+ name : Build and Test ${{ needs.determine-release-type.outputs.version }}
78+ if : needs.determine-release-type .outputs.release_type == 'latest'
5679 uses : homebridge/.github/.github/workflows/nodejs-build-and-test.yml@latest
5780 with :
5881 enable_coverage : true
82+ install_cmd : npm ci
5983 secrets :
6084 token : ${{ secrets.GITHUB_TOKEN }}
6185
6286 build_and_test_beta :
63- needs : [ determine-npm-tag, lint]
64- name : Build & Test (Beta)
65- if : needs.determine-npm-tag .outputs.npm_tag == 'beta'
87+ needs : determine-release-type
88+ name : Build and Test (Beta)
89+ if : needs.determine-release-type .outputs.release_type == 'beta'
6690 uses : homebridge/.github/.github/workflows/nodejs-build-and-test.yml@latest
6791 with :
6892 enable_coverage : false
93+ install_cmd : npm ci
6994 secrets :
7095 token : ${{ secrets.GITHUB_TOKEN }}
7196
72- publish-to-npm :
73- needs : [determine-npm-tag, lint , build_and_test_latest, build_and_test_beta]
97+ publish :
98+ needs : [determine-release-type , build_and_test_latest, build_and_test_beta]
7499 if : |
75100 always() &&
76- needs.determine-npm-tag.outputs.npm_tag != 'none' &&
77- (needs.determine-npm-tag.outputs.npm_tag != 'alpha' ||
78- needs.lint.result == 'success') &&
79- (needs.determine-npm-tag.outputs.npm_tag == 'alpha' ||
101+ needs.determine-release-type.outputs.release_type != 'none' &&
102+ (needs.determine-release-type.outputs.release_type == 'alpha' ||
80103 needs.build_and_test_latest.result == 'success' ||
81104 needs.build_and_test_latest.result == 'skipped') &&
82105 (needs.build_and_test_beta.result == 'success' ||
83106 needs.build_and_test_beta.result == 'skipped')
84- name : Publish To NPM (${{ needs.determine-npm-tag .outputs.npm_tag }})
107+ name : Publish to npm (${{ needs.determine-release-type .outputs.npm_tag }})
85108 runs-on : ubuntu-latest
86109 outputs :
87110 npm_version : ${{ steps.get-published-version.outputs.version }}
88111 steps :
89- - name : Checkout Code
112+ - name : Checkout code
90113 uses : actions/checkout@v6
91114
92115 - name : Setup Node.js
@@ -95,49 +118,50 @@ jobs:
95118 node-version : 24
96119 registry-url : ' https://registry.npmjs.org'
97120
98- - name : Upgrade NPM ( OIDC Support)
121+ - name : Upgrade npm for OIDC support
99122 run : npm install -g npm@latest
100123
101- - name : Install Dependencies
124+ - name : Install dependencies
102125 run : npm ci
103126
104- - name : Handle Prerelease Versioning
105- if : needs.determine-npm-tag .outputs.npm_tag == 'beta' || needs.determine-npm-tag .outputs.npm_tag == 'alpha'
127+ - name : Handle prerelease versioning
128+ if : needs.determine-release-type .outputs.release_type == 'beta' || needs.determine-release-type .outputs.release_type == 'alpha'
106129 run : |
107130 # Download versioning script from homebridge/.github
108131 mkdir -p .github
109132 wget -q https://raw.githubusercontent.com/homebridge/.github/latest/.github/npm-version-script-esm.js -O .github/npm-version-script-esm.js
110133
111134 # Run the script to set base version
112- node .github/npm-version-script-esm.js ${{ github.ref }} ${{ needs.determine-npm-tag .outputs.npm_tag }}
135+ node .github/npm-version-script-esm.js ${{ github.ref }} ${{ needs.determine-release-type .outputs.release_type }}
113136
114137 # Add prerelease suffix
115- npm version pre --preid=${{ needs.determine-npm-tag .outputs.npm_tag }} --no-git-tag-version
138+ npm version pre --preid=${{ needs.determine-release-type .outputs.release_type }} --no-git-tag-version
116139
117140 - name : Build
118141 run : npm run build
119142
120- - name : NPM Publish ( OIDC)
121- run : npm publish --tag ${{ needs.determine-npm-tag .outputs.npm_tag }} --provenance --access public
143+ - name : Publish to npm with OIDC
144+ run : npm publish --tag ${{ needs.determine-release-type .outputs.npm_tag }} --provenance --access public
122145
123- - name : Get Published Version
146+ - name : Get published version
124147 id : get-published-version
125148 run : |
126149 VERSION=$(node -p "require('./package.json').version")
127150 echo "version=$VERSION" >> $GITHUB_OUTPUT
128- echo "Published Version : $VERSION"
151+ echo "Published version : $VERSION"
129152
130153 github-releases-to-discord :
131154 name : Discord Webhooks
132- needs : [determine-npm-tag , publish-to-npm ]
155+ needs : [determine-release-type , publish]
133156 if : |
134157 always() &&
135- needs.publish-to-npm.result == 'success'
158+ needs.publish.result == 'success' &&
159+ needs.attach-artifact.result == 'success'
136160 uses : homebridge/.github/.github/workflows/discord-webhooks.yml@latest
137161 with :
138- title : ${{ needs.determine-npm-tag.outputs.npm_tag == 'latest' && ' HAP-NodeJS Release' || needs.determine-npm-tag.outputs.npm_tag == 'beta' && 'HAP-NodeJS Beta Release' || 'HAP-NodeJS Alpha Release' }}
162+ title : " HAP-NodeJS Release"
139163 description : |
140- Version `v${{ needs.publish-to-npm .outputs.npm_version }}`
141- url : ' https://github.com/homebridge/hap-nodejs /releases/tag/v${{ needs.publish-to-npm .outputs.npm_version }}'
164+ Version `v${{ needs.publish.outputs.NPM_VERSION }}`
165+ url : " https://github.com/homebridge/HAP-NodeJS /releases/tag/v${{ needs.publish.outputs.NPM_VERSION }}"
142166 secrets :
143- DISCORD_WEBHOOK : ${{ needs.determine-npm-tag .outputs.npm_tag == 'latest' && secrets.DISCORD_WEBHOOK_URL_LATEST || secrets.DISCORD_WEBHOOK_URL_BETA }}
167+ DISCORD_WEBHOOK : ${{ needs.determine-release-type .outputs.release_type == 'latest' && secrets.DISCORD_WEBHOOK_URL_LATEST || secrets.DISCORD_WEBHOOK_URL_BETA }}
0 commit comments