-
Notifications
You must be signed in to change notification settings - Fork 16
99 lines (84 loc) · 3.34 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: Release
on:
push:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
env:
GITHUB_USER: personiumio
GITHUB_TOKEN: ${{ secrets.PERSONIUM_GITHUB_TOKEN }}
steps:
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: git settings
run: |
if [ -z "$GITHUB_USER" -o -z "$GITHUB_TOKEN" ]; then
echo '$GITHUB_USER or $GITHUB_TOKEN is empty.'
exit 1
fi
cat << EOS >~/.netrc
machine github.com
login $GITHUB_USER
password $GITHUB_TOKEN
EOS
git config --global user.name "Personium Bot"
git config --global user.email "[email protected]"
git clone https://github.com/${GITHUB_REPOSITORY}.git .
git checkout master
- name: Get Component Name
run: |
echo "COMPONENT=$(echo $GITHUB_REPOSITORY | awk -F '/' '{ print $2 }')" >> $GITHUB_ENV
- name: Get Release Version String
run: |
echo "RELEASE_VERSION=$(cat CHANGELOG.md | grep -m 1 -E '## .+' | awk '{ print $2 }')" >> $GITHUB_ENV
- name: Remove -SNAPSHOT from pom.xml on master branch
run: |
bash ./.github/workflows/scripts/remove-SNAPSHOT.sh
- name: Create Release Note
run: awk '/##/{i++}i==1' CHANGELOG.md | tail +2 > ${{ github.workflow }}_CHANGELOG.md
- name: Build with maven
run: mvn -B package --file pom.xml -DskipTests && mv target/${{ env.COMPONENT }}.war target/${{ env.COMPONENT }}-${{ env.RELEASE_VERSION }}.war
- name: Create Release
uses: softprops/action-gh-release@v1
with:
name: "Release v${{ env.RELEASE_VERSION }}"
tag_name: "v${{ env.RELEASE_VERSION }}"
body_path: ${{ github.workflow }}_CHANGELOG.md
draft: True
files: |
target/${{ env.COMPONENT }}-${{ env.RELEASE_VERSION }}.war
prerelease: False
- name: Delete Temporary Release Note
run: rm ${{ github.workflow }}_CHANGELOG.md
# Preparing next version
- name: Prepare develop branch
run: |
git checkout develop
git rebase master
- name: Set next -SNAPSHOT version, and get next version string.
run: |
NEXT_VERSION=$(echo "$RELEASE_VERSION" | awk -F . '{print $1"."$2"."$3+1}')
NEXT_SNAPSHOT_VERSION="$NEXT_VERSION-SNAPSHOT"
mvn -B versions:set -DnewVersion=$NEXT_SNAPSHOT_VERSION && mvn -B versions:commit
echo "NEXT_SNAPSHOT_VERSION=$NEXT_SNAPSHOT_VERSION" >> $GITHUB_ENV
echo "NEXT_VERSION=$NEXT_VERSION" >> $GITHUB_ENV
- name: Update version in properties
if: ${{ env.COMPONENT == 'personium-core' || env.COMPONENT == 'personium-engine'}}
run: |
sed -i "s|^\(io\.personium\.core\.version=\).*|\1${NEXT_VERSION}|" src/main/resources/personium-unit-config-default.properties
- name: Create pull request for next release
uses: peter-evans/create-pull-request@v4
with:
base: master
branch: develop
token: ${{ secrets.PERSONIUM_GITHUB_TOKEN }}
title: 'Release v${{ env.NEXT_VERSION }}'
commit-message: "Update to v${{ env.NEXT_SNAPSHOT_VERSION }}"
committer: "Personium Bot <[email protected]>"
author: "Personium Bot <[email protected]>"
add-paths: |
pom.xml
src/main/**/*.properties