89 lines
2.9 KiB
YAML
89 lines
2.9 KiB
YAML
name: Create Release Branch
|
|
|
|
on:
|
|
pull_request:
|
|
types:
|
|
- closed
|
|
branches:
|
|
- main
|
|
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
|
|
jobs:
|
|
create-release-branch:
|
|
runs-on: ubuntu-latest
|
|
if: >
|
|
github.event.pull_request.merged == true &&
|
|
startsWith(github.event.pull_request.head.ref, 'version-bump/')
|
|
steps:
|
|
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
|
with:
|
|
ref: ${{ github.event.pull_request.merge_commit_sha }}
|
|
fetch-depth: 0
|
|
|
|
- uses: cashapp/activate-hermit@e49f5cb4dd64ff0b0b659d1d8df499595451155a # v1
|
|
- uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0
|
|
|
|
- name: Extract version and base branch
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
VERSION=$(just get-tag-version)
|
|
BASE_BRANCH="${{ github.event.pull_request.base.ref }}"
|
|
echo "version=$VERSION" >> $GITHUB_ENV
|
|
echo "base_branch=$BASE_BRANCH" >> $GITHUB_ENV
|
|
echo "Version: $VERSION"
|
|
echo "Base branch: $BASE_BRANCH"
|
|
|
|
PRIOR_TAG=$(just get-prior-version "$VERSION")
|
|
if [[ -z "$PRIOR_TAG" ]]; then
|
|
echo "No prior version (first release), using first commit"
|
|
PRIOR_TAG=$(git rev-list --max-parents=0 HEAD)
|
|
fi
|
|
echo "prior_ref=$PRIOR_TAG" >> $GITHUB_ENV
|
|
echo "Prior ref: $PRIOR_TAG"
|
|
|
|
- name: Create release branch
|
|
run: |
|
|
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
git config --local user.name "github-actions[bot]"
|
|
|
|
BRANCH_NAME="release/${{ env.version }}"
|
|
git switch -c "$BRANCH_NAME"
|
|
|
|
# Add an empty commit so GitHub can represent this as a PR
|
|
git commit --allow-empty --message "chore(release): open release branch for ${{ env.version }}"
|
|
|
|
git push origin "$BRANCH_NAME"
|
|
|
|
HEAD_REF=$(git rev-parse HEAD)
|
|
echo "branch_name=$BRANCH_NAME" >> $GITHUB_ENV
|
|
echo "head_ref=$HEAD_REF" >> $GITHUB_ENV
|
|
|
|
- name: Generate release notes
|
|
uses: ./.github/actions/generate-release-pr-body
|
|
with:
|
|
version: ${{ env.version }}
|
|
head_ref: ${{ env.head_ref }}
|
|
prior_ref: ${{ env.prior_ref }}
|
|
|
|
- name: Create Release PR
|
|
run: |
|
|
PR_URL=$(gh pr create \
|
|
-B "${{ env.base_branch }}" \
|
|
-H "${{ env.branch_name }}" \
|
|
--title "chore(release): release version ${{ env.version }}" \
|
|
--body-file pr_body.txt)
|
|
echo "pr_url=$PR_URL" >> $GITHUB_ENV
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Post release checklist comment
|
|
run: |
|
|
sed 's/{{VERSION}}/${{ env.version }}/g' RELEASE_CHECKLIST.md > checklist_comment.md
|
|
gh pr comment "${{ env.pr_url }}" --body-file checklist_comment.md
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|