Skip to content

Commit 634b1a1

Browse files
committed
ci: add auto-versioning option to publish workflow
- Add version_type input with 'auto' as default - Auto mode uses conventional commits to determine version: - fix: → patch - feat: → minor - BREAKING CHANGE → major - Manual override still available (patch/minor/major) - Simplified workflow with only dry_run and version_type inputs
1 parent 8a6316a commit 634b1a1

1 file changed

Lines changed: 26 additions & 31 deletions

File tree

.github/workflows/publish.yml

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,17 @@ on:
44
workflow_dispatch:
55
inputs:
66
version_type:
7-
description: 'Version bump type'
7+
description: 'Version bump type (auto = determined by conventional commits)'
88
required: true
9-
default: 'patch'
9+
default: 'auto'
1010
type: choice
1111
options:
12+
- auto
1213
- patch
1314
- minor
1415
- major
15-
- prerelease
16-
prerelease_id:
17-
description: 'Prerelease identifier (e.g., alpha, beta, rc) - only used with prerelease'
18-
required: false
19-
default: ''
20-
type: string
2116
dry_run:
22-
description: 'Dry run (no actual publish, just preview)'
17+
description: 'Dry run (preview changes without publishing)'
2318
required: false
2419
default: false
2520
type: boolean
@@ -81,42 +76,49 @@ jobs:
8176
echo "=== DRY RUN MODE ==="
8277
echo ""
8378
echo "Version type: ${{ inputs.version_type }}"
84-
if [ -n "${{ inputs.prerelease_id }}" ]; then
85-
echo "Prerelease ID: ${{ inputs.prerelease_id }}"
79+
if [ "${{ inputs.version_type }}" == "auto" ]; then
80+
echo " (auto = determined by conventional commits)"
81+
echo " - fix: commits → patch bump"
82+
echo " - feat: commits → minor bump"
83+
echo " - BREAKING CHANGE → major bump"
8684
fi
8785
echo ""
8886
echo "=== Changed packages ==="
8987
npx lerna changed -l || echo "No packages changed"
9088
echo ""
91-
echo "=== What would be published ==="
92-
npx lerna version ${{ inputs.version_type }} --no-git-tag-version --no-push --yes 2>/dev/null || true
89+
echo "=== Preview version bumps ==="
90+
VERSION_ARG=""
91+
if [ "${{ inputs.version_type }}" != "auto" ]; then
92+
VERSION_ARG="${{ inputs.version_type }}"
93+
fi
94+
npx lerna version $VERSION_ARG --conventional-commits --no-git-tag-version --no-push --yes 2>/dev/null || true
95+
echo ""
96+
echo "=== Files that would change ==="
9397
git diff --name-only
9498
git checkout -- .
9599
96100
- name: Version packages
97101
if: inputs.dry_run == false && steps.check.outputs.changed == 'true'
98102
id: version
99103
run: |
100-
PREID_ARG=""
101-
if [ -n "${{ inputs.prerelease_id }}" ]; then
102-
PREID_ARG="--preid ${{ inputs.prerelease_id }}"
104+
# Determine version argument (empty for auto = let conventional commits decide)
105+
VERSION_ARG=""
106+
if [ "${{ inputs.version_type }}" != "auto" ]; then
107+
VERSION_ARG="${{ inputs.version_type }}"
103108
fi
104109
105110
# Version packages with conventional commits
106-
npx lerna version ${{ inputs.version_type }} \
111+
# When VERSION_ARG is empty (auto), lerna uses conventional commits to determine version:
112+
# fix: → patch, feat: → minor, BREAKING CHANGE → major
113+
npx lerna version $VERSION_ARG \
107114
--yes \
108115
--conventional-commits \
109116
--changelog-preset angular \
110-
--message "chore(release): publish %s" \
111-
$PREID_ARG
117+
--message "chore(release): publish"
112118
113119
# Get the new version for release notes
114120
NEW_VERSION=$(node -p "require('./lerna.json').version || 'independent'")
115121
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
116-
117-
# Get list of published packages for release notes
118-
PACKAGES=$(npx lerna ls --json | jq -r '.[].name' | tr '\n' ', ' | sed 's/,$//')
119-
echo "packages=$PACKAGES" >> $GITHUB_OUTPUT
120122
env:
121123
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
122124

@@ -183,17 +185,10 @@ jobs:
183185
# Get the latest tag created by lerna
184186
LATEST_TAG=$(git describe --tags --abbrev=0)
185187
186-
# Determine if this is a prerelease
187-
PRERELEASE_FLAG=""
188-
if [ -n "${{ inputs.prerelease_id }}" ]; then
189-
PRERELEASE_FLAG="--prerelease"
190-
fi
191-
192188
# Create the GitHub release
193189
gh release create "$LATEST_TAG" \
194190
--title "Release $LATEST_TAG" \
195-
--notes-file release_notes.md \
196-
$PRERELEASE_FLAG
191+
--notes-file release_notes.md
197192
env:
198193
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
199194

0 commit comments

Comments
 (0)