@switchbot/homebridge-switchbot 5.0.0-beta.99 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.changeset/config.json +14 -0
- package/.github/copilot-instructions.md +39 -0
- package/.github/workflows/ci.yml +4 -1
- package/.github/workflows/manual-e2e.yml +6 -3
- package/.github/workflows/release.yml +64 -15
- package/.github/workflows/stale.yml +2 -4
- package/.husky/pre-push +15 -0
- package/CHANGELOG.md +126 -134
- package/MIGRATION.md +16 -6
- package/README.md +84 -3
- package/TODO.md +263 -0
- package/config.schema.json +229 -36
- package/dist/SwitchBotHAPPlatform.d.ts +133 -0
- package/dist/SwitchBotHAPPlatform.d.ts.map +1 -0
- package/dist/SwitchBotHAPPlatform.js +555 -0
- package/dist/SwitchBotHAPPlatform.js.map +1 -0
- package/dist/SwitchBotMatterPlatform.d.ts +141 -0
- package/dist/SwitchBotMatterPlatform.d.ts.map +1 -0
- package/dist/SwitchBotMatterPlatform.js +536 -0
- package/dist/SwitchBotMatterPlatform.js.map +1 -0
- package/dist/device-types.d.ts +31 -0
- package/dist/device-types.d.ts.map +1 -0
- package/dist/device-types.js +246 -0
- package/dist/device-types.js.map +1 -0
- package/dist/deviceCommandMapper.d.ts +10 -0
- package/dist/deviceCommandMapper.d.ts.map +1 -0
- package/dist/deviceCommandMapper.js +319 -0
- package/dist/deviceCommandMapper.js.map +1 -0
- package/dist/deviceFactory.d.ts +3 -2
- package/dist/deviceFactory.d.ts.map +1 -1
- package/dist/deviceFactory.js +107 -29
- package/dist/deviceFactory.js.map +1 -1
- package/dist/devices/genericDevice.d.ts +59 -37
- package/dist/devices/genericDevice.d.ts.map +1 -1
- package/dist/devices/genericDevice.js +376 -78
- package/dist/devices/genericDevice.js.map +1 -1
- package/dist/errors.d.ts +38 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +32 -0
- package/dist/errors.js.map +1 -0
- package/dist/homebridge-ui/device-types.js +246 -0
- package/dist/homebridge-ui/device-types.js.map +1 -0
- package/dist/homebridge-ui/deviceCommandMapper.js +319 -0
- package/dist/homebridge-ui/deviceCommandMapper.js.map +1 -0
- package/dist/homebridge-ui/endpoints/config.d.ts +3 -0
- package/dist/homebridge-ui/endpoints/config.d.ts.map +1 -0
- package/dist/homebridge-ui/endpoints/config.js +90 -0
- package/dist/homebridge-ui/endpoints/config.js.map +1 -0
- package/dist/homebridge-ui/endpoints/devices.d.ts +6 -0
- package/dist/homebridge-ui/endpoints/devices.d.ts.map +1 -0
- package/dist/homebridge-ui/endpoints/devices.js +144 -0
- package/dist/homebridge-ui/endpoints/devices.js.map +1 -0
- package/dist/homebridge-ui/endpoints/discovery.d.ts +7 -0
- package/dist/homebridge-ui/endpoints/discovery.d.ts.map +1 -0
- package/dist/homebridge-ui/endpoints/discovery.js +219 -0
- package/dist/homebridge-ui/endpoints/discovery.js.map +1 -0
- package/dist/homebridge-ui/errors.js +32 -0
- package/dist/homebridge-ui/errors.js.map +1 -0
- package/dist/homebridge-ui/homebridge-ui/endpoints/config.js +90 -0
- package/dist/homebridge-ui/homebridge-ui/endpoints/config.js.map +1 -0
- package/dist/homebridge-ui/homebridge-ui/endpoints/devices.js +144 -0
- package/dist/homebridge-ui/homebridge-ui/endpoints/devices.js.map +1 -0
- package/dist/homebridge-ui/homebridge-ui/endpoints/discovery.js +219 -0
- package/dist/homebridge-ui/homebridge-ui/endpoints/discovery.js.map +1 -0
- package/dist/homebridge-ui/homebridge-ui/server.js +11 -0
- package/dist/homebridge-ui/homebridge-ui/server.js.map +1 -0
- package/dist/homebridge-ui/homebridge-ui/utils/config-parser.js +108 -0
- package/dist/homebridge-ui/homebridge-ui/utils/config-parser.js.map +1 -0
- package/dist/homebridge-ui/homebridge-ui/utils/device-migration.js +111 -0
- package/dist/homebridge-ui/homebridge-ui/utils/device-migration.js.map +1 -0
- package/dist/homebridge-ui/homebridge-ui/utils/logger.js +17 -0
- package/dist/homebridge-ui/homebridge-ui/utils/logger.js.map +1 -0
- package/dist/homebridge-ui/public/css/styles.css +483 -0
- package/dist/homebridge-ui/public/index.html +197 -621
- package/dist/homebridge-ui/public/js/advanced-settings.d.ts +3 -0
- package/dist/homebridge-ui/public/js/advanced-settings.d.ts.map +1 -0
- package/dist/homebridge-ui/public/js/advanced-settings.js +95 -0
- package/dist/homebridge-ui/public/js/advanced-settings.js.map +1 -0
- package/dist/homebridge-ui/public/js/advanced-settings.ts +94 -0
- package/dist/homebridge-ui/public/js/api.d.ts +66 -0
- package/dist/homebridge-ui/public/js/api.d.ts.map +1 -0
- package/dist/homebridge-ui/public/js/api.js +295 -0
- package/dist/homebridge-ui/public/js/api.js.map +1 -0
- package/dist/homebridge-ui/public/js/api.ts +355 -0
- package/dist/homebridge-ui/public/js/app.d.ts +2 -0
- package/dist/homebridge-ui/public/js/app.d.ts.map +1 -0
- package/dist/homebridge-ui/public/js/app.js +3722 -0
- package/dist/homebridge-ui/public/js/app.js.map +7 -0
- package/dist/homebridge-ui/public/js/app.ts +22 -0
- package/dist/homebridge-ui/public/js/constants.d.ts +2 -0
- package/dist/homebridge-ui/public/js/constants.d.ts.map +1 -0
- package/dist/homebridge-ui/public/js/constants.js +2 -0
- package/dist/homebridge-ui/public/js/constants.js.map +1 -0
- package/dist/homebridge-ui/public/js/constants.ts +1 -0
- package/dist/homebridge-ui/public/js/credentials.d.ts +3 -0
- package/dist/homebridge-ui/public/js/credentials.d.ts.map +1 -0
- package/dist/homebridge-ui/public/js/credentials.js +99 -0
- package/dist/homebridge-ui/public/js/credentials.js.map +1 -0
- package/dist/homebridge-ui/public/js/credentials.ts +105 -0
- package/dist/homebridge-ui/public/js/devices-delete.d.ts +3 -0
- package/dist/homebridge-ui/public/js/devices-delete.d.ts.map +1 -0
- package/dist/homebridge-ui/public/js/devices-delete.js +199 -0
- package/dist/homebridge-ui/public/js/devices-delete.js.map +1 -0
- package/dist/homebridge-ui/public/js/devices-delete.ts +227 -0
- package/dist/homebridge-ui/public/js/devices.d.ts +9 -0
- package/dist/homebridge-ui/public/js/devices.d.ts.map +1 -0
- package/dist/homebridge-ui/public/js/devices.js +98 -0
- package/dist/homebridge-ui/public/js/devices.js.map +1 -0
- package/dist/homebridge-ui/public/js/devices.ts +106 -0
- package/dist/homebridge-ui/public/js/discovery.d.ts +9 -0
- package/dist/homebridge-ui/public/js/discovery.d.ts.map +1 -0
- package/dist/homebridge-ui/public/js/discovery.js +1201 -0
- package/dist/homebridge-ui/public/js/discovery.js.map +1 -0
- package/dist/homebridge-ui/public/js/discovery.ts +1335 -0
- package/dist/homebridge-ui/public/js/logger.d.ts +7 -0
- package/dist/homebridge-ui/public/js/logger.d.ts.map +1 -0
- package/dist/homebridge-ui/public/js/logger.js +17 -0
- package/dist/homebridge-ui/public/js/logger.js.map +1 -0
- package/dist/homebridge-ui/public/js/logger.ts +17 -0
- package/dist/homebridge-ui/public/js/modal.d.ts +5 -0
- package/dist/homebridge-ui/public/js/modal.d.ts.map +1 -0
- package/dist/homebridge-ui/public/js/modal.js +35 -0
- package/dist/homebridge-ui/public/js/modal.js.map +1 -0
- package/dist/homebridge-ui/public/js/modal.ts +35 -0
- package/dist/homebridge-ui/public/js/modals.d.ts +15 -0
- package/dist/homebridge-ui/public/js/modals.d.ts.map +1 -0
- package/dist/homebridge-ui/public/js/modals.js +675 -0
- package/dist/homebridge-ui/public/js/modals.js.map +1 -0
- package/dist/homebridge-ui/public/js/modals.ts +765 -0
- package/dist/homebridge-ui/public/js/render.d.ts +71 -0
- package/dist/homebridge-ui/public/js/render.d.ts.map +1 -0
- package/dist/homebridge-ui/public/js/render.js +960 -0
- package/dist/homebridge-ui/public/js/render.js.map +1 -0
- package/dist/homebridge-ui/public/js/render.ts +1084 -0
- package/dist/homebridge-ui/public/js/toast.d.ts +6 -0
- package/dist/homebridge-ui/public/js/toast.d.ts.map +1 -0
- package/dist/homebridge-ui/public/js/toast.js +38 -0
- package/dist/homebridge-ui/public/js/toast.js.map +1 -0
- package/dist/homebridge-ui/public/js/toast.ts +44 -0
- package/dist/homebridge-ui/public/js/types.d.ts +23 -0
- package/dist/homebridge-ui/public/js/types.d.ts.map +1 -0
- package/dist/homebridge-ui/public/js/types.js +2 -0
- package/dist/homebridge-ui/public/js/types.js.map +1 -0
- package/dist/homebridge-ui/public/js/types.ts +26 -0
- package/dist/homebridge-ui/server.d.ts +1 -3
- package/dist/homebridge-ui/server.d.ts.map +1 -1
- package/dist/homebridge-ui/server.js +8 -471
- package/dist/homebridge-ui/server.js.map +1 -1
- package/dist/homebridge-ui/settings.js +8 -0
- package/dist/homebridge-ui/settings.js.map +1 -0
- package/dist/homebridge-ui/switchbotClient.js +247 -0
- package/dist/homebridge-ui/switchbotClient.js.map +1 -0
- package/dist/homebridge-ui/utils/config-parser.d.ts +39 -0
- package/dist/homebridge-ui/utils/config-parser.d.ts.map +1 -0
- package/dist/homebridge-ui/utils/config-parser.js +108 -0
- package/dist/homebridge-ui/utils/config-parser.js.map +1 -0
- package/dist/homebridge-ui/utils/device-migration.d.ts +35 -0
- package/dist/homebridge-ui/utils/device-migration.d.ts.map +1 -0
- package/dist/homebridge-ui/utils/device-migration.js +111 -0
- package/dist/homebridge-ui/utils/device-migration.js.map +1 -0
- package/dist/homebridge-ui/utils/logger.d.ts +7 -0
- package/dist/homebridge-ui/utils/logger.d.ts.map +1 -0
- package/dist/homebridge-ui/utils/logger.js +17 -0
- package/dist/homebridge-ui/utils/logger.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -2
- package/dist/index.js.map +1 -1
- package/dist/settings.d.ts +1 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +1 -0
- package/dist/settings.js.map +1 -1
- package/dist/switchbotClient.d.ts +12 -10
- package/dist/switchbotClient.d.ts.map +1 -1
- package/dist/switchbotClient.js +156 -103
- package/dist/switchbotClient.js.map +1 -1
- package/dist/utils.d.ts +76 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1121 -4
- package/dist/utils.js.map +1 -1
- package/docs/assets/highlight.css +16 -2
- package/docs/assets/main.js +1 -1
- package/docs/index.html +82 -5
- package/docs/variables/default.html +3 -1
- package/eslint.config.js +9 -5
- package/nodemon.json +2 -2
- package/package.json +34 -21
- package/scripts/build-ui.js +37 -0
- package/scripts/free-dev-ports.mjs +105 -0
- package/scripts/generate-matter-maps.js +34 -17
- package/scripts/sync-device-types.mjs +31 -0
- package/src/SwitchBotHAPPlatform.ts +558 -0
- package/src/SwitchBotMatterPlatform.ts +538 -0
- package/src/device-types.js +246 -0
- package/src/device-types.js.map +1 -0
- package/src/device-types.ts +261 -0
- package/src/deviceCommandMapper.js +319 -0
- package/src/deviceCommandMapper.js.map +1 -0
- package/src/deviceCommandMapper.ts +333 -0
- package/src/deviceFactory.ts +125 -45
- package/src/devices/genericDevice.ts +411 -69
- package/src/errors.js +32 -0
- package/src/errors.js.map +1 -0
- package/src/errors.ts +35 -0
- package/src/homebridge-ui/endpoints/config.ts +110 -0
- package/src/homebridge-ui/endpoints/devices.ts +153 -0
- package/src/homebridge-ui/endpoints/discovery.ts +240 -0
- package/src/homebridge-ui/public/css/styles.css +483 -0
- package/src/homebridge-ui/public/index.html +197 -621
- package/src/homebridge-ui/public/js/advanced-settings.ts +94 -0
- package/src/homebridge-ui/public/js/api.ts +355 -0
- package/src/homebridge-ui/public/js/app.ts +22 -0
- package/src/homebridge-ui/public/js/constants.ts +1 -0
- package/src/homebridge-ui/public/js/credentials.ts +105 -0
- package/src/homebridge-ui/public/js/devices-delete.ts +227 -0
- package/src/homebridge-ui/public/js/devices.ts +106 -0
- package/src/homebridge-ui/public/js/discovery.ts +1335 -0
- package/src/homebridge-ui/public/js/logger.ts +17 -0
- package/src/homebridge-ui/public/js/modal.ts +35 -0
- package/src/homebridge-ui/public/js/modals.ts +765 -0
- package/src/homebridge-ui/public/js/render.ts +1084 -0
- package/src/homebridge-ui/public/js/toast.ts +44 -0
- package/src/homebridge-ui/public/js/types.ts +26 -0
- package/src/homebridge-ui/server.ts +9 -554
- package/src/homebridge-ui/utils/config-parser.ts +125 -0
- package/src/homebridge-ui/utils/device-migration.ts +144 -0
- package/src/homebridge-ui/utils/logger.ts +17 -0
- package/src/index.ts +12 -2
- package/src/settings.js +8 -0
- package/src/settings.js.map +1 -0
- package/src/settings.ts +2 -0
- package/src/switchbotClient.js +247 -0
- package/src/switchbotClient.js.map +1 -0
- package/src/switchbotClient.ts +177 -114
- package/src/utils.ts +1133 -5
- package/test/client/switchbot-client-debounce.spec.ts +35 -0
- package/test/client/switchbot-client-openapi.spec.ts +19 -0
- package/test/client/switchbotClient.spec.ts +64 -0
- package/test/device/device-mapping.spec.ts +23 -0
- package/test/device/deviceBase.spec.ts +26 -0
- package/test/device/deviceFactory-edge.spec.ts +15 -0
- package/test/device/deviceFactory.spec.ts +33 -0
- package/test/device/fan-swing.spec.ts +34 -0
- package/test/device/genericDevice-blepoll.spec.ts +47 -0
- package/test/device/irdevice.spec.ts +9 -0
- package/test/device/lock-users.spec.ts +35 -0
- package/test/device/matter-descriptors.spec.ts +22 -0
- package/test/device/matter-device-state.spec.ts +37 -0
- package/test/e2e/run-e2e.spec.ts +18 -19
- package/test/errors/errors.spec.ts +10 -0
- package/test/helpers/matter-harness.ts +20 -9
- package/test/homebridge-ui/server.spec.ts +9 -0
- package/test/platform/accessory-restore.spec.ts +37 -0
- package/test/platform/matter-childbridge.spec.ts +34 -0
- package/test/platform/matter-integration.spec.ts +33 -0
- package/test/platform/platform-edge.spec.ts +73 -0
- package/test/platform/platform.integration.spec.ts +34 -0
- package/test/utils/utils-extra.spec.ts +10 -0
- package/test/utils/utils.spec.ts +53 -0
- package/todo/TODO.md +80 -0
- package/tsconfig.ui.json +11 -0
- package/.github/npm-version-script-esm.js +0 -97
- package/.github/workflows/beta-release.yml +0 -52
- package/dist/platform.d.ts +0 -35
- package/dist/platform.d.ts.map +0 -1
- package/dist/platform.js +0 -945
- package/dist/platform.js.map +0 -1
- package/src/platform.ts +0 -963
- package/test/accessory-restore.spec.ts +0 -73
- package/test/device-mapping.spec.ts +0 -37
- package/test/deviceFactory.spec.ts +0 -18
- package/test/fan-swing.spec.ts +0 -29
- package/test/lock-users.spec.ts +0 -44
- package/test/matter-childbridge.spec.ts +0 -55
- package/test/matter-descriptors.spec.ts +0 -97
- package/test/matter-device-state.spec.ts +0 -101
- package/test/matter-integration.spec.ts +0 -70
- package/test/platform.integration.spec.ts +0 -55
- package/test/switchbot-client-debounce.spec.ts +0 -131
- package/test/switchbot-client-openapi.spec.ts +0 -56
- package/test/switchbotClient.spec.ts +0 -10
- package/test/utils.spec.ts +0 -20
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://unpkg.com/@changesets/config@2.3.0/schema.json",
|
|
3
|
+
"changelog": [
|
|
4
|
+
"@changesets/cli/changelog",
|
|
5
|
+
{ "repo": "OpenWonderLabs/homebridge-switchbot" }
|
|
6
|
+
],
|
|
7
|
+
"commit": false,
|
|
8
|
+
"fixed": [],
|
|
9
|
+
"linked": [],
|
|
10
|
+
"access": "public",
|
|
11
|
+
"baseBranch": "latest",
|
|
12
|
+
"updateInternalDependencies": "patch",
|
|
13
|
+
"ignore": []
|
|
14
|
+
}
|
|
@@ -2,6 +2,45 @@
|
|
|
2
2
|
|
|
3
3
|
Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.
|
|
4
4
|
|
|
5
|
+
## Topic-Based Reference Priority
|
|
6
|
+
|
|
7
|
+
When a prompt includes the topics below, consult these upstream references first before implementation decisions.
|
|
8
|
+
|
|
9
|
+
### Matter (keyword examples: "Matter", "child bridge", "cluster", "conformance")
|
|
10
|
+
|
|
11
|
+
Primary references:
|
|
12
|
+
- https://github.com/homebridge-plugins/homebridge-matter
|
|
13
|
+
- https://github.com/homebridge/homebridge/ - only if latest is 2.0.0 or later and contains Matter-related code or reference:
|
|
14
|
+
- https://github.com/homebridge/homebridge/tree/beta-2.0.0/
|
|
15
|
+
- https://github.com/matter-js/matter.js
|
|
16
|
+
|
|
17
|
+
Usage rule:
|
|
18
|
+
- For Matter behavior, conformance, clustering, or registration logic, align implementation with these references before applying local changes.
|
|
19
|
+
|
|
20
|
+
### SwitchBot BLE (keyword examples: "BLE", "Bluetooth", "RSSI", "advertisement", "scan")
|
|
21
|
+
|
|
22
|
+
Primary references:
|
|
23
|
+
- https://github.com/OpenWonderLabs/SwitchBotAPI-BLE
|
|
24
|
+
- https://github.com/sblibs/pySwitchbot
|
|
25
|
+
|
|
26
|
+
Usage rule:
|
|
27
|
+
- For BLE command/state/scan behavior, prefer these references for protocol expectations and payload shape.
|
|
28
|
+
|
|
29
|
+
### SwitchBot OpenAPI (keyword examples: "OpenAPI", "cloud API", "device list", "command")
|
|
30
|
+
|
|
31
|
+
Primary reference:
|
|
32
|
+
- https://github.com/OpenWonderLabs/SwitchBotAPI
|
|
33
|
+
|
|
34
|
+
Usage rule:
|
|
35
|
+
- For OpenAPI device models, commands, and response fields, prioritize this reference for compatibility.
|
|
36
|
+
|
|
37
|
+
### Conflict Resolution
|
|
38
|
+
|
|
39
|
+
If references conflict:
|
|
40
|
+
1. Prefer official upstream docs/API specs.
|
|
41
|
+
2. Keep existing plugin behavior unless a clear bug is identified.
|
|
42
|
+
3. Document any intentional deviation in PR notes.
|
|
43
|
+
|
|
5
44
|
## Branch Targeting Strategy
|
|
6
45
|
|
|
7
46
|
When creating pull requests, ALWAYS follow this branch targeting strategy:
|
package/.github/workflows/ci.yml
CHANGED
|
@@ -6,12 +6,15 @@ on:
|
|
|
6
6
|
pull_request:
|
|
7
7
|
branches: ["main", "latest"]
|
|
8
8
|
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
9
12
|
jobs:
|
|
10
13
|
build-and-test:
|
|
11
14
|
runs-on: ubuntu-latest
|
|
12
15
|
strategy:
|
|
13
16
|
matrix:
|
|
14
|
-
node-version: [
|
|
17
|
+
node-version: [22, 24]
|
|
15
18
|
|
|
16
19
|
steps:
|
|
17
20
|
- uses: actions/checkout@v4
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
name: Manual E2E (build + optional E2E)
|
|
2
2
|
|
|
3
|
+
permissions:
|
|
4
|
+
contents: read
|
|
5
|
+
|
|
3
6
|
on:
|
|
4
7
|
workflow_dispatch:
|
|
5
8
|
inputs:
|
|
@@ -43,12 +46,12 @@ jobs:
|
|
|
43
46
|
runs-on: ubuntu-latest
|
|
44
47
|
steps:
|
|
45
48
|
- name: Checkout
|
|
46
|
-
uses: actions/checkout@
|
|
49
|
+
uses: actions/checkout@v6
|
|
47
50
|
|
|
48
51
|
- name: Setup Node
|
|
49
|
-
uses: actions/setup-node@
|
|
52
|
+
uses: actions/setup-node@v6
|
|
50
53
|
with:
|
|
51
|
-
node-version: '
|
|
54
|
+
node-version: '22'
|
|
52
55
|
|
|
53
56
|
- name: Install dependencies
|
|
54
57
|
run: npm ci --prefer-offline --no-audit --progress=false
|
|
@@ -1,30 +1,78 @@
|
|
|
1
|
-
name:
|
|
1
|
+
name: Release
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
4
|
push:
|
|
5
5
|
branches:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
- latest
|
|
6
|
+
- 'beta-*'
|
|
7
|
+
- 'beta'
|
|
8
|
+
- 'latest'
|
|
9
9
|
workflow_dispatch:
|
|
10
10
|
|
|
11
11
|
jobs:
|
|
12
|
+
# ─── BETA RELEASE (branches starting with "beta") ────────────────────────────
|
|
13
|
+
|
|
14
|
+
# 1️⃣ Build and test
|
|
15
|
+
build_and_test:
|
|
16
|
+
if: startsWith(github.ref_name, 'beta')
|
|
17
|
+
uses: homebridge/.github/.github/workflows/nodejs-build-and-test.yml@latest
|
|
18
|
+
with:
|
|
19
|
+
enable_coverage: false
|
|
20
|
+
secrets:
|
|
21
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
22
|
+
|
|
23
|
+
# 2️⃣ Lint
|
|
24
|
+
lint:
|
|
25
|
+
if: startsWith(github.ref_name, 'beta')
|
|
26
|
+
needs: build_and_test
|
|
27
|
+
uses: homebridge/.github/.github/workflows/eslint.yml@latest
|
|
28
|
+
|
|
29
|
+
# 3️⃣ Publish beta to NPM (OIDC — id-token required here and in the reusable workflow)
|
|
30
|
+
beta-publish:
|
|
31
|
+
if: startsWith(github.ref_name, 'beta')
|
|
32
|
+
needs: lint
|
|
33
|
+
permissions:
|
|
34
|
+
id-token: write
|
|
35
|
+
uses: homebridge/.github/.github/workflows/npm-publish-esm-oidc.yml@latest
|
|
36
|
+
with:
|
|
37
|
+
tag: 'beta'
|
|
38
|
+
dynamically_adjust_version: true
|
|
39
|
+
npm_version_command: 'pre'
|
|
40
|
+
pre_id: 'beta'
|
|
41
|
+
|
|
42
|
+
# 4️⃣ Create GitHub pre-release
|
|
43
|
+
beta-pre-release:
|
|
44
|
+
if: startsWith(github.ref_name, 'beta')
|
|
45
|
+
needs: beta-publish
|
|
46
|
+
uses: homebridge/.github/.github/workflows/pre-release.yml@latest
|
|
47
|
+
with:
|
|
48
|
+
npm_version: ${{ needs.beta-publish.outputs.NPM_VERSION }}
|
|
49
|
+
body: |
|
|
50
|
+
**Beta Release**
|
|
51
|
+
**Version**: v${{ needs.beta-publish.outputs.NPM_VERSION }}
|
|
52
|
+
[How To Test Beta Releases](https://github.com/OpenWonderLabs/homebridge-switchbot/wiki/Beta-Version)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
# ─── STABLE RELEASE (branch: "latest") ───────────────────────────────────────
|
|
56
|
+
|
|
12
57
|
# 1️⃣ Determine release type, ESM status, and branch name
|
|
13
58
|
determine-release-type:
|
|
59
|
+
if: github.ref_name == 'latest'
|
|
14
60
|
uses: homebridge/.github/.github/workflows/determine-release-type.yml@latest
|
|
15
61
|
with:
|
|
16
62
|
ref_name: ${{ github.ref_name }}
|
|
17
63
|
|
|
18
64
|
# 2️⃣ Update version and changelog using the scripts
|
|
19
65
|
update-version:
|
|
66
|
+
if: github.ref_name == 'latest'
|
|
20
67
|
needs: determine-release-type
|
|
21
68
|
uses: homebridge/.github/.github/workflows/update-version.yml@latest
|
|
22
69
|
with:
|
|
23
70
|
release_type: ${{ needs.determine-release-type.outputs.release_type }}
|
|
24
71
|
is_esm: ${{ needs.determine-release-type.outputs.is_esm == 'true' }}
|
|
25
72
|
|
|
26
|
-
# 3️⃣ Publish to NPM and create GitHub release
|
|
73
|
+
# 3️⃣ Publish to NPM and create GitHub release (OIDC — id-token required here and in the reusable workflow)
|
|
27
74
|
publish-release:
|
|
75
|
+
if: github.ref_name == 'latest'
|
|
28
76
|
needs: [determine-release-type, update-version]
|
|
29
77
|
permissions:
|
|
30
78
|
id-token: write
|
|
@@ -39,17 +87,17 @@ jobs:
|
|
|
39
87
|
|
|
40
88
|
# 4️⃣ Promote branch if this is a prerelease (alpha/beta)
|
|
41
89
|
promote-branch:
|
|
90
|
+
if: ${{ github.ref_name == 'latest' && needs.determine-release-type.outputs.release_type != 'latest' && needs.determine-release-type.outputs.release_type != 'skip' }}
|
|
42
91
|
needs: [determine-release-type, publish-release]
|
|
43
|
-
if: ${{ needs.determine-release-type.outputs.release_type != 'latest' && needs.determine-release-type.outputs.release_type != 'skip' }}
|
|
44
92
|
uses: homebridge/.github/.github/workflows/promote-branch.yml@latest
|
|
45
93
|
with:
|
|
46
94
|
branch_name: ${{ needs.determine-release-type.outputs.branch_name }}
|
|
47
95
|
release_type: ${{ needs.determine-release-type.outputs.release_type }}
|
|
48
96
|
is_esm: ${{ needs.determine-release-type.outputs.is_esm == 'true' }}
|
|
49
97
|
|
|
50
|
-
# 5️⃣ Notify if any
|
|
98
|
+
# 5️⃣ Notify if any stable-release job fails
|
|
51
99
|
workflow-failure:
|
|
52
|
-
if:
|
|
100
|
+
if: failure()
|
|
53
101
|
needs: [determine-release-type, update-version, publish-release, promote-branch]
|
|
54
102
|
uses: homebridge/.github/.github/workflows/report-failure.yml@latest
|
|
55
103
|
with:
|
|
@@ -57,15 +105,16 @@ jobs:
|
|
|
57
105
|
job_name: ${{ github.job }}
|
|
58
106
|
run_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
|
59
107
|
|
|
60
|
-
# 6️⃣ Post to Discord
|
|
61
|
-
|
|
62
|
-
name:
|
|
63
|
-
|
|
108
|
+
# 6️⃣ Post to Discord (Beta + Stable)
|
|
109
|
+
discord:
|
|
110
|
+
name: Release Notifications
|
|
111
|
+
if: ${{ always() && ((startsWith(github.ref_name, 'beta') && needs.beta-publish.result == 'success') || (github.ref_name == 'latest' && needs.publish-release.result == 'success')) }}
|
|
112
|
+
needs: [beta-publish, update-version, publish-release]
|
|
64
113
|
uses: homebridge/.github/.github/workflows/discord-webhooks.yml@latest
|
|
65
114
|
with:
|
|
66
|
-
title:
|
|
115
|
+
title: ${{ startsWith(github.ref_name, 'beta') && 'Homebridge SwitchBot Beta Release' || 'Homebridge SwitchBot Release' }}
|
|
67
116
|
description: |
|
|
68
|
-
Version `v${{ needs.update-version.outputs.version }}`
|
|
69
|
-
url: "https://github.com/OpenWonderLabs/homebridge-switchbot/releases/tag/v${{ needs.update-version.outputs.version }}"
|
|
117
|
+
Version `v${{ startsWith(github.ref_name, 'beta') && needs.beta-publish.outputs.NPM_VERSION || needs.update-version.outputs.version }}`
|
|
118
|
+
url: "https://github.com/OpenWonderLabs/homebridge-switchbot/releases/tag/v${{ startsWith(github.ref_name, 'beta') && needs.beta-publish.outputs.NPM_VERSION || needs.update-version.outputs.version }}"
|
|
70
119
|
secrets:
|
|
71
120
|
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL_LATEST }}
|
|
@@ -3,12 +3,10 @@ name: Stale workflow
|
|
|
3
3
|
on:
|
|
4
4
|
workflow_dispatch:
|
|
5
5
|
schedule:
|
|
6
|
-
- cron: '45
|
|
6
|
+
- cron: '45 7 * * *'
|
|
7
7
|
|
|
8
8
|
jobs:
|
|
9
9
|
stale:
|
|
10
|
-
uses:
|
|
11
|
-
with:
|
|
12
|
-
days-before-issue-stale: 15
|
|
10
|
+
uses: homebridge/.github/.github/workflows/stale.yml@latest
|
|
13
11
|
secrets:
|
|
14
12
|
token: ${{ secrets.GITHUB_TOKEN }}
|
package/.husky/pre-push
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
. "$(dirname "$0")/_/husky.sh"
|
|
3
|
+
|
|
4
|
+
echo "Running changeset version before push..."
|
|
5
|
+
if npx @changesets/cli version --yes; then
|
|
6
|
+
git add package.json package-lock.json CHANGELOG.md || true
|
|
7
|
+
if ! git diff --staged --quiet; then
|
|
8
|
+
echo "Committing version and changelog updates"
|
|
9
|
+
git commit -m "chore(release): version packages [skip ci]" || true
|
|
10
|
+
else
|
|
11
|
+
echo "No version changes to commit"
|
|
12
|
+
fi
|
|
13
|
+
else
|
|
14
|
+
echo "changeset version failed or no changesets present"
|
|
15
|
+
fi
|