v4.0.0 (#330) #66
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }} |