Skip to content

Commit b698daa

Browse files
committed
update release script for oidc releases
1 parent 080b55a commit b698daa

File tree

1 file changed

+151
-0
lines changed

1 file changed

+151
-0
lines changed

.github/workflows/release.yml

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
name: Release
2+
3+
# This workflow handles latest, beta, and alpha releases:
4+
# - Latest: Triggered by GitHub releases (tag vX.Y.Z)
5+
# - Beta: Triggered by pushes to beta-X.Y.Z branches
6+
# - Alpha: Triggered by pushes to alpha-X.Y.Z branches
7+
8+
on:
9+
release:
10+
types: [released]
11+
push:
12+
branches:
13+
- beta-*.*.*
14+
- alpha-*.*.*
15+
workflow_dispatch:
16+
17+
permissions:
18+
id-token: write
19+
contents: write
20+
21+
concurrency:
22+
group: ${{ github.workflow }}-${{ github.ref }}
23+
cancel-in-progress: true
24+
25+
jobs:
26+
determine-release-type:
27+
name: Determine Release Type
28+
runs-on: ubuntu-latest
29+
if: ${{ github.repository == 'homebridge/dbus-native' }}
30+
outputs:
31+
release_type: ${{ steps.release-type.outputs.type }}
32+
npm_tag: ${{ steps.release-type.outputs.tag }}
33+
version: ${{ steps.get_version.outputs.version }}
34+
steps:
35+
- name: Determine release type
36+
id: release-type
37+
run: |
38+
if [[ "${{ github.event_name }}" == "release" ]]; then
39+
echo "type=latest" >> $GITHUB_OUTPUT
40+
echo "tag=latest" >> $GITHUB_OUTPUT
41+
elif [[ "${{ github.ref }}" == refs/heads/beta-* ]]; then
42+
echo "type=beta" >> $GITHUB_OUTPUT
43+
echo "tag=beta" >> $GITHUB_OUTPUT
44+
elif [[ "${{ github.ref }}" == refs/heads/alpha-* ]]; then
45+
echo "type=alpha" >> $GITHUB_OUTPUT
46+
echo "tag=alpha" >> $GITHUB_OUTPUT
47+
else
48+
echo "type=none" >> $GITHUB_OUTPUT
49+
echo "tag=none" >> $GITHUB_OUTPUT
50+
echo "No valid release type detected - skipping publish"
51+
fi
52+
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
74+
75+
publish:
76+
needs: [determine-release-type]
77+
if: |
78+
always() &&
79+
needs.determine-release-type.outputs.release_type != 'none' &&
80+
(needs.determine-release-type.outputs.release_type == 'alpha' ||
81+
needs.build_and_test_latest.result == 'success' ||
82+
needs.build_and_test_latest.result == 'skipped') &&
83+
(needs.build_and_test_beta.result == 'success' ||
84+
needs.build_and_test_beta.result == 'skipped')
85+
name: Publish to npm (${{ needs.determine-release-type.outputs.npm_tag }})
86+
runs-on: ubuntu-latest
87+
outputs:
88+
npm_version: ${{ steps.get-published-version.outputs.version }}
89+
steps:
90+
- name: Checkout code
91+
uses: actions/checkout@v6
92+
93+
- name: Setup Node.js
94+
uses: actions/setup-node@v6
95+
with:
96+
node-version: 24
97+
registry-url: 'https://registry.npmjs.org'
98+
99+
- name: Upgrade npm for OIDC support
100+
run: npm install -g npm@latest
101+
102+
- name: Install dependencies
103+
run: npm ci
104+
105+
- name: Handle prerelease versioning
106+
if: needs.determine-release-type.outputs.release_type == 'beta' || needs.determine-release-type.outputs.release_type == 'alpha'
107+
run: |
108+
# Download versioning script from homebridge/.github
109+
mkdir -p .github
110+
wget -q https://raw.githubusercontent.com/homebridge/.github/latest/.github/npm-version-script-esm.js -O .github/npm-version-script-esm.js
111+
112+
# Run the script to set base version
113+
node .github/npm-version-script-esm.js ${{ github.ref }} ${{ needs.determine-release-type.outputs.release_type }}
114+
115+
# Add prerelease suffix
116+
npm version pre --preid=${{ needs.determine-release-type.outputs.release_type }} --no-git-tag-version
117+
118+
- name: Publish to npm with OIDC
119+
run: npm publish --tag ${{ needs.determine-release-type.outputs.npm_tag }} --provenance --access public
120+
121+
- name: Get published version
122+
id: get-published-version
123+
run: |
124+
VERSION=$(node -p "require('./package.json').version")
125+
echo "version=$VERSION" >> $GITHUB_OUTPUT
126+
echo "Published version: $VERSION"
127+
128+
pre-release:
129+
needs: [determine-release-type, publish]
130+
name: Create GitHub Pre-Release
131+
if: |
132+
always() &&
133+
needs.publish.result == 'success' &&
134+
github.repository == 'homebridge/dbus-native' &&
135+
(needs.determine-release-type.outputs.release_type == 'beta' || needs.determine-release-type.outputs.release_type == 'alpha')
136+
runs-on: ubuntu-latest
137+
steps:
138+
- uses: actions/checkout@v6
139+
- name: Create nightly release
140+
id: create_release
141+
uses: viperproject/create-nightly-release@v1
142+
env:
143+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
144+
with:
145+
tag_name: v${{ needs.publish.outputs.npm_version }}
146+
release_name: v${{ needs.publish.outputs.npm_version }}
147+
body: |
148+
v${{ needs.publish.outputs.npm_version }}
149+
[How To Test Upcoming Changes](https://github.com/homebridge/dbus-native/wiki/How-To-Test-Upcoming-Changes)
150+
keep_num: 5
151+
keep_tags: false

0 commit comments

Comments
 (0)