-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit ensures that the changelog is updated before a release with the correct date and version. Also, after a release, a mergeback PR is created to ensure that the changelog update and version bump is available in main.
- Loading branch information
1 parent
03ff062
commit 98bd32a
Showing
3 changed files
with
128 additions
and
5 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
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,70 @@ | ||
# This workflow runs after a release of the action. | ||
# It merges any changes from the release back into the | ||
# main branch. Typically, this is just a single commit | ||
# that updates the changelog. | ||
name: Mergeback after release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
baseBranch: | ||
description: 'The base branch to merge into' | ||
default: v1 | ||
required: false | ||
|
||
# Commented for now to ensure we don't run this accidentally after a real merge | ||
# push: | ||
# branches: | ||
# - main | ||
|
||
pull_request: | ||
paths: | ||
- .github/workflows/post-release-mergeback.yml | ||
|
||
jobs: | ||
merge-back: | ||
runs-on: ubuntu-latest | ||
env: | ||
BASE_BRANCH: "${{ github.event.inputs.baseBranch || 'v1' }}" | ||
HEAD_BRANCH: "${{ github.ref }}" | ||
|
||
steps: | ||
- name: validate | ||
run: | | ||
if [ "$BASE_BRANCH" -eq "$HEAD_BRANCH" ]; then | ||
echo "error::Base branch and head branch are the same $BASE_BRANCH." | ||
exit -1 | ||
fi | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
|
||
- name: Update git config | ||
run: | | ||
git config --global user.email "codeql-core@github.com" | ||
git config --global user.name "CodeQL Actions Bot" | ||
# we didn't tag the release during the update-release-branch workflow because the | ||
# commit that actually makes it to the main branch may be different than the one | ||
# created by the workflow. We tag now because we know the correct commit | ||
- name: Tag release | ||
run: | | ||
VERSION="$(jq '.version' -r 'package.json')" | ||
git tag -a "v$VERSION" -m "v$VERSION" | ||
git push origin --follow-tags | ||
- name: Create mergeback branch | ||
run: | | ||
NEW_BRANCH="mergeback/$HEAD_BRANCH-to-$BASE_BRANCH" | ||
PR_TITLE="Mergeback $HEAD_BRANCH into $BASE_BRANCH" | ||
PR_BODY="Updates version and changelog." | ||
git checkout -b $NEW_BRANCH | ||
# Update the changelog | ||
perl -i -pe 's/^/## \[UNRELEASED\]\n\n/ if($.==3)' CHANGELOG.md | ||
git add CHANGELOG.md | ||
git commit -m "Update changelog for new version" | ||
npm version | ||
# Create pull request | ||
gh pr create --base "$BASE_BRANCH" --reviewer "github/codeql-core" --title "$PR_TITLE" --body "$PR_BODY" |
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