-
Notifications
You must be signed in to change notification settings - Fork 0
168 lines (148 loc) · 6.53 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: Release develop
on:
workflow_dispatch:
inputs:
next_version:
description: Updated version (if not set next minor is used)
type: string
required: false
default: "Auto"
push:
tags:
- 'perform-release-on-*'
jobs:
release:
runs-on: judong
timeout-minutes: 30
env:
SIGN_KEY_ID: ${{ secrets.GPG_KEYNAME }}
SIGN_KEY_PASS: ${{ secrets.GPG_PASSPHRASE }}
SIGN_KEY: ${{ secrets.GPG_SECRET_KEYS }}
outputs:
version: ${{ steps.version.outputs.version }}
message: ${{ steps.success_message.outputs.message }}${{ steps.failure_message.outputs.message }}${{ steps.cancel_message.outputs.message }}
steps:
- name: ⬇️ Checkout repository
uses: actions/checkout@v3
with:
ref: develop
token: ${{ secrets.OSS_PAT }}
fetch-depth: 2
- name: 🛠️ Project context
id: context
uses: zero88/[email protected]
- name: 🧹 Remove toolchains.xml
run: rm $HOME/.m2/toolchains.xml || true
- name: 🛠️ Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'zulu'
- name: 🧹 Remove settings.xml
run: rm $HOME/.m2/settings.xml || true
- name: 🛠️ Setup maven settings.xml
uses: whelk-io/maven-settings-xml-action@v21
with:
servers: >
[
{
"id": "judong-nexus-mirror",
"username": "${{ secrets.JUDONG_NEXUS_USERNAME }}",
"password": "${{ secrets.JUDONG_NEXUS_PASSWORD }}"
},
{
"id": "judong-nexus-distribution",
"username": "${{ secrets.JUDONG_NEXUS_USERNAME }}",
"password": "${{ secrets.JUDONG_NEXUS_PASSWORD }}"
}
]
mirrors: >
[
{
"id": "judong-nexus-mirror",
"mirrorOf": "*",
"url": "https://nexus.judo.technology/repository/maven-judong/"
}
]
- name: ⬇️ Checkout master repository
uses: actions/checkout@v3
with:
token: ${{ secrets.OSS_PAT }}
ref: master
fetch-depth: 0
- name: 🔪 Reset master branch to develop
run: |
git fetch origin develop:develop
git reset --hard develop
- name: 🔢 Calculate version number
id: version
run: |-
TAG_NAME=$(echo "${{ steps.context.outputs.branch }}" | cut -d ' ' -f2 | tr '#\/\.-' '_')
BASE_VERSION=$(./mvnw org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dtycho.mode=maven -DskipModules=true -Dexpression=project.version -q -DforceStdout | cut -d'-' -f 1)
if [[ "${{ github.event.inputs.is_release }}" == "true" ]]; then
VERSION_NUMBER=${BASE_VERSION}
else
VERSION_NUMBER=${BASE_VERSION}.$(date +%Y%m%d_%H%M%S)_${{ steps.context.outputs.shortCommitId }}_${TAG_NAME//[(\)]}
fi
echo "Base version from POM: $BASE_VERSION"
echo "Building version: ${VERSION_NUMBER}"
echo "version=${VERSION_NUMBER}" >> $GITHUB_OUTPUT
echo "base-version=${BASE_VERSION}" >> $GITHUB_OUTPUT
- name: 🔀 Merge master branch to release branch
run: |
git merge -s ours origin/master
- name: Set release version
run: |-
./mvnw versions:set-property -Dproperty=revision -DnewVersion=${{ steps.version.outputs.base-version }} -Dtycho.mode=maven -DskipModules=true
- name: ⬆️ Create Pull Request for release into master
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.OSS_PAT }}
commit-message: '[RELEASE] Release version: ${{ steps.version.outputs.base-version }}'
branch: release/v${{ steps.version.outputs.base-version }}
delete-branch: true
title: '[RELEASE] Release version: ${{ steps.version.outputs.base-version }} to master'
body: >
This PR is auto-generated. Creates pull request to master which contains the coresponding release's source code.
labels: release, automated pr
- name: ⬇️ Checkout develop repository
uses: actions/checkout@v3
with:
ref: develop
fetch-depth: 0
- name: ⏭️ Increase version number
id: next_version
run: |-
NEXT_VERSION="${{ github.event.inputs.next_version }}"
if [ -z "$NEXT_VERSION" ] || [ $NEXT_VERSION == "Auto" ]; then
NEXT_VERSION=`(echo $(./mvnw build-helper:parse-version org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate \
-Dtycho.mode=maven -DskipModules=true -Dexpression="parsedVersion.majorVersion" -q -DforceStdout) &&\
echo "." && \
echo $(./mvnw build-helper:parse-version org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate \
-Dtycho.mode=maven -DskipModules=true -Dexpression="parsedVersion.minorVersion" -q -DforceStdout) &&\
echo "." && \
echo $(./mvnw build-helper:parse-version org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate \
-Dtycho.mode=maven -DskipModules=true -Dexpression="parsedVersion.nextIncrementalVersion" -q -DforceStdout) &&\
echo "-SNAPSHOT") \
| tr -d '\n'`
fi
if [[ ! $NEXT_VERSION =~ ^.*-SNAPSHOT ]]; then
NEXT_VERSION="${NEXT_VERSION}-SNAPSHOT"
fi
echo "Next version is: $NEXT_VERSION"
echo "version=${NEXT_VERSION}" >> $GITHUB_OUTPUT
- name: Set next version
run: |-
./mvnw versions:set-property -Dproperty=revision -DnewVersion=${{ steps.next_version.outputs.version }} -Dtycho.mode=maven -DskipModules=true
- name: ⬆️ Create Pull Request for increased version into develop
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.OSS_PAT }}
commit-message: '[RELEASE] Increase version to ${{ steps.next_version.outputs.version }}'
branch: increment/v${{ steps.next_version.outputs.version }}
delete-branch: true
branch-suffix: short-commit-hash
title: '[RELEASE] Set develop version to: ${{ steps.next_version.outputs.version }}'
body: >
This PR is auto-generated. Increasing development version and creates a pull request to develop.
labels: release, automated pr