Skip to content

Commit 5c3a285

Browse files
fix release with pre tag
1 parent 7dd8047 commit 5c3a285

1 file changed

Lines changed: 27 additions & 19 deletions

File tree

.github/workflows/release.yaml

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ on:
66
- main
77
workflow_dispatch:
88
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
1314

1415
concurrency: ${{ github.workflow }}-${{ github.ref }}
1516

@@ -48,29 +49,36 @@ jobs:
4849
env:
4950
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5051

51-
- name: Validate manual npm tag
52+
- name: Validate dispatch mode
5253
if: github.event_name == 'workflow_dispatch'
5354
env:
54-
NPM_TAG: ${{ inputs.npm_tag }}
55+
PUBLISH_LATEST: ${{ inputs.publish_latest }}
5556
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
5964
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."
6267
exit 1
6368
fi
6469
6570
- name: Build
6671
if: github.event_name == 'workflow_dispatch'
6772
run: npm run build
6873

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

Comments
 (0)