-
-
Notifications
You must be signed in to change notification settings - Fork 3
169 lines (152 loc) · 6.67 KB
/
Copy pathrelease.yml
File metadata and controls
169 lines (152 loc) · 6.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
name: Release
on:
push:
branches:
- 'beta-*'
- 'beta'
- 'latest'
workflow_dispatch:
inputs:
release_type:
description: Release channel
required: true
type: choice
options:
- latest
- beta
- alpha
default: latest
is_esm:
description: Package is ESM
required: true
type: boolean
default: true
version_override:
description: Exact version (for example 2.1.0). Leave empty for auto bump.
required: false
type: string
version_bump:
description: Auto bump type when version_override is empty
required: false
type: choice
options:
- patch
- minor
- major
default: patch
max_attempts:
description: Max retries for prerelease collision handling
required: false
type: number
default: 5
# Cancel any in-progress workflow for the same branch. A new push should
# supersede the previous run rather than racing it to publish.
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true
jobs:
# ─── QUALITY GATE (all branches) ────────────────────────────────────────────
# Build and test run for EVERY push, regardless of branch. Both the beta
# and stable release paths depend on these passing before anything is
# published or version-bumped.
# 1️⃣ Build and test
build_and_test:
uses: homebridge/.github/.github/workflows/nodejs-build-and-test.yml@latest
with:
enable_coverage: false
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
# 2️⃣ Lint
lint:
needs: build_and_test
uses: homebridge/.github/.github/workflows/eslint.yml@latest
# ─── BETA RELEASE (branches starting with "beta") ────────────────────────────
# 3️⃣ Publish beta to NPM (OIDC — id-token required here and in the reusable workflow)
beta-publish:
if: startsWith(github.ref_name, 'beta')
needs: lint
permissions:
id-token: write
uses: homebridge/.github/.github/workflows/npm-publish-esm-oidc.yml@latest
with:
tag: 'beta'
dynamically_adjust_version: true
npm_version_command: 'pre'
pre_id: 'beta'
# 4️⃣ Create GitHub pre-release
beta-pre-release:
if: startsWith(github.ref_name, 'beta')
needs: beta-publish
uses: homebridge/.github/.github/workflows/pre-release.yml@latest
with:
npm_version: ${{ needs.beta-publish.outputs.NPM_VERSION }}
body: |
**Beta Release**
**Version**: v${{ needs.beta-publish.outputs.NPM_VERSION }}
[How To Test Beta Releases](https://github.com/homebridge-plugins/homebridge-plugin-update-check/wiki/Beta-Version)
# ─── STABLE RELEASE (branch: "latest") ───────────────────────────────────────
# 3️⃣ Determine release type, ESM status, and branch name
determine-release-type:
if: github.ref_name == 'latest'
needs: lint
uses: homebridge/.github/.github/workflows/determine-release-type.yml@latest
with:
ref_name: ${{ github.ref_name }}
# 4️⃣ Update version and changelog using the scripts
update-version:
if: github.ref_name == 'latest'
needs: determine-release-type
uses: homebridge/.github/.github/workflows/update-version.yml@latest
with:
release_type: ${{ needs.determine-release-type.outputs.release_type || inputs.release_type }}
is_esm: ${{ needs.determine-release-type.outputs.is_esm == 'true' || inputs.is_esm == 'true' }}
version_override: ${{ inputs.version_override }}
version_bump: ${{ inputs.version_bump }}
# 5️⃣ Publish to NPM and create GitHub release (OIDC — id-token required here and in the reusable workflow)
publish-release:
if: github.ref_name == 'latest'
needs: [determine-release-type, update-version]
permissions:
id-token: write
contents: write
uses: homebridge/.github/.github/workflows/publish-release.yml@latest
with:
release_type: ${{ needs.determine-release-type.outputs.release_type }}
version: ${{ needs.update-version.outputs.version }}
is_esm: ${{ needs.determine-release-type.outputs.is_esm == 'true' }}
version_override: ${{ inputs.version_override || '' }}
version_bump: ${{ inputs.version_bump || 'patch' }}
max_attempts: ${{ inputs.max_attempts || 5 }}
secrets:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# 6️⃣ Promote branch if this is a prerelease (alpha/beta)
promote-branch:
if: ${{ github.ref_name == 'latest' && needs.determine-release-type.outputs.release_type != 'latest' && needs.determine-release-type.outputs.release_type != 'skip' }}
needs: [determine-release-type, publish-release]
uses: homebridge/.github/.github/workflows/promote-branch.yml@latest
with:
branch_name: ${{ needs.determine-release-type.outputs.branch_name }}
release_type: ${{ needs.determine-release-type.outputs.release_type }}
is_esm: ${{ needs.determine-release-type.outputs.is_esm == 'true' || inputs.is_esm == 'true' }}
# 7️⃣ Notify if any job fails
workflow-failure:
if: failure()
needs: [build_and_test, lint, determine-release-type, update-version, publish-release, promote-branch]
uses: homebridge/.github/.github/workflows/report-failure.yml@latest
with:
workflow_name: ${{ github.workflow }}
job_name: ${{ github.job }}
run_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
# 8️⃣ Post to Discord (Beta + Stable)
discord:
name: Release Notifications
if: ${{ always() && ((startsWith(github.ref_name, 'beta') && needs.beta-publish.result == 'success') || (github.ref_name == 'latest' && needs.publish-release.result == 'success')) }}
needs: [beta-publish, update-version, publish-release]
uses: homebridge/.github/.github/workflows/discord-webhooks.yml@latest
with:
title: ${{ startsWith(github.ref_name, 'beta') && 'Homebridge Plugin Update Check Beta Release' || 'Homebridge Plugin Update Check Release' }}
description: |
Version `v${{ startsWith(github.ref_name, 'beta') && needs.beta-publish.outputs.NPM_VERSION || needs.update-version.outputs.version }}`
url: "https://github.com/homebridge-plugins/homebridge-plugin-update-check/releases/tag/v${{ startsWith(github.ref_name, 'beta') && needs.beta-publish.outputs.NPM_VERSION || needs.update-version.outputs.version }}"
secrets:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL_LATEST }}