Skip to content

Commit 2d45700

Browse files
committed
update release script for oidc releases
1 parent 22ff892 commit 2d45700

File tree

1 file changed

+144
-0
lines changed

1 file changed

+144
-0
lines changed

.github/workflows/release.yml

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
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: needs.determine-release-type.outputs.release_type != 'none'
78+
name: Publish to npm (${{ needs.determine-release-type.outputs.npm_tag }})
79+
runs-on: ubuntu-latest
80+
outputs:
81+
npm_version: ${{ steps.get-published-version.outputs.version }}
82+
steps:
83+
- name: Checkout code
84+
uses: actions/checkout@v6
85+
86+
- name: Setup Node.js
87+
uses: actions/setup-node@v6
88+
with:
89+
node-version: 24
90+
registry-url: 'https://registry.npmjs.org'
91+
92+
- name: Upgrade npm for OIDC support
93+
run: npm install -g npm@latest
94+
95+
- name: Install dependencies
96+
run: npm ci
97+
98+
- name: Handle prerelease versioning
99+
if: needs.determine-release-type.outputs.release_type == 'beta' || needs.determine-release-type.outputs.release_type == 'alpha'
100+
run: |
101+
# Download versioning script from homebridge/.github
102+
mkdir -p .github
103+
wget -q https://raw.githubusercontent.com/homebridge/.github/latest/.github/npm-version-script-esm.js -O .github/npm-version-script-esm.js
104+
105+
# Run the script to set base version
106+
node .github/npm-version-script-esm.js ${{ github.ref }} ${{ needs.determine-release-type.outputs.release_type }}
107+
108+
# Add prerelease suffix
109+
npm version pre --preid=${{ needs.determine-release-type.outputs.release_type }} --no-git-tag-version
110+
111+
- name: Publish to npm with OIDC
112+
run: npm publish --tag ${{ needs.determine-release-type.outputs.npm_tag }} --provenance --access public
113+
114+
- name: Get published version
115+
id: get-published-version
116+
run: |
117+
VERSION=$(node -p "require('./package.json').version")
118+
echo "version=$VERSION" >> $GITHUB_OUTPUT
119+
echo "Published version: $VERSION"
120+
121+
pre-release:
122+
needs: [determine-release-type, publish]
123+
name: Create GitHub Pre-Release
124+
if: |
125+
always() &&
126+
needs.publish.result == 'success' &&
127+
github.repository == 'homebridge/dbus-native' &&
128+
(needs.determine-release-type.outputs.release_type == 'beta' || needs.determine-release-type.outputs.release_type == 'alpha')
129+
runs-on: ubuntu-latest
130+
steps:
131+
- uses: actions/checkout@v6
132+
- name: Create nightly release
133+
id: create_release
134+
uses: viperproject/create-nightly-release@v1
135+
env:
136+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
137+
with:
138+
tag_name: v${{ needs.publish.outputs.npm_version }}
139+
release_name: v${{ needs.publish.outputs.npm_version }}
140+
body: |
141+
v${{ needs.publish.outputs.npm_version }}
142+
[How To Test Upcoming Changes](https://github.com/homebridge/dbus-native/wiki/How-To-Test-Upcoming-Changes)
143+
keep_num: 5
144+
keep_tags: false

0 commit comments

Comments
 (0)