|
1 | | -name: Release |
| 1 | +name: Unified Release |
2 | 2 |
|
3 | 3 | on: |
4 | | - release: |
5 | | - types: [published] |
| 4 | + push: |
| 5 | + branches: |
| 6 | + #- "alpha-*" |
| 7 | + #- "beta-*" |
| 8 | + - latest |
| 9 | + workflow_dispatch: |
6 | 10 |
|
7 | 11 | jobs: |
8 | | - build_and_test: |
9 | | - uses: homebridge/.github/.github/workflows/nodejs-build-and-test.yml@latest |
| 12 | + # 1️⃣ Determine release type, ESM status, and branch name |
| 13 | + determine-release-type: |
| 14 | + uses: homebridge/.github/.github/workflows/determine-release-type.yml@latest |
10 | 15 | with: |
11 | | - enable_coverage: false |
| 16 | + ref_name: ${{ github.ref_name }} |
| 17 | + |
| 18 | + # 2️⃣ Update version and changelog using the scripts |
| 19 | + update-version: |
| 20 | + needs: determine-release-type |
| 21 | + uses: homebridge/.github/.github/workflows/update-version.yml@latest |
| 22 | + with: |
| 23 | + release_type: ${{ needs.determine-release-type.outputs.release_type }} |
| 24 | + is_esm: ${{ needs.determine-release-type.outputs.is_esm == 'true' }} |
12 | 25 | secrets: |
13 | | - token: ${{ secrets.GITHUB_TOKEN }} |
| 26 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
14 | 27 |
|
15 | | - publish: |
16 | | - needs: build_and_test |
17 | | - if: ${{ github.repository == 'homebridge-plugins/homebridge-rainbird' }} |
| 28 | + # 3️⃣ Publish to NPM and create GitHub release |
| 29 | + publish-release: |
| 30 | + needs: [determine-release-type, update-version] |
18 | 31 | permissions: |
19 | 32 | id-token: write |
20 | | - uses: homebridge/.github/.github/workflows/npm-publish-esm.yml@latest |
| 33 | + contents: write |
| 34 | + uses: homebridge/.github/.github/workflows/publish-release.yml@latest |
| 35 | + with: |
| 36 | + release_type: ${{ needs.determine-release-type.outputs.release_type }} |
| 37 | + version: ${{ needs.update-version.outputs.version }} |
| 38 | + is_esm: ${{ needs.determine-release-type.outputs.is_esm == 'true' }} |
| 39 | + secrets: |
| 40 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 41 | + |
| 42 | + # 4️⃣ Promote branch if this is a prerelease (alpha/beta) |
| 43 | + promote-branch: |
| 44 | + needs: [determine-release-type, publish-release] |
| 45 | + if: ${{ needs.determine-release-type.outputs.release_type != 'latest' && needs.determine-release-type.outputs.release_type != 'skip' }} |
| 46 | + uses: homebridge/.github/.github/workflows/promote-branch.yml@latest |
| 47 | + with: |
| 48 | + branch_name: ${{ needs.determine-release-type.outputs.branch_name }} |
| 49 | + release_type: ${{ needs.determine-release-type.outputs.release_type }} |
| 50 | + is_esm: ${{ needs.determine-release-type.outputs.is_esm == 'true' }} |
21 | 51 | secrets: |
22 | | - npm_auth_token: ${{ secrets.npm_token }} |
| 52 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 53 | + |
| 54 | + # 5️⃣ Notify if any previous job fails |
| 55 | + workflow-failure: |
| 56 | + if: ${{ failure() }} |
| 57 | + needs: [determine-release-type, update-version, publish-release, promote-branch] |
| 58 | + uses: homebridge/.github/.github/workflows/report-failure.yml@latest |
| 59 | + with: |
| 60 | + workflow_name: ${{ github.workflow }} |
| 61 | + job_name: ${{ github.job }} |
| 62 | + run_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} |
23 | 63 |
|
| 64 | + # 6️⃣ Post to Discord |
24 | 65 | github-releases-to-discord: |
25 | 66 | name: Discord Webhooks |
26 | | - needs: [build_and_test,publish] |
27 | | - if: ${{ github.repository == 'homebridge-plugins/homebridge-rainbird' }} |
| 67 | + needs: [determine-release-type, update-version, publish-release] |
28 | 68 | uses: homebridge/.github/.github/workflows/discord-webhooks.yml@latest |
29 | 69 | with: |
30 | | - title: "RainBird Release" |
| 70 | + title: "Rainbird Release" |
31 | 71 | description: | |
32 | | - Version `v${{ needs.publish.outputs.NPM_VERSION }}` |
33 | | - url: "https://github.com/homebridge-plugins/homebridge-rainbird/releases/tag/v${{ needs.publish.outputs.NPM_VERSION }}" |
| 72 | + Version `v${{ needs.update-version.outputs.version }}` |
| 73 | + url: "https://github.com/homebridge-plugins/homebridge-rainbird/releases/tag/v${{ needs.update-version.outputs.version }}" |
34 | 74 | secrets: |
35 | 75 | DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL_LATEST }} |
0 commit comments