diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8ff742f335..d5095a3043 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,11 +14,13 @@ concurrency: cancel-in-progress: true env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} permissions: contents: write id-token: write + pull-requests: write jobs: release: @@ -40,11 +42,33 @@ jobs: - name: Stop Nx Agents if: ${{ always() }} run: npx nx-cloud stop-all-agents + - name: Prepare Release PR Branch + id: release-branch + run: | + branch="release/${GITHUB_REF_NAME}/version-bump-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" + git switch -c "$branch" + git push --set-upstream origin "$branch" + echo "branch=$branch" >> "$GITHUB_OUTPUT" - name: Publish run: | - git config --global user.name 'Tanner Linsley' - git config --global user.email 'tannerlinsley@users.noreply.github.com' + git config --global user.name 'github-actions[bot]' + git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com' pnpm run cipublish env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH: ${{ github.ref_name }} TAG: ${{ inputs.tag }} + - name: Open Version Bump Pull Request + run: | + if [[ "$(git rev-list --count "origin/${GITHUB_REF_NAME}..HEAD")" == "0" ]]; then + echo "No version bump commit was created; skipping pull request." + git push origin --delete "$RELEASE_BRANCH" + exit 0 + fi + + gh pr create \ + --base "$GITHUB_REF_NAME" \ + --head "$RELEASE_BRANCH" \ + --title "release: version packages" \ + --body "Automated version bump created after publishing packages." + env: + RELEASE_BRANCH: ${{ steps.release-branch.outputs.branch }}