-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add changelog auto update github action (#11)
This workflow will copy changelog from release branch to main branch after release is triggered. Signed-off-by: Rahul Jain <rahulj@vmware.com>
- Loading branch information
1 parent
fbb4dbb
commit b8b3629
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: Update CHANGELOG after release | ||
|
||
on: | ||
push: | ||
tags: | ||
- v* | ||
|
||
jobs: | ||
check-version: | ||
runs-on: [ubuntu-latest] | ||
outputs: | ||
version: ${{ steps.get-version.outputs.version }} | ||
steps: | ||
- name: Extract version from Github ref | ||
id: get-version | ||
env: | ||
TAG: ${{ github.ref }} | ||
shell: bash | ||
run: | | ||
version=${TAG:10} | ||
if [[ "$version" == *-* ]]; then | ||
echo "$version is a release candidate or a pre-release" | ||
exit 0 | ||
fi | ||
echo "::set-output name=version::$version" | ||
pr-update-changelog: | ||
runs-on: [ubuntu-latest] | ||
needs: check-version | ||
if: ${{ needs.check-version.outputs.version != '' }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
ref: main | ||
- name: Cherry-pick changelog commit | ||
env: | ||
VERSION: ${{ needs.check-version.outputs.version }} | ||
shell: bash | ||
run: | | ||
git config user.name github-actions | ||
git config user.email github-actions@github.com | ||
commit_hash=$(git log "$VERSION" --format="%H" --grep="Update CHANGELOG for $VERSION release") | ||
if [[ -z "$commit_hash" ]]; then | ||
echo "Cannot find commit" | ||
exit 1 | ||
fi | ||
git cherry-pick "$commit_hash" | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v4 | ||
with: | ||
token: ${{ secrets.ANTREA_BOT_WRITE_PAT }} | ||
delete-branch: true | ||
title: "Update CHANGELOG for ${{ needs.check-version.outputs.version }} release" | ||
body: | | ||
PR was opened automatically from Github Actions | ||
- name: Check outputs | ||
run: | | ||
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" | ||
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" |