|
6 | 6 | - main |
7 | 7 | workflow_dispatch: |
8 | 8 | inputs: |
9 | | - npm_tag: |
10 | | - description: "npm dist-tag to publish under. Manual releases cannot use latest." |
11 | | - required: true |
12 | | - type: string |
| 9 | + publish_latest: |
| 10 | + description: "Retry a failed latest publish (skips pre-mode check, publishes whatever's in package.json under the 'latest' tag). Leave off for normal prerelease dispatch." |
| 11 | + required: false |
| 12 | + default: false |
| 13 | + type: boolean |
13 | 14 |
|
14 | 15 | concurrency: ${{ github.workflow }}-${{ github.ref }} |
15 | 16 |
|
@@ -48,29 +49,36 @@ jobs: |
48 | 49 | env: |
49 | 50 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
50 | 51 |
|
51 | | - - name: Validate manual npm tag |
| 52 | + - name: Validate dispatch mode |
52 | 53 | if: github.event_name == 'workflow_dispatch' |
53 | 54 | env: |
54 | | - NPM_TAG: ${{ inputs.npm_tag }} |
| 55 | + PUBLISH_LATEST: ${{ inputs.publish_latest }} |
55 | 56 | run: | |
56 | | - if [ "$NPM_TAG" = "latest" ]; then |
57 | | - echo "::error::Manual releases cannot publish to latest. Pushes to main publish to latest automatically." |
58 | | - exit 1 |
| 57 | + if [ "$PUBLISH_LATEST" = "true" ]; then |
| 58 | + if [ -f .changeset/pre.json ]; then |
| 59 | + echo "::error::publish_latest is true but .changeset/pre.json exists. Exit pre mode before publishing to latest." |
| 60 | + exit 1 |
| 61 | + fi |
| 62 | + echo "publish_latest=true: will publish under 'latest' (retry path)." |
| 63 | + exit 0 |
59 | 64 | fi |
60 | | - if ! echo "$NPM_TAG" | grep -Eq '^[a-z][a-z0-9-]*$'; then |
61 | | - echo "::error::npm_tag must match ^[a-z][a-z0-9-]*$." |
| 65 | + if [ ! -f .changeset/pre.json ]; then |
| 66 | + echo "::error::Prerelease dispatch requires changesets pre mode. Run 'npx changeset pre enter <tag>' on the branch first, or re-dispatch with publish_latest=true to retry a latest publish." |
62 | 67 | exit 1 |
63 | 68 | fi |
64 | 69 |
|
65 | 70 | - name: Build |
66 | 71 | if: github.event_name == 'workflow_dispatch' |
67 | 72 | run: npm run build |
68 | 73 |
|
69 | | - # Manual dispatch publishes packages from the selected ref that are not |
70 | | - # already on the registry under a non-latest npm dist-tag, for compatibility |
71 | | - # or preview channels. It does not retag already-published versions. |
72 | | - - name: Publish with manual npm tag |
73 | | - if: github.event_name == 'workflow_dispatch' |
74 | | - run: ./node_modules/.bin/changeset publish --tag "$NPM_TAG" |
75 | | - env: |
76 | | - NPM_TAG: ${{ inputs.npm_tag }} |
| 74 | + # Manual dispatch publishes whatever's already versioned on the branch. |
| 75 | + # In pre mode, the dist-tag comes from .changeset/pre.json. |
| 76 | + # With publish_latest=true, it retries a failed latest publish (--provenance |
| 77 | + # mirrors the push-trigger path). |
| 78 | + - name: Publish (prerelease) |
| 79 | + if: github.event_name == 'workflow_dispatch' && inputs.publish_latest != true |
| 80 | + run: ./node_modules/.bin/changeset publish |
| 81 | + |
| 82 | + - name: Publish (latest retry) |
| 83 | + if: github.event_name == 'workflow_dispatch' && inputs.publish_latest == true |
| 84 | + run: ./node_modules/.bin/changeset publish --provenance |
0 commit comments