|
11 | 11 | workflow_dispatch: |
12 | 12 | inputs: |
13 | 13 | release_type: |
14 | | - description: 'Release type. "dev" publishes a -next prerelease without bumping package.json. patch/minor/major/prerelease bump package.json, commit + tag to main, then publish as a stable release.' |
15 | | - type: choice |
16 | | - options: |
17 | | - - dev |
18 | | - - patch |
19 | | - - minor |
20 | | - - major |
21 | | - - prerelease |
22 | | - default: patch |
| 14 | + description: >- |
| 15 | + Release to cut. Leave empty for a rolling "next" prerelease (no version |
| 16 | + bump). "dev" publishes a -dev prerelease (no bump). A semver keyword |
| 17 | + (patch/minor/major) or an explicit version (e.g. 9.1.0, 9.1.0-alpha.1) |
| 18 | + bumps package.json, commits + tags v<version>, then publishes a stable |
| 19 | + release. A prerelease version publishes under the dist-tag matching its |
| 20 | + prerelease id (alpha/beta/rc); a plain version publishes under "latest". |
| 21 | + type: string |
| 22 | + required: false |
| 23 | + default: '' |
23 | 24 |
|
24 | 25 | permissions: read-all |
25 | 26 |
|
@@ -62,17 +63,22 @@ jobs: |
62 | 63 | echo NPM_VERSION=$NPM_VERSION >> $GITHUB_ENV |
63 | 64 |
|
64 | 65 | - name: Bump, commit and tag stable release (manual dispatch) |
65 | | - if: ${{ github.event_name == 'workflow_dispatch' && inputs.release_type != 'dev' }} |
| 66 | + if: ${{ github.event_name == 'workflow_dispatch' && inputs.release_type != '' && inputs.release_type != 'dev' }} |
| 67 | + env: |
| 68 | + # env indirection keeps the free-text dispatch input out of shell interpolation |
| 69 | + RELEASE_INPUT: ${{ inputs.release_type }} |
66 | 70 | run: | |
67 | 71 | git config user.name "github-actions[bot]" |
68 | 72 | git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
69 | | - npm version ${{ inputs.release_type }} -m "chore: release v%s" |
| 73 | + # npm version accepts a semver keyword (patch/minor/major) or an explicit |
| 74 | + # version; strip an optional leading "v" so v9.1.0 and 9.1.0 both work. |
| 75 | + npm version "${RELEASE_INPUT#v}" -m "chore: release v%s" |
70 | 76 | NPM_VERSION=$(node -e "console.log(require('./package.json').version);") |
71 | 77 | echo NPM_VERSION=$NPM_VERSION >> $GITHUB_ENV |
72 | 78 | git push origin HEAD:${GITHUB_REF_NAME} --follow-tags |
73 | 79 |
|
74 | 80 | - name: Bump version for dev release |
75 | | - if: ${{ !contains(github.ref, 'refs/tags/') && (github.event_name != 'workflow_dispatch' || inputs.release_type == 'dev') }} |
| 81 | + if: ${{ !contains(github.ref, 'refs/tags/') && (github.event_name != 'workflow_dispatch' || inputs.release_type == '' || inputs.release_type == 'dev') }} |
76 | 82 | env: |
77 | 83 | NPM_TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.release_type == 'dev' && 'dev' || 'next' }} |
78 | 84 | run: | |
|
82 | 88 |
|
83 | 89 | - name: Output NPM Version and tag |
84 | 90 | id: npm_version_output |
| 91 | + env: |
| 92 | + # true only for a manual dispatch that cut a real (bumped) release — not |
| 93 | + # the empty "next" build or the "dev" channel. Computed in the GitHub |
| 94 | + # expression context so the free-text input never reaches the shell. |
| 95 | + IS_DISPATCH_RELEASE: ${{ github.event_name == 'workflow_dispatch' && inputs.release_type != '' && inputs.release_type != 'dev' }} |
85 | 96 | run: | |
86 | 97 | NPM_TAG=$(node ./scripts/get-npm-tag.js) |
87 | | - if [[ "${GITHUB_REF}" == refs/tags/* ]] || [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ inputs.release_type }}" != "dev" ]]; then |
| 98 | + if [[ "${GITHUB_REF}" == refs/tags/* ]] || [[ "$IS_DISPATCH_RELEASE" == "true" ]]; then |
88 | 99 | IS_RELEASE=true |
89 | 100 | else |
90 | 101 | IS_RELEASE=false |
|
0 commit comments