Skip to content

Commit d0d98d9

Browse files
committed
chore: allow semver input for ci workflow
[skip ci]
1 parent 3f5461f commit d0d98d9

1 file changed

Lines changed: 24 additions & 13 deletions

File tree

.github/workflows/npm_release_cli.yml

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@ on:
1111
workflow_dispatch:
1212
inputs:
1313
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: ''
2324

2425
permissions: read-all
2526

@@ -62,17 +63,22 @@ jobs:
6263
echo NPM_VERSION=$NPM_VERSION >> $GITHUB_ENV
6364
6465
- 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 }}
6670
run: |
6771
git config user.name "github-actions[bot]"
6872
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"
7076
NPM_VERSION=$(node -e "console.log(require('./package.json').version);")
7177
echo NPM_VERSION=$NPM_VERSION >> $GITHUB_ENV
7278
git push origin HEAD:${GITHUB_REF_NAME} --follow-tags
7379
7480
- 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') }}
7682
env:
7783
NPM_TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.release_type == 'dev' && 'dev' || 'next' }}
7884
run: |
@@ -82,9 +88,14 @@ jobs:
8288
8389
- name: Output NPM Version and tag
8490
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' }}
8596
run: |
8697
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
8899
IS_RELEASE=true
89100
else
90101
IS_RELEASE=false

0 commit comments

Comments
 (0)