-
Notifications
You must be signed in to change notification settings - Fork 651
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding script and workflow to automate the preparation of releases (#615
) The prepare-release workflow is triggered when a new release/<version> branch is created. This workflow parses the <version> number from the branch name and updates version.py/changelog.md files accordingly. It then creates a pull request with those changes. This addresses part of #374. Co-authored-by: Mauricio Vásquez <mauricio@kinvolk.io>
- v1.29.0
- v1.28.2
- v1.28.1
- v1.28.0
- v1.27.0
- v1.26.0
- v1.25.0
- v1.24.0
- v1.23.0
- v1.22.0
- v1.21.0
- v1.20.0
- v1.19.0
- v1.18.0
- v1.17.0
- v1.16.0
- v1.15.0
- v1.14.0
- v1.13.0
- v1.12.0
- v1.12.0rc2
- v1.12.0rc1
- v1.11.1
- v1.11.0
- v1.10.0
- v1.10a0
- v1.9.1
- v1.9.0
- v1.8.0
- v1.7.1
- v1.7.0
- v1.6.2
- v1.6.1
- v1.6.0
- v1.5.0
- v1.4.1
- v1.4.0
- v1.3.0
- v1.2.0
- v1.1.0
- v1.0.0
- v1.0.0rc1
- v0.19b0
- v0.18b0
- v0.17b0
- v0.16b1
- v0.16b0
- v0.15b0
- v0.14b0
- v0.13b0
- v0.12.0
- v0.11.0
- v0.10.0
- v0.9.0
- v0.8.0
- v0.7.1
- v0.7.0
- stable
1 parent
1140332
commit fc2d073
Showing
2 changed files
with
107 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,27 @@ | ||
name: prepare-release | ||
on: | ||
push: | ||
branch: [ 'release/*' ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Get the version | ||
id: get_version | ||
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} | ||
|
||
- name: Prepare the release | ||
id: update | ||
run: | | ||
./scripts/prepare_release.sh ${{ steps.get_version.outputs.VERSION }} | ||
- name: Create Pull Request | ||
id: create-pr | ||
uses: peter-evans/create-pull-request@v2.7.0 | ||
with: | ||
branch: ${{ steps.get_version.outputs.VERSION }}-auto | ||
title: '[pre-release] Update changelogs, version [${{ steps.get_version.outputs.VERSION }}]' | ||
if: ${{ steps.update.outputs.version_updated == 1 }} |
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,80 @@ | ||
#!/bin/bash | ||
# | ||
# This script: | ||
# 1. parses the version number from the branch name | ||
# 2. updates version.py files to match that version | ||
# 3. iterates through CHANGELOG.md files and updates any files containing | ||
# unreleased changes | ||
# 4. sets the output variable 'version_updated' to determine whether | ||
# the github action to create a pull request should run. this allows | ||
# maintainers to merge changes back into the release branch without | ||
# triggering unnecessary pull requests | ||
# | ||
|
||
VERSION=`echo $1 | awk -F "/" '{print $NF}'` | ||
echo "Using version ${VERSION}" | ||
|
||
# check the version matches expected versioning e.g | ||
# 0.6, 0.6b, 0.6b0, 0.6.0 | ||
if [[ ! "${VERSION}" =~ ^([0-9])(\.*[0-9]{1,5}[a-b]*){1,3}$ ]]; then | ||
echo "Version number invalid: $VERSION" | ||
exit 1 | ||
fi | ||
|
||
function update_version_file() { | ||
errors=0 | ||
for f in `find . -name version.py`; do | ||
# check if version is already in version.py | ||
grep -q ${VERSION} $f; | ||
rc=$? | ||
if [ $rc == 0 ]; then | ||
errors=1 | ||
echo "${f} already contains ${VERSION}" | ||
continue | ||
fi | ||
# update version.py | ||
perl -i -pe "s/__version__.*/__version__ = \"${VERSION}\"/g" ${f}; | ||
git add ${f}; | ||
echo "Updating ${f}" | ||
done | ||
if [ ${errors} != 0 ]; then | ||
echo "::set-output name=version_updated::0" | ||
exit 0 | ||
fi | ||
} | ||
|
||
function update_changelog() { | ||
errors=0 | ||
for f in `find . -name CHANGELOG.md`; do | ||
# check if version is already in CHANGELOG | ||
grep -q ${VERSION} $f; | ||
rc=$? | ||
if [ $rc == 0 ]; then | ||
errors=1 | ||
echo "${f} already contains ${VERSION}" | ||
continue | ||
fi | ||
# check if changelog contains any new details | ||
changes=`sed -n '/## Unreleased/,/^##/p' ${f} | grep -v '^##' | wc -w | awk '{$1=$1;print}'` | ||
if [ ${changes} != "0" ]; then | ||
# update CHANGELOG.md | ||
perl -i -pe 's/## Unreleased.*/## Unreleased\n\n## '${VERSION}'/' ${f}; | ||
git add ${f}; | ||
echo "Updating ${f}" | ||
else | ||
echo "Skipping ${f}, no changes detected" | ||
fi | ||
done | ||
if [ ${errors} != 0 ]; then | ||
echo "::set-output name=version_updated::0" | ||
exit 0 | ||
fi | ||
} | ||
|
||
update_version_file | ||
update_changelog | ||
|
||
git config --local user.email "action@github.com" | ||
git config --local user.name "GitHub Action" | ||
git commit -m "updating changelogs and version to ${VERSION}" | ||
echo "::set-output name=version_updated::1" |