-
Notifications
You must be signed in to change notification settings - Fork 31
120 lines (106 loc) · 4.94 KB
/
Copy pathrelease.yml
File metadata and controls
120 lines (106 loc) · 4.94 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
name: Release
on:
push:
branches:
- 'beta-*'
- 'beta'
- 'latest'
workflow_dispatch:
jobs:
# ─── BETA RELEASE (branches starting with "beta") ────────────────────────────
# 1️⃣ Build and test
build_and_test:
if: startsWith(github.ref_name, 'beta')
uses: homebridge/.github/.github/workflows/nodejs-build-and-test.yml@latest
with:
enable_coverage: false
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
# 2️⃣ Lint
lint:
if: startsWith(github.ref_name, 'beta')
needs: build_and_test
uses: homebridge/.github/.github/workflows/eslint.yml@latest
# 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/OpenWonderLabs/homebridge-switchbot/wiki/Beta-Version)
# ─── STABLE RELEASE (branch: "latest") ───────────────────────────────────────
# 1️⃣ Determine release type, ESM status, and branch name
determine-release-type:
if: github.ref_name == 'latest'
uses: homebridge/.github/.github/workflows/determine-release-type.yml@latest
with:
ref_name: ${{ github.ref_name }}
# 2️⃣ 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 }}
is_esm: ${{ needs.determine-release-type.outputs.is_esm == 'true' }}
# 3️⃣ 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' }}
secrets:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# 4️⃣ 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' }}
# 5️⃣ Notify if any stable-release job fails
workflow-failure:
if: failure()
needs: [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 }}
# 6️⃣ 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') && 'SwitchBot-Node Beta Release' || 'SwitchBot-Node Release' }}
description: |
Version `v${{ startsWith(github.ref_name, 'beta') && needs.beta-publish.outputs.NPM_VERSION || needs.update-version.outputs.version }}`
url: "https://github.com/OpenWonderLabs/node-switchbot/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 }}