|
9 | 9 | options: [angular, zone-js] |
10 | 10 | default: angular |
11 | 11 | version: |
12 | | - description: Version specifier (e.g. 22.0.0, patch, minor) |
| 12 | + description: Version specifier (e.g. 22.0.0, 22.0.0-rc.4, patch, minor) |
13 | 13 | required: true |
14 | 14 | dry-run: |
15 | 15 | description: Dry run (preview only, no push/publish) |
|
61 | 61 | ${{ inputs.dry-run && '--dry-run' || '' }} |
62 | 62 | env: |
63 | 63 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 64 | + # Prereleases (e.g. 22.0.0-rc.4) publish to their prerelease dist-tag (rc), |
| 65 | + # never latest. In a dry run keyword specifiers (patch/minor) resolve from |
| 66 | + # the unbumped manifest, so the previewed tag may differ from a real run. |
| 67 | + - name: Resolve npm dist-tag |
| 68 | + id: dist-tag |
| 69 | + shell: bash |
| 70 | + run: | |
| 71 | + set -euo pipefail |
| 72 | + spec='${{ inputs.version }}' |
| 73 | + if [[ "$spec" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then |
| 74 | + version="$spec" |
| 75 | + else |
| 76 | + version=$(node -p "require('./packages/${{ inputs.project }}/package.json').version") |
| 77 | + fi |
| 78 | + if [[ "$version" == *-* ]]; then |
| 79 | + pre="${version#*-}" |
| 80 | + tag="${pre%%.*}" |
| 81 | + if [[ "$tag" =~ ^[0-9]+$ ]]; then |
| 82 | + tag="next" |
| 83 | + fi |
| 84 | + else |
| 85 | + tag="latest" |
| 86 | + fi |
| 87 | + echo "Resolved version ${version} -> dist-tag ${tag}" |
| 88 | + echo "tag=${tag}" >> "$GITHUB_OUTPUT" |
64 | 89 | # OIDC trusted publishing (default): npm must find no token auth at all, |
65 | 90 | # otherwise it uses the token instead of the OIDC exchange. |
66 | 91 | - name: nx release publish (OIDC) |
|
79 | 104 |
|
80 | 105 | npx nx release publish \ |
81 | 106 | --groups=${{ inputs.project }} \ |
| 107 | + --tag "${{ steps.dist-tag.outputs.tag }}" \ |
82 | 108 | --access public \ |
83 | 109 | ${{ inputs.dry-run && '--dry-run' || '' }} |
84 | 110 | # Token fallback: only when explicitly enabled via repo variable USE_NPM_TOKEN=true. |
|
90 | 116 | run: > |
91 | 117 | npx nx release publish |
92 | 118 | --groups=${{ inputs.project }} |
| 119 | + --tag "${{ steps.dist-tag.outputs.tag }}" |
93 | 120 | --access public |
94 | 121 | ${{ inputs.dry-run && '--dry-run' || '' }} |
0 commit comments