Skip to content

Commit a06e310

Browse files
authored
fix: release branch publishing not to commit to main (#6275)
* fix: release branch publishing not to commit to main * use env var for branch name * use gh token as env
1 parent 24b36ff commit a06e310

1 file changed

Lines changed: 27 additions & 3 deletions

File tree

.github/workflows/release.yml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ concurrency:
1414
cancel-in-progress: true
1515

1616
env:
17+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1718
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
1819

1920
permissions:
2021
contents: write
2122
id-token: write
23+
pull-requests: write
2224

2325
jobs:
2426
release:
@@ -40,11 +42,33 @@ jobs:
4042
- name: Stop Nx Agents
4143
if: ${{ always() }}
4244
run: npx nx-cloud stop-all-agents
45+
- name: Prepare Release PR Branch
46+
id: release-branch
47+
run: |
48+
branch="release/${GITHUB_REF_NAME}/version-bump-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
49+
git switch -c "$branch"
50+
git push --set-upstream origin "$branch"
51+
echo "branch=$branch" >> "$GITHUB_OUTPUT"
4352
- name: Publish
4453
run: |
45-
git config --global user.name 'Tanner Linsley'
46-
git config --global user.email 'tannerlinsley@users.noreply.github.com'
54+
git config --global user.name 'github-actions[bot]'
55+
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
4756
pnpm run cipublish
4857
env:
49-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
BRANCH: ${{ github.ref_name }}
5059
TAG: ${{ inputs.tag }}
60+
- name: Open Version Bump Pull Request
61+
run: |
62+
if [[ "$(git rev-list --count "origin/${GITHUB_REF_NAME}..HEAD")" == "0" ]]; then
63+
echo "No version bump commit was created; skipping pull request."
64+
git push origin --delete "$RELEASE_BRANCH"
65+
exit 0
66+
fi
67+
68+
gh pr create \
69+
--base "$GITHUB_REF_NAME" \
70+
--head "$RELEASE_BRANCH" \
71+
--title "release: version packages" \
72+
--body "Automated version bump created after publishing packages."
73+
env:
74+
RELEASE_BRANCH: ${{ steps.release-branch.outputs.branch }}

0 commit comments

Comments
 (0)