-
Notifications
You must be signed in to change notification settings - Fork 17
51 lines (45 loc) · 1.98 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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 }}