-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automate the creation of release PR (close #498)
- Loading branch information
Showing
1 changed file
with
51 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,51 @@ | ||
name: Prepare PR for release | ||
|
||
on: | ||
create | ||
|
||
jobs: | ||
prepare_release_pr: | ||
if: ${{ contains(github.ref, 'refs/heads/release/') }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Github | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Extract release version | ||
id: version | ||
run: | | ||
export VERSION=$(basename ${{ github.ref }}) | ||
echo "::set-output name=release_version::$VERSION" | ||
- name: Create prepare for release commit | ||
run: | | ||
echo $(git log --pretty=oneline | cut -d" " -f2- | grep -n -m1 "Prepare for .* release"|cut -d':' -f1) | ||
nbNewCommits=$(echo "$(git log --pretty=format:%s | grep -n -m1 "Prepare for .* release" | cut -d':' -f1) - 1" | bc) | ||
newCommits=$(git log --pretty=format:%s|head -$nbNewCommits|sed 's/close #/#/;s/closes #/#/') | ||
newVersion=${{ steps.version.outputs.release_version }} | ||
headLine="Version $newVersion ($(date +%Y-%m-%d))" | ||
nbDashes=$(expr length "$headLine") | ||
dashes=$(printf "%0.s-" $(seq 1 $nbDashes)) | ||
{ echo -e "$headLine\n$dashes\n$newCommits\n"; cat CHANGELOG; } > CHANGELOG.new | ||
mv CHANGELOG.new CHANGELOG | ||
sed -i -E "s/([ ]+version[ ]+:= )\"[0-9]+\.[0-9]+\.[0-9]+.*/\1\"$newVersion\"/g" build.sbt | ||
sed -i -E "s/(release-)[0-9]+\.[0-9]+\.[0-9]+/\1$newVersion/g" README.md | ||
git config user.name "github-actions[bot]" | ||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
git commit -m "Prepare for $newVersion release" CHANGELOG build.sbt README.md | ||
- name: Push changes | ||
uses: ad-m/github-push-action@master | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
branch: ${{ github.ref }} | ||
|
||
- name: Create PR | ||
uses: repo-sync/pull-request@v2 | ||
with: | ||
destination_branch: "master" | ||
pr_title: "Release ${{ steps.version.outputs.release_version }}" | ||
pr_body: "Created by Github Actions" | ||
github_token: ${{ secrets.GITHUB_TOKEN }} |