|
9 | 9 | - '*-*' |
10 | 10 | workflow_dispatch: |
11 | 11 | inputs: |
12 | | - dist-tag: |
13 | | - description: "npm dist-tag to use (e.g. latest | next | canary)" |
| 12 | + release-type: |
| 13 | + description: "Version bump (patch/minor/major publish to npm 'latest'; prerelease uses 'preid')" |
| 14 | + required: false |
| 15 | + type: choice |
| 16 | + options: |
| 17 | + - prerelease |
| 18 | + - patch |
| 19 | + - minor |
| 20 | + - major |
| 21 | + default: prerelease |
| 22 | + preid: |
| 23 | + description: "Prerelease identifier (used only when release-type=prerelease; also becomes the npm dist-tag, e.g. next | canary)" |
14 | 24 | required: false |
15 | 25 | type: string |
16 | 26 | default: next |
@@ -83,23 +93,37 @@ jobs: |
83 | 93 | set -euo pipefail |
84 | 94 |
|
85 | 95 | if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then |
86 | | - dist_tag="${{ inputs['dist-tag'] }}" |
| 96 | + release_type="${{ inputs['release-type'] }}" |
| 97 | + preid="${{ inputs['preid'] }}" |
87 | 98 | scope="${{ inputs['release-group'] }}" |
88 | 99 | dry_run="${{ inputs['dry-run'] }}" |
89 | 100 | mode="dispatch" |
| 101 | +
|
| 102 | + # npm dist-tag follows release type: prerelease -> preid, stable -> latest |
| 103 | + if [[ "$release_type" == "prerelease" ]]; then |
| 104 | + dist_tag="$preid" |
| 105 | + else |
| 106 | + dist_tag="latest" |
| 107 | + fi |
90 | 108 | elif [[ "${GITHUB_REF}" == refs/tags/* ]]; then |
| 109 | + release_type="" |
| 110 | + preid="" |
91 | 111 | dist_tag="" |
92 | 112 | scope="" |
93 | 113 | dry_run="false" |
94 | 114 | mode="tag" |
95 | 115 | else |
| 116 | + release_type="prerelease" |
| 117 | + preid="next" |
96 | 118 | dist_tag="next" |
97 | 119 | scope="" |
98 | 120 | dry_run="false" |
99 | 121 | mode="main" |
100 | 122 | fi |
101 | 123 |
|
102 | 124 | echo "mode=${mode}" >> "$GITHUB_OUTPUT" |
| 125 | + echo "release_type=${release_type}" >> "$GITHUB_OUTPUT" |
| 126 | + echo "preid=${preid}" >> "$GITHUB_OUTPUT" |
103 | 127 | echo "dist_tag=${dist_tag}" >> "$GITHUB_OUTPUT" |
104 | 128 | echo "scope=${scope}" >> "$GITHUB_OUTPUT" |
105 | 129 | echo "dry_run=${dry_run}" >> "$GITHUB_OUTPUT" |
@@ -195,42 +219,56 @@ jobs: |
195 | 219 | if: ${{ steps.ctx.outputs.mode == 'main' && steps.affected.outputs.count == '0' }} |
196 | 220 | run: echo "No affected release projects on main; skipping version + publish." |
197 | 221 |
|
198 | | - - name: nx release version (dispatch) |
| 222 | + # Orchestrated release: bumps versions, generates changelogs, commits + tags + pushes in one shot. |
| 223 | + # --skip-publish keeps publishing as a separate step below so the OIDC token-clearing logic still runs. |
| 224 | + - name: nx release version + changelog (dispatch) |
199 | 225 | if: ${{ steps.ctx.outputs.mode == 'dispatch' && !inputs.dry-run }} |
200 | 226 | shell: bash |
201 | 227 | run: | |
202 | 228 | set -euo pipefail |
203 | 229 |
|
204 | 230 | scope="${{ steps.ctx.outputs.scope }}" |
| 231 | + projects_arg=() |
205 | 232 | if [[ -n "$scope" ]]; then |
206 | 233 | projects_arg=(--projects "$scope") |
207 | | - else |
208 | | - projects_arg=() |
209 | 234 | fi |
210 | 235 |
|
211 | | - npx nx release version prerelease \ |
212 | | - --preid "${{ steps.ctx.outputs.dist_tag }}" \ |
| 236 | + release_type="${{ steps.ctx.outputs.release_type }}" |
| 237 | + preid_arg=() |
| 238 | + if [[ "$release_type" == "prerelease" ]]; then |
| 239 | + preid_arg=(--preid "${{ steps.ctx.outputs.preid }}") |
| 240 | + fi |
| 241 | +
|
| 242 | + npx nx release "$release_type" \ |
| 243 | + "${preid_arg[@]}" \ |
213 | 244 | "${projects_arg[@]}" \ |
| 245 | + --skip-publish \ |
214 | 246 | --git-commit \ |
215 | 247 | --git-push \ |
216 | 248 | --verbose |
217 | 249 |
|
218 | | - - name: nx release version (dispatch, dry-run) |
| 250 | + - name: nx release version + changelog (dispatch, dry-run) |
219 | 251 | if: ${{ steps.ctx.outputs.mode == 'dispatch' && inputs.dry-run }} |
220 | 252 | shell: bash |
221 | 253 | run: | |
222 | 254 | set -euo pipefail |
223 | 255 |
|
224 | 256 | scope="${{ steps.ctx.outputs.scope }}" |
| 257 | + projects_arg=() |
225 | 258 | if [[ -n "$scope" ]]; then |
226 | 259 | projects_arg=(--projects "$scope") |
227 | | - else |
228 | | - projects_arg=() |
229 | 260 | fi |
230 | 261 |
|
231 | | - npx nx release version prerelease \ |
232 | | - --preid "${{ steps.ctx.outputs.dist_tag }}" \ |
| 262 | + release_type="${{ steps.ctx.outputs.release_type }}" |
| 263 | + preid_arg=() |
| 264 | + if [[ "$release_type" == "prerelease" ]]; then |
| 265 | + preid_arg=(--preid "${{ steps.ctx.outputs.preid }}") |
| 266 | + fi |
| 267 | +
|
| 268 | + npx nx release "$release_type" \ |
| 269 | + "${preid_arg[@]}" \ |
233 | 270 | "${projects_arg[@]}" \ |
| 271 | + --skip-publish \ |
234 | 272 | --verbose \ |
235 | 273 | --dry-run |
236 | 274 |
|
@@ -406,6 +444,8 @@ jobs: |
406 | 444 |
|
407 | 445 | echo "Nx Release completed." |
408 | 446 | echo "- mode: ${mode}" |
| 447 | + echo "- release-type: '${{ steps.ctx.outputs.release_type }}'" |
| 448 | + echo "- preid: '${{ steps.ctx.outputs.preid }}'" |
409 | 449 | echo "- dist-tag: ${{ steps.ctx.outputs.mode == 'tag' && steps.taginfo.outputs.dist_tag || steps.ctx.outputs.dist_tag }}" |
410 | 450 | echo "- scope: '${{ steps.ctx.outputs.scope }}'" |
411 | 451 | echo "- next-prerelease-allowlist: ${NEXT_PRERELEASE_PROJECT_ALLOWLIST}" |
|
0 commit comments