Skip to content

Commit b096513

Browse files
committed
feat: Add branch selector to npm publish workflow
1 parent 7510b87 commit b096513

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

.github/workflows/publish.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ name: Publish to npm
33
on:
44
workflow_dispatch:
55
inputs:
6+
branch:
7+
description: 'Branch to publish from'
8+
type: choice
9+
options:
10+
- main
11+
- dev
12+
default: main
613
dry_run:
714
description: 'Dry run — show what would be published without actually publishing'
815
type: boolean
@@ -23,6 +30,8 @@ jobs:
2330
steps:
2431
- name: Checkout
2532
uses: actions/checkout@v4
33+
with:
34+
ref: ${{ inputs.branch }}
2635

2736
- name: Setup pnpm
2837
uses: pnpm/action-setup@v4
@@ -46,7 +55,7 @@ jobs:
4655
run: |
4756
PKG_VERSION=$(node -p "require('./package.json').version")
4857
REF_TYPE="${{ github.ref_type }}"
49-
BRANCH="${{ github.ref_name }}"
58+
BRANCH="${{ inputs.branch }}"
5059
5160
if [[ "$REF_TYPE" == "tag" ]]; then
5261
# Explicit tag (e.g. v1.2.3 or v1.2.3-rc.1) — always publish as latest
@@ -66,7 +75,7 @@ jobs:
6675
echo "channel=stable" >> $GITHUB_OUTPUT
6776
fi
6877
69-
elif [[ "$BRANCH" == "beta" || "$BRANCH" == "next" ]]; then
78+
elif [[ "$BRANCH" == "dev" || "$BRANCH" == "beta" || "$BRANCH" == "next" ]]; then
7079
# Pre-release branches — append date + short SHA so every commit gets a unique version
7180
SHORT_SHA=$(git rev-parse --short=7 HEAD)
7281
DATE=$(date -u +%Y%m%d)

0 commit comments

Comments
 (0)