Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ concurrency:

permissions:
contents: write
pull-requests: write

jobs:
publish:
Expand Down Expand Up @@ -52,6 +53,10 @@ jobs:
git config user.email "github-actions[bot]@users.noreply.github.com"
npm version ${{ inputs.version }} --no-git-tag-version
VERSION=$(node -p "require('./package.json').version")
echo "VERSION=${VERSION}" >> "$GITHUB_ENV"
echo "RELEASE_BRANCH=release/v${VERSION}" >> "$GITHUB_ENV"
# main is protected (requires a PR), so commit to a release branch and merge via PR.
git switch -c "release/v${VERSION}"
git add package.json
git commit -m "release: v${VERSION}"
git tag "v${VERSION}"
Expand All @@ -66,8 +71,17 @@ jobs:
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Push version commit and tag
- name: Push release branch and tag, open auto-merge PR
if: ${{ inputs.dry-run != true }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git push origin main
git push origin "${RELEASE_BRANCH}"
git push origin --tags
gh pr create \
--base main \
--head "${RELEASE_BRANCH}" \
--title "release: v${VERSION}" \
--body "Automated version bump for v${VERSION}. Tag \`v${VERSION}\` already pushed; npm publish already completed. Merging this lands the bumped package.json on main."
# Land it through the protected branch's PR flow once required checks/approvals pass.
gh pr merge "${RELEASE_BRANCH}" --auto --squash --delete-branch
Loading