|
1 | 1 | name: Release |
2 | 2 |
|
3 | | -# To publish a new plugin version (to the npm 'latest' tag): |
4 | | -# 1. Update the version in package.json and package-lock.json and commit to the 'latest' branch |
5 | | -# 2. Create a new release on GitHub with the tag vX.Y.Z which points to the 'latest' branch |
6 | | -# 3. The release will trigger this workflow, which will publish the new version to npm |
| 3 | +# This workflow handles latest, beta, and alpha releases: |
| 4 | +# - Latest: Triggered by GitHub releases (tag vX.Y.Z) |
| 5 | +# - Beta: Triggered by pushes to beta-X.Y.Z branches |
| 6 | +# - Alpha: Triggered by pushes to alpha-X.Y.Z branches |
7 | 7 |
|
8 | 8 | on: |
9 | 9 | release: |
10 | 10 | types: [published] |
| 11 | + push: |
| 12 | + branches: |
| 13 | + - beta-*.*.* |
| 14 | + - alpha-*.*.* |
| 15 | + |
| 16 | +permissions: |
| 17 | + id-token: write |
| 18 | + contents: read |
11 | 19 |
|
12 | 20 | jobs: |
| 21 | + eslint: |
| 22 | + uses: homebridge/.github/.github/workflows/eslint.yml@latest |
| 23 | + |
13 | 24 | publish: |
14 | 25 | if: ${{ github.repository == 'homebridge-plugins/homebridge-tado' }} |
15 | | - permissions: |
16 | | - id-token: write |
17 | | - uses: homebridge/.github/.github/workflows/npm-publish-esm.yml@latest |
18 | | - secrets: |
19 | | - npm_auth_token: ${{ secrets.npm_token }} |
| 26 | + needs: eslint |
| 27 | + runs-on: ubuntu-latest |
| 28 | + steps: |
| 29 | + - name: Checkout code |
| 30 | + uses: actions/checkout@v5 |
| 31 | + |
| 32 | + - name: Setup Node.js |
| 33 | + uses: actions/setup-node@v6 |
| 34 | + with: |
| 35 | + node-version: 24 |
| 36 | + registry-url: "https://registry.npmjs.org" |
| 37 | + |
| 38 | + - name: Upgrade npm for OIDC support |
| 39 | + run: npm install -g npm@latest |
| 40 | + |
| 41 | + - name: Install dependencies |
| 42 | + run: npm ci |
| 43 | + |
| 44 | + - name: Determine release type |
| 45 | + id: release-type |
| 46 | + run: | |
| 47 | + if [[ "${{ github.event_name }}" == "release" ]]; then |
| 48 | + echo "type=latest" >> $GITHUB_OUTPUT |
| 49 | + echo "tag=latest" >> $GITHUB_OUTPUT |
| 50 | + elif [[ "${{ github.ref }}" == refs/heads/beta-* ]]; then |
| 51 | + echo "type=beta" >> $GITHUB_OUTPUT |
| 52 | + echo "tag=beta" >> $GITHUB_OUTPUT |
| 53 | + elif [[ "${{ github.ref }}" == refs/heads/alpha-* ]]; then |
| 54 | + echo "type=alpha" >> $GITHUB_OUTPUT |
| 55 | + echo "tag=alpha" >> $GITHUB_OUTPUT |
| 56 | + else |
| 57 | + echo "type=none" >> $GITHUB_OUTPUT |
| 58 | + echo "tag=none" >> $GITHUB_OUTPUT |
| 59 | + echo "No valid release type detected - skipping publish" |
| 60 | + fi |
| 61 | +
|
| 62 | + - name: Handle prerelease versioning |
| 63 | + if: steps.release-type.outputs.type == 'beta' || steps.release-type.outputs.type == 'alpha' |
| 64 | + run: | |
| 65 | + # Download versioning script from homebridge/.github |
| 66 | + mkdir -p .github |
| 67 | + wget -q https://raw.githubusercontent.com/homebridge/.github/latest/.github/npm-version-script-esm.js -O .github/npm-version-script-esm.js |
| 68 | +
|
| 69 | + # Run the script to set base version |
| 70 | + node .github/npm-version-script-esm.js ${{ github.ref }} ${{ steps.release-type.outputs.type }} |
| 71 | +
|
| 72 | + # Add prerelease suffix |
| 73 | + npm version pre --preid=${{ steps.release-type.outputs.type }} --no-git-tag-version |
| 74 | +
|
| 75 | + - name: Publish to npm with OIDC |
| 76 | + if: steps.release-type.outputs.type != 'none' |
| 77 | + run: npm publish --tag ${{ steps.release-type.outputs.tag }} --provenance --access public |
0 commit comments