-
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
bc39b21
commit 14f5cf4
Showing
10 changed files
with
164 additions
and
5 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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,106 @@ | ||
# 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: main | ||
required: false | ||
|
||
# Commented for now to ensure we don't run this accidentally after a real merge | ||
# push: | ||
# branches: | ||
# - v1 | ||
|
||
pull_request: | ||
paths: | ||
- .github/workflows/post-release-mergeback.yml | ||
|
||
jobs: | ||
merge-back: | ||
runs-on: ubuntu-latest | ||
env: | ||
BASE_BRANCH: "${{ github.event.inputs.baseBranch || 'main' }}" | ||
# TODO head_ref won't exist in workflow dispatch | ||
HEAD_BRANCH: "${{ github.head_ref }}" | ||
NEW_BRANCH: "mergeback/${{ github.head_ref }}-to-${{ github.event.inputs.baseBranch || 'main' }}" | ||
|
||
steps: | ||
- name: Dump GitHub context | ||
env: | ||
GITHUB_CONTEXT: '${{ toJson(github) }}' | ||
run: echo "$GITHUB_CONTEXT" | ||
|
||
- name: Dump branches | ||
run: | | ||
echo "BASE_BRANCH $BASE_BRANCH" | ||
echo "HEAD_BRANCH $HEAD_BRANCH" | ||
echo "NEW_BRANCH $NEW_BRANCH" | ||
- 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" | ||
- name: Create mergeback branch | ||
run: | | ||
git checkout -b $NEW_BRANCH | ||
- name: Check for tag | ||
id: check | ||
run: | | ||
set +e # don't fail on an errored command | ||
VERSION="$(jq '.version' -r 'package.json')" | ||
TAG="v$VERSION" | ||
git ls-remote --tags origin | grep $TAG | ||
EXISTS="$?" | ||
if [ "$EXISTS" -ne 0 ]; then | ||
echo "::set-output name=exists::true" | ||
echo "Tag $TAG exists. Not going to re-release." | ||
fi | ||
# 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 | ||
if: steps.check.outputs.exists == 'true' | ||
run: | | ||
VERSION="$(jq '.version' -r 'package.json')" | ||
git tag -a "v$VERSION" -m "v$VERSION" | ||
git push origin --follow-tags "v$VERSION" | ||
- name: Create mergeback branch | ||
if: steps.check.outputs.exists == 'true' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
set -exu | ||
PR_TITLE="Mergeback $HEAD_BRANCH into $BASE_BRANCH" | ||
PR_BODY="Updates version and changelog." | ||
# 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 TODO: choose a better reviewer | ||
git push origin "$NEW_BRANCH" | ||
# TODO aeisenberg isn't the right reviewer, would like to specify the github/codeql-core team, but not working right now. | ||
gh pr create --head "$NEW_BRANCH" --base "$BASE_BRANCH" --reviewer "aeisenberg" --title "$PR_TITLE" --body "$PR_BODY" |