Create Release Branch #26
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create Release Branch | |
on: | |
workflow_dispatch: | |
inputs: | |
release_version: | |
description: 'Which version are we creating a release branch for?' | |
required: true | |
from_branch: | |
description: 'Which branch to source release branch from? (default: master)' | |
required: false | |
default: 'master' | |
jobs: | |
create-release-branch: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: validate version | |
run: echo "${{github.event.inputs.release_version}}" | grep -E 'v[0-9]+\.[0-9]+\.[0-9]+$' | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{github.event.inputs.from_branch}} | |
- name: create branch | |
run: | | |
git remote -v | |
git checkout -b release-${{github.event.inputs.release_version}} | |
git push origin release-${{github.event.inputs.release_version}} | |
generate-release-changelog: | |
needs: create-release-branch | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: release-${{github.event.inputs.release_version}} | |
fetch-depth: 0 | |
- name: setup git | |
run: | | |
git config user.name "GitHub Actions Bot" | |
git config user.email "<>" | |
- name: install go | |
uses: actions/setup-go@v3 | |
with: | |
go-version-file: 'go.mod' | |
- name: install git-chglog | |
run: GOBIN=${GITHUB_WORKSPACE} go install github.com/git-chglog/git-chglog/cmd/[email protected] | |
- name: generate release notes | |
run: | | |
git tag ${{github.event.inputs.release_version}} | |
${GITHUB_WORKSPACE}/git-chglog --tag-filter-pattern 'v\d+\.\d+\.\d+$' --output releases/CHANGELOG-${{github.event.inputs.release_version}}.md ${{github.event.inputs.release_version}} | |
git tag -d ${{github.event.inputs.release_version}} | |
git add releases/CHANGELOG-${{github.event.inputs.release_version}}.md | |
- name: remove git-chglog binary | |
run: rm -f ${GITHUB_WORKSPACE}/git-chglog | |
- name: create changelog branch | |
run: | | |
git commit -m "release: ${RELEASE_VER} CHANGELOG" | |
git checkout -b CHANGELOG-${RELEASE_VER} | |
git push origin CHANGELOG-${RELEASE_VER} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
RELEASE_VER: ${{github.event.inputs.release_version}} | |
- name: print create pr instructions | |
run: | | |
BASE=release-${RELEASE_VER} | |
TITLE="release: ${RELEASE_VER} CHANGELOG" | |
BODY="Add CHANGELOG for upcoming ${RELEASE_VER} release" | |
echo "Create PR from web UI: https://github.com/${GITHUB_REPOSITORY}/pull/new/CHANGELOG-${RELEASE_VER}" | |
echo "Create PR from GH CLI: > gh pr create -b \"${BASE}\" -t \"${TITLE}\" -b \"${BODY}\" -R ${GITHUB_REPOSITORY}" | |
env: | |
RELEASE_VER: ${{github.event.inputs.release_version}} |