|
4 | 4 | workflow_dispatch: |
5 | 5 | inputs: |
6 | 6 | version_type: |
7 | | - description: 'Version bump type' |
| 7 | + description: 'Version bump type (auto = determined by conventional commits)' |
8 | 8 | required: true |
9 | | - default: 'patch' |
| 9 | + default: 'auto' |
10 | 10 | type: choice |
11 | 11 | options: |
| 12 | + - auto |
12 | 13 | - patch |
13 | 14 | - minor |
14 | 15 | - 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 |
21 | 16 | dry_run: |
22 | | - description: 'Dry run (no actual publish, just preview)' |
| 17 | + description: 'Dry run (preview changes without publishing)' |
23 | 18 | required: false |
24 | 19 | default: false |
25 | 20 | type: boolean |
@@ -81,42 +76,49 @@ jobs: |
81 | 76 | echo "=== DRY RUN MODE ===" |
82 | 77 | echo "" |
83 | 78 | 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" |
86 | 84 | fi |
87 | 85 | echo "" |
88 | 86 | echo "=== Changed packages ===" |
89 | 87 | npx lerna changed -l || echo "No packages changed" |
90 | 88 | 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 ===" |
93 | 97 | git diff --name-only |
94 | 98 | git checkout -- . |
95 | 99 |
|
96 | 100 | - name: Version packages |
97 | 101 | if: inputs.dry_run == false && steps.check.outputs.changed == 'true' |
98 | 102 | id: version |
99 | 103 | 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 }}" |
103 | 108 | fi |
104 | 109 |
|
105 | 110 | # 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 \ |
107 | 114 | --yes \ |
108 | 115 | --conventional-commits \ |
109 | 116 | --changelog-preset angular \ |
110 | | - --message "chore(release): publish %s" \ |
111 | | - $PREID_ARG |
| 117 | + --message "chore(release): publish" |
112 | 118 |
|
113 | 119 | # Get the new version for release notes |
114 | 120 | NEW_VERSION=$(node -p "require('./lerna.json').version || 'independent'") |
115 | 121 | 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 |
120 | 122 | env: |
121 | 123 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
122 | 124 |
|
@@ -183,17 +185,10 @@ jobs: |
183 | 185 | # Get the latest tag created by lerna |
184 | 186 | LATEST_TAG=$(git describe --tags --abbrev=0) |
185 | 187 |
|
186 | | - # Determine if this is a prerelease |
187 | | - PRERELEASE_FLAG="" |
188 | | - if [ -n "${{ inputs.prerelease_id }}" ]; then |
189 | | - PRERELEASE_FLAG="--prerelease" |
190 | | - fi |
191 | | -
|
192 | 188 | # Create the GitHub release |
193 | 189 | gh release create "$LATEST_TAG" \ |
194 | 190 | --title "Release $LATEST_TAG" \ |
195 | | - --notes-file release_notes.md \ |
196 | | - $PRERELEASE_FLAG |
| 191 | + --notes-file release_notes.md |
197 | 192 | env: |
198 | 193 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
199 | 194 |
|
|
0 commit comments