diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9f31b08..4d9425e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,6 +21,7 @@ on: permissions: contents: write + pull-requests: write jobs: release: @@ -50,11 +51,10 @@ jobs: - run: yarn build - # release-it pushes the version commit and the tag back to master, and - # actions/checkout leaves the branch without an upstream to push to. - - run: git branch --set-upstream-to=origin/${{ github.ref_name }} - + # Publishes to npm, pushes the annotated tag and creates the GitHub + # release. The version bump commit stays local, see .release-it.cjs. - name: Release + id: release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} @@ -74,3 +74,37 @@ jobs: fi yarn release $args + + echo "version=$(node -p "require('./package.json').version")" >> "$GITHUB_OUTPUT" + + # master requires status checks and a fresh commit has none, so the bump + # has to arrive as a PR. Merge commit, not squash: the tag points at the + # bump commit, and squashing would rewrite it and leave the tag off + # master's history, which breaks the next release's changelog range. + - name: Land the version bump on master + if: ${{ !inputs.dry-run }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + VERSION: ${{ steps.release.outputs.version }} + BASE: ${{ github.ref_name }} + REPO: ${{ github.repository }} + run: | + branch="chore/release-v$VERSION" + git push origin "HEAD:refs/heads/$branch" + + cat > /tmp/pr-body.md < !/^chore\(release\)/.test(commit.header ?? ""), + preset: { + name: "conventionalcommits", + types: [ + { type: "feat", section: "Features" }, + { type: "fix", section: "Bug Fixes" }, + { type: "perf", section: "Performance" }, + { type: "refactor", section: "Code Refactoring" }, + { type: "docs", section: "Documentation" }, + { type: "build", section: "Build System" }, + { type: "ci", section: "Continuous Integration" }, + { type: "chore", section: "Chores" }, + { type: "revert", section: "Reverts" }, + { type: "test", hidden: true }, + { type: "style", hidden: true }, + ], + }, + }, + }, +}; diff --git a/package.json b/package.json index 16747d8..9573a4a 100644 --- a/package.json +++ b/package.json @@ -45,79 +45,6 @@ "prettier": "^3.9.6", "release-it": "^21.0.0" }, - "release-it": { - "git": { - "requireBranch": "master", - "commitMessage": "chore(release): v${version} [skip ci]", - "tagName": "v${version}", - "tagAnnotation": "v${version}\n\n${changelog}", - "tagArgs": [ - "--cleanup=verbatim" - ] - }, - "npm": { - "publish": true - }, - "github": { - "release": true, - "releaseName": "v${version}" - }, - "plugins": { - "@release-it/conventional-changelog": { - "infile": "CHANGELOG.md", - "header": "# Changelog", - "preset": { - "name": "conventionalcommits", - "types": [ - { - "type": "feat", - "section": "Features" - }, - { - "type": "fix", - "section": "Bug Fixes" - }, - { - "type": "perf", - "section": "Performance" - }, - { - "type": "refactor", - "section": "Code Refactoring" - }, - { - "type": "docs", - "section": "Documentation" - }, - { - "type": "build", - "section": "Build System" - }, - { - "type": "ci", - "section": "Continuous Integration" - }, - { - "type": "chore", - "section": "Chores" - }, - { - "type": "revert", - "section": "Reverts" - }, - { - "type": "test", - "hidden": true - }, - { - "type": "style", - "hidden": true - } - ] - } - } - } - }, "resolutions": { "**/@expo/plist/@xmldom/xmldom": "0.8.13", "**/@typescript-eslint/typescript-estree/minimatch": "9.0.7",