|
29 | 29 | - run: pnpm install |
30 | 30 |
|
31 | 31 | - name: Create release PR or publish |
| 32 | + id: changesets |
32 | 33 | uses: changesets/action@v1 |
33 | 34 | with: |
34 | 35 | version: pnpm run version |
|
38 | 39 | env: |
39 | 40 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
40 | 41 | NPM_CONFIG_PROVENANCE: true |
| 42 | + |
| 43 | + # While in `pre` mode, changesets publishes under `--tag rc`, leaving |
| 44 | + # `npm install <pkg>` stuck on whatever was on `latest` first. Since RCs |
| 45 | + # are what users are installing today, re-point `latest` (and `rc`) at |
| 46 | + # every just-published version, and force the wrapper's GitHub release |
| 47 | + # to be the repo's Latest (GitHub otherwise skips prereleases). |
| 48 | + - name: Promote published RCs to npm latest + GitHub Latest |
| 49 | + if: steps.changesets.outputs.published == 'true' |
| 50 | + env: |
| 51 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 52 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 53 | + PUBLISHED: ${{ steps.changesets.outputs.publishedPackages }} |
| 54 | + run: | |
| 55 | + set -euo pipefail |
| 56 | + echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc |
| 57 | + echo "$PUBLISHED" | jq -c '.[]' | while read -r pkg; do |
| 58 | + name=$(echo "$pkg" | jq -r '.name') |
| 59 | + version=$(echo "$pkg" | jq -r '.version') |
| 60 | + echo "Promoting ${name}@${version} -> latest, rc" |
| 61 | + npm dist-tag add "${name}@${version}" latest |
| 62 | + npm dist-tag add "${name}@${version}" rc |
| 63 | + if [ "$name" = "ciderpress" ]; then |
| 64 | + echo "Marking ${name}@${version} as GitHub Latest" |
| 65 | + gh release edit "${name}@${version}" --prerelease=false --latest=true --repo "$GITHUB_REPOSITORY" |
| 66 | + fi |
| 67 | + done |
0 commit comments