Skip to content

Commit 1cf9cc5

Browse files
committed
Add github workfklows
1 parent 5d0d11f commit 1cf9cc5

File tree

4 files changed

+187
-0
lines changed

4 files changed

+187
-0
lines changed

.github/workflows/create_release.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Create release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
commit_hash:
7+
description: "Hash of 'Release version x.y.z' commit"
8+
required: true
9+
10+
jobs:
11+
build:
12+
name: Create Release
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Setup Java SDK
16+
uses: actions/[email protected]
17+
with:
18+
java-version: 11
19+
20+
- name: Checkout code
21+
uses: actions/checkout@v2
22+
with:
23+
ref: ${{ github.event.inputs.commit_hash }}
24+
25+
- name: Check commit title and extract version
26+
run: |
27+
export commit_title=$(git log --pretty=format:%s -1 ${{ github.event.inputs.commit_hash }})
28+
echo "Commit title: $commit_title"
29+
if [[ $commit_title =~ ^Release\ version\ [0-9]*\.[0-9]*\.[0-9]*$ ]]; then
30+
echo "Valid commit title"
31+
else
32+
echo "Invalid commit title"
33+
exit 1
34+
fi
35+
export version=$(echo ${commit_title} | sed s/^Release\ version\ //g)
36+
echo "Will use version ${version}"
37+
echo "version=${version}" >> $GITHUB_ENV
38+
39+
- name: Build
40+
run: |
41+
./gradlew distTar distZip
42+
43+
export tar_file=$(ls ./build/distributions/ | grep tar)
44+
export zip_file=$(ls ./build/distributions/ | grep zip)
45+
echo tar_file=${tar_file} >> $GITHUB_ENV
46+
echo zip_file=${zip_file} >> $GITHUB_ENV
47+
48+
echo tar_path=`realpath ./build/distributions/${tar_file}` >> $GITHUB_ENV
49+
echo zip_path=`realpath ./build/distributions/${zip_file}` >> $GITHUB_ENV
50+
51+
- name: Create tag
52+
run: |
53+
git config --local user.name "GitHub Action"
54+
git config --local user.email "[email protected]"
55+
git tag -a "v${{ env.version }}" -m "Release version ${{ env.version }}"
56+
git push origin "v${{ env.version }}"
57+
58+
- name: Create release draft
59+
id: create_release
60+
uses: actions/create-release@v1
61+
env:
62+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
with:
64+
tag_name: "v${{ env.version }}"
65+
release_name: "v${{ env.version }}"
66+
commitish: ${{ github.event.inputs.commit_hash }}
67+
body: |
68+
*Fill in*
69+
draft: true
70+
prerelease: false
71+
72+
- name: Upload tar
73+
uses: actions/upload-release-asset@v1
74+
env:
75+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76+
with:
77+
upload_url: ${{ steps.create_release.outputs.upload_url }}
78+
asset_path: ${{ env.tar_path }}
79+
asset_name: ${{ env.tar_file }}
80+
asset_content_type: application/tar
81+
82+
- name: Upload zip
83+
uses: actions/upload-release-asset@v1
84+
env:
85+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86+
with:
87+
upload_url: ${{ steps.create_release.outputs.upload_url }}
88+
asset_path: ${{ env.zip_path }}
89+
asset_name: ${{ env.zip_file }}
90+
asset_content_type: application/zip
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# The workflow to check master after push.
2+
name: Master checks after push
3+
on:
4+
push:
5+
branches: [ master ]
6+
jobs:
7+
build:
8+
name: Build
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v2
13+
with:
14+
fetch-depth: 0
15+
- name: Set up JDK 11
16+
uses: actions/setup-java@v1
17+
with:
18+
java-version: 11
19+
- name: Build with Gradle
20+
run: ./gradlew build
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# The workflow to check pull requests into master.
2+
# This checks the source in the state as if after the merge.
3+
name: Pull request checks
4+
on:
5+
pull_request:
6+
branches: [ master ]
7+
jobs:
8+
build:
9+
name: Build
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v2
14+
- name: Set up JDK 11
15+
uses: actions/setup-java@v1
16+
with:
17+
java-version: 11
18+
- name: Build with Gradle
19+
run: ./gradlew build
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# The workflow to create PRs with release commits.
2+
name: Create release PR
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release_version:
7+
description: "Release version '0.1.2' (without 'v')"
8+
required: true
9+
snapshot_version:
10+
description: "Snapshot version '0.2.0-SNAPSHOT' (without 'v')"
11+
required: true
12+
13+
jobs:
14+
create_release_pr:
15+
name: Create release PR (job)
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Check versions
19+
run: |
20+
echo "Checking release version..."
21+
if echo ${{ github.event.inputs.release_version }} | grep --invert-match '^[0-9]\+\.[0-9]\+\.[0-9]\+$' > /dev/null; then
22+
echo "Release version is invalid"
23+
exit 1
24+
fi
25+
26+
echo "Checking snapshot version..."
27+
if echo ${{ github.event.inputs.snapshot_version }} | grep --invert-match '^[0-9]\+\.[0-9]\+\.[0-9]\+-SNAPSHOT$' > /dev/null; then
28+
echo "Snapshot version is invalid"
29+
exit 1
30+
fi
31+
32+
- name: Checkout master
33+
uses: actions/checkout@v2
34+
with:
35+
ref: master
36+
fetch-depth: 0
37+
38+
- name: Create release commits
39+
run: |
40+
git config --local user.name "GitHub Action"
41+
git config --local user.email "[email protected]"
42+
sed -i -e "s/^version=.\+$/version=${{ github.event.inputs.release_version }}/g" gradle.properties
43+
git add gradle.properties
44+
git commit -m "Release version ${{ github.event.inputs.release_version }}"
45+
sed -i -e "s/^version=.\+$/version=${{ github.event.inputs.snapshot_version }}/g" gradle.properties
46+
git add gradle.properties
47+
git commit -m "Bump version to ${{ github.event.inputs.snapshot_version }}"
48+
49+
- name: Create Pull Request
50+
uses: peter-evans/create-pull-request@v3
51+
with:
52+
branch: release-${{ github.event.inputs.release_version }}
53+
delete-branch: true
54+
draft: true
55+
title: Release version ${{ github.event.inputs.release_version }}
56+
body: |
57+
Proposed changelog:
58+
- *fill in*

0 commit comments

Comments
 (0)