|
17 | 17 | - ".github/workflows/release.yml" |
18 | 18 | workflow_dispatch: |
19 | 19 | inputs: |
| 20 | + release_intent: |
| 21 | + description: "What should this manual run do?" |
| 22 | + required: true |
| 23 | + type: choice |
| 24 | + options: |
| 25 | + - version-pr |
| 26 | + - publish |
| 27 | + default: version-pr |
| 28 | + force_publish: |
| 29 | + description: "Allow manual publish even when version-bump detection is false (use for reruns/recovery)" |
| 30 | + required: false |
| 31 | + type: boolean |
| 32 | + default: false |
20 | 33 | version_type: |
21 | 34 | description: 'Version bump type (major/minor/patch)' |
22 | 35 | required: false |
@@ -100,18 +113,39 @@ jobs: |
100 | 113 |
|
101 | 114 | echo "has_version_bumps=${has_version_bumps}" >> "$GITHUB_OUTPUT" |
102 | 115 |
|
| 116 | + - name: Validate manual release intent prerequisites |
| 117 | + if: github.event_name == 'workflow_dispatch' |
| 118 | + shell: bash |
| 119 | + run: | |
| 120 | + set -euo pipefail |
| 121 | + intent="${{ inputs.release_intent }}" |
| 122 | + has_changesets="${{ steps.detect.outputs.has_changesets }}" |
| 123 | + has_version_bumps="${{ steps.detect.outputs.has_version_bumps }}" |
| 124 | + force_publish="${{ inputs.force_publish }}" |
| 125 | +
|
| 126 | + if [ "$intent" = "version-pr" ] && [ "$has_changesets" != "true" ]; then |
| 127 | + echo "Manual intent 'version-pr' requires at least one .changeset/*.md file in this commit." |
| 128 | + exit 1 |
| 129 | + fi |
| 130 | +
|
| 131 | + if [ "$intent" = "publish" ] && [ "$has_version_bumps" != "true" ] && [ "$force_publish" != "true" ]; then |
| 132 | + echo "Manual intent 'publish' requires package.json/CHANGELOG.md version bump changes." |
| 133 | + echo "If you are rerunning/recovering a failed publish from master, re-run with force_publish=true." |
| 134 | + exit 1 |
| 135 | + fi |
| 136 | +
|
103 | 137 | - name: Stop early (no changesets / no version bumps) |
104 | 138 | if: github.event_name != 'workflow_dispatch' && steps.detect.outputs.has_changesets != 'true' && steps.detect.outputs.has_version_bumps != 'true' |
105 | 139 | run: | |
106 | 140 | echo "No .changeset files and no package version/changelog updates in this push. Skipping release." |
107 | 141 | exit 0 |
108 | 142 |
|
109 | 143 | - name: Build packages (publish runs only) |
110 | | - if: github.event_name == 'workflow_dispatch' || steps.detect.outputs.has_version_bumps == 'true' |
| 144 | + if: (github.event_name == 'workflow_dispatch' && inputs.release_intent == 'publish') || (github.event_name != 'workflow_dispatch' && steps.detect.outputs.has_version_bumps == 'true') |
111 | 145 | run: bun run build |
112 | 146 |
|
113 | 147 | - name: Run tests (publish runs only) |
114 | | - if: github.event_name == 'workflow_dispatch' || steps.detect.outputs.has_version_bumps == 'true' |
| 148 | + if: (github.event_name == 'workflow_dispatch' && inputs.release_intent == 'publish') || (github.event_name != 'workflow_dispatch' && steps.detect.outputs.has_version_bumps == 'true') |
115 | 149 | run: bun run test |
116 | 150 |
|
117 | 151 | - name: Create Release Pull Request or Publish to NPM |
|
0 commit comments