|
1 | 1 | # This workflow handles two flows: |
2 | 2 | # |
3 | 3 | # 1. Normal release (default) |
4 | | -# Triggered by pushes to `main`. Uses changesets/action to either open a |
5 | | -# "Version Packages" PR or, when such a PR is merged, publish to npm. |
| 4 | +# Triggered only by pushes to `main` (not by manual workflow runs). |
| 5 | +# Uses changesets/action to either open a "Version Packages" PR or, when such |
| 6 | +# a PR is merged, publish to npm. |
6 | 7 | # |
7 | 8 | # 2. Snapshot release (manual, opt-in) |
8 | 9 | # Triggered by running this workflow via workflow_dispatch with the |
|
54 | 55 | workflow_dispatch: |
55 | 56 | inputs: |
56 | 57 | snapshot: |
57 | | - description: "Publish a snapshot release from the selected branch (under the `snapshot` dist-tag) instead of running the normal release flow. Requires a changeset on the branch." |
| 58 | + description: "Manual runs must enable this to publish (snapshot dist-tag from the selected branch); otherwise the workflow fails. Stable versioning/publish runs only on push to main. Requires a changeset on the branch." |
58 | 59 | type: boolean |
59 | 60 | default: false |
60 | 61 |
|
|
85 | 86 | - name: Install Dependencies |
86 | 87 | run: pnpm install |
87 | 88 |
|
88 | | - # ----- Normal release (push to main, or manual run without snapshot) ----- |
| 89 | + - name: Disallow manual non-snapshot release |
| 90 | + if: ${{ github.event_name == 'workflow_dispatch' && inputs.snapshot != true }} |
| 91 | + run: | |
| 92 | + echo "::error::Stable releases (changesets version/publish) run only on push to main. For a manual run, enable the snapshot input." |
| 93 | + exit 1 |
| 94 | +
|
| 95 | + # ----- Normal release (push to main only) ----- |
89 | 96 | - name: Create Release Pull Request or Publish to npm |
90 | | - if: ${{ inputs.snapshot != true }} |
| 97 | + if: ${{ github.event_name == 'push' }} |
91 | 98 | id: changesets |
92 | 99 | uses: changesets/action@v1 |
93 | 100 | with: |
|
0 commit comments