diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9eacbb7..d39fc69 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,8 +17,6 @@ jobs: release: name: Release runs-on: ubuntu-latest - env: - HAS_NPM_TOKEN: ${{ secrets.NPM_TOKEN != '' }} steps: - uses: actions/checkout@v4 with: @@ -32,35 +30,13 @@ jobs: - run: pnpm install --frozen-lockfile # Without an npm token the job still opens version pull requests but # does not try to publish: a release is then published by hand. + # v2 reads the output of Changesets v3: v1 did not, so it pushed no tags + # and made no GitHub releases after publishing. - name: Create release pull request or publish - uses: changesets/action@v1 + uses: changesets/action@v2.1.2 with: - publish: ${{ secrets.NPM_TOKEN != '' && 'pnpm release' || '' }} + publish-script: ${{ secrets.NPM_TOKEN != '' && 'pnpm release' || '' }} + github-token: ${{ secrets.GITHUB_TOKEN }} env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} NPM_CONFIG_PROVENANCE: true - # changesets/action does not read @changesets/cli 3's publish output, so it - # neither pushes the tag nor makes the GitHub release: done here for the - # version in package.json once npm has it and the tag is missing. - - name: Tag and GitHub release of the published version - if: env.HAS_NPM_TOKEN == 'true' - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - name=$(node -p "require('./package.json').name") - version=$(node -p "require('./package.json').version") - tag="v$version" - if git ls-remote --exit-code --tags origin "refs/tags/$tag" >/dev/null; then - echo "$tag is already tagged"; exit 0 - fi - # npm may take a minute to show what was just published. - for i in $(seq 1 12); do - npm view "$name@$version" version >/dev/null 2>&1 && found=1 && break - sleep 15 - done - if [ -z "$found" ]; then echo "$name@$version is not on npm"; exit 0; fi - awk -v v="$version" '$0 == "## " v { f = 1; next } /^## / { if (f) exit } f' CHANGELOG.md > "$RUNNER_TEMP/notes.md" - git rev-parse -q --verify "refs/tags/$tag" >/dev/null || git tag "$tag" - git push origin "refs/tags/$tag" - gh release create "$tag" --verify-tag --title "$tag" --notes-file "$RUNNER_TEMP/notes.md" --latest