-
Notifications
You must be signed in to change notification settings - Fork 0
261 lines (253 loc) · 9.98 KB
/
release_workflow.yaml
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
<<<<<<< HEAD
name: Release Pipeline
=======
name: Release Workflow
>>>>>>> 34c9efdd2ed1275b7d4b3ea5db8865a58f4ae2e9
run-name: "Releasing ${{ github.event.repository.name }} #${{github.run_number}}"
on:
workflow_dispatch:
<<<<<<< HEAD
=======
inputs:
release_message:
type: string
description: "(Optional) Enter Release Message"
env:
BRANCH_NAME: ${{github.ref_name}}
TRUNK_BRANCH_NAME: main
RELEASE_MESSAGE: ${{github.event.inputs.release_message}}
>>>>>>> 34c9efdd2ed1275b7d4b3ea5db8865a58f4ae2e9
jobs:
initialization:
runs-on: ubuntu-latest
<<<<<<< HEAD
if: github.ref == 'refs/heads/main' || github.ref_name == 'refs/heads/master'
outputs:
SNAPSHOT_VERSION: ${{steps.newSnapshotVersion.outputs.SnapshotVersion}}
RELEASE_VERSION: ${{steps.splitVersion.outputs._0}}
env:
SNAPSHOTVERSION: ""
steps:
=======
name: Initialization
outputs:
NEXT_SNAPSHOT_VERSION: ${{steps.nextSnapshotVersion.outputs.SnapshotVersion}}
RELEASE_VERSION: ${{steps.splitCurrentVersion.outputs._0}}
steps:
- name: Verify Branch
if: env.BRANCH_NAME != env.TRUNK_BRANCH_NAME
run: |
echo "ERROR: Attempting to release from branch ${{env.BRANCH_NAME}}. Release from ${{env.TRUNK_BRANCH_NAME}} branch only"
exit 1
>>>>>>> 34c9efdd2ed1275b7d4b3ea5db8865a58f4ae2e9
- name: Checkout Code Repository
uses: actions/checkout@v4
- name: Downloading Java
uses: actions/setup-java@v4
with:
<<<<<<< HEAD
java-version: '11'
distribution: 'temurin'
- name: Get Current Version
=======
java-version: '21'
distribution: 'adopt'
- name: Get Current Version
id: getCurrentVersion
>>>>>>> 34c9efdd2ed1275b7d4b3ea5db8865a58f4ae2e9
run: |
echo "POM_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
- name: Print Version
run: echo ${{env.POM_VERSION}}
- name: Verify Is SNAPSHOT Version
<<<<<<< HEAD
if: ${{ !contains(env.POM_VERSION, '-SNAPSHOT')}}
run: |
echo "ERROR: Version is set to incompatible version ${{env.POM_VERSION}}. Only SNAPSHOT development versions can be converted to a release version."
exit 1
- name: Split version code
uses: xom9ikk/split@v1
id: splitVersion
=======
if: ${{!contains(env.POM_VERSION, '-SNAPSHOT')}}
run: |
echo "ERROR: Version is set to incompatible version ${{env.POM_VERSION}}. Only SNAPSHOT development versions can be converted to a release version."
exit 1
- name: Split version code - Remove SNAPSHOT Word
uses: xom9ikk/split@v1
id: splitCurrentVersion
>>>>>>> 34c9efdd2ed1275b7d4b3ea5db8865a58f4ae2e9
with:
string: ${{env.POM_VERSION}}
separator: -SNAPSHOT
limit: -1
<<<<<<< HEAD
- name: Split version code - Minor
uses: xom9ikk/split@v1
id: splitVersionMinor
with:
string: ${{steps.splitVersion.outputs._0}}
separator: .
limit: -1
- name: Increment Snapshot Version
id: newSnapshotVersion
run: |
echo "SnapshotVersion=${{steps.splitVersionMinor.outputs._0}}.$((${{steps.splitVersionMinor.outputs._1}} + 1)).${{steps.splitVersionMinor.outputs._2}}-SNAPSHOT" >> $GITHUB_OUTPUT
- name: Print Versions
run: |
echo " Snapshot Version -- ${{steps.newSnapshotVersion.outputs.SnapshotVersion}}"
echo " Release Version -- ${{steps.splitVersion.outputs._0}}"
=======
- name: Split version code - Seperate By .
uses: xom9ikk/split@v1
id: splitVersionMinor
with:
string: ${{steps.splitCurrentVersion.outputs._0}}
separator: .
limit: -1
- name: Increment Snapshot Version
id: nextSnapshotVersion
run: |
echo "SnapshotVersion=${{steps.splitVersionMinor.outputs._0}}.$((${{steps.splitVersionMinor.outputs._1}} + 1)).${{steps.splitVersionMinor.outputs._2}}-SNAPSHOT" >> $GITHUB_OUTPUT
- name: Print Information
run: |
echo "Release Version -- ${{steps.splitCurrentVersion.outputs._0}}"
echo "Snapshot Version -- ${{steps.nextSnapshotVersion.outputs.SnapshotVersion}}"
echo "Branch Name -- ${{env.BRANCH_NAME}}"
>>>>>>> 34c9efdd2ed1275b7d4b3ea5db8865a58f4ae2e9
set_build_and_tag_release:
runs-on: ubuntu-latest
needs: initialization
<<<<<<< HEAD
=======
name: Set, Build & Tag Release Version
>>>>>>> 34c9efdd2ed1275b7d4b3ea5db8865a58f4ae2e9
permissions:
contents: write
steps:
- name: Checkout Code Repository
uses: actions/checkout@v4
- name: Downloading Java
uses: actions/setup-java@v4
with:
java-version: '21'
<<<<<<< HEAD
distribution: 'temurin'
- name: Set Release Version
run: mvn -B versions:set -DnewVersion=${{needs.initialization.outputs.RELEASE_VERSION}} -DgenerateBackupPoms=false
- name: Build Release Version
run: mvn -version mvn clean install
=======
distribution: 'adopt'
- name: Set Release Version
run: |
mvn -B versions:set \
-DnewVersion=${{needs.initialization.outputs.RELEASE_VERSION}} \
-DgenerateBackupPoms=false
# - name: Build Release Version
# run: |
# mvn -version
# mvn clean install \
# --batch-mode \
# -e \
# -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
# -PcodeQuality,release-enforcement
- name: Build Release Version
run: |
mvn -version
mvn clean install
>>>>>>> 34c9efdd2ed1275b7d4b3ea5db8865a58f4ae2e9
- name: Create tag
uses: actions/github-script@v5
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{needs.initialization.outputs.RELEASE_VERSION}}',
sha: context.sha
})
set_next_dev:
runs-on: ubuntu-latest
<<<<<<< HEAD
=======
name: Set Next Development Version
>>>>>>> 34c9efdd2ed1275b7d4b3ea5db8865a58f4ae2e9
needs:
- initialization
- set_build_and_tag_release
permissions:
contents: write
steps:
- name: Checkout Code Repository
uses: actions/checkout@v4
- name: Downloading Java
uses: actions/setup-java@v4
with:
java-version: '21'
<<<<<<< HEAD
distribution: 'temurin'
- name: Set Dev Version
run: mvn -B versions:set -DnewVersion=${{needs.initialization.outputs.SNAPSHOT_VERSION}} -DgenerateBackupPoms=false
=======
distribution: 'adopt'
- name: Set Dev Version
run: |
mvn -B versions:set \
-DnewVersion=${{needs.initialization.outputs.NEXT_SNAPSHOT_VERSION}} \
-DgenerateBackupPoms=false
>>>>>>> 34c9efdd2ed1275b7d4b3ea5db8865a58f4ae2e9
- name: Commit & Push
run: |
git add .
git config user.name fda_shield_omoruyi
git config user.email [email protected]
<<<<<<< HEAD
git commit -m 'Set next dev version to ${{needs.initialization.outputs.SNAPSHOT_VERSION}}'
=======
git commit -m 'Set next dev version to ${{needs.initialization.outputs.NEXT_SNAPSHOT_VERSION}}'
>>>>>>> 34c9efdd2ed1275b7d4b3ea5db8865a58f4ae2e9
git push origin HEAD:main
git push --tags origin
create_release:
name: Create Release
permissions: write-all
needs:
- initialization
<<<<<<< HEAD
- set_build_and_tag_release
=======
>>>>>>> 34c9efdd2ed1275b7d4b3ea5db8865a58f4ae2e9
- set_next_dev
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@master
<<<<<<< HEAD
=======
- name: Modify Release Message
if: env.RELEASE_MESSAGE == ''
run: echo "RELEASE_MESSAGE=Release ${{needs.initialization.outputs.RELEASE_VERSION}}" >> $GITHUB_ENV
>>>>>>> 34c9efdd2ed1275b7d4b3ea5db8865a58f4ae2e9
- name: Create Release
id: create_release
uses: actions/create-release@latest
env:
<<<<<<< HEAD
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
=======
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
>>>>>>> 34c9efdd2ed1275b7d4b3ea5db8865a58f4ae2e9
with:
tag_name: ${{needs.initialization.outputs.RELEASE_VERSION}}
release_name: Release ${{needs.initialization.outputs.RELEASE_VERSION}}
body: |
<<<<<<< HEAD
Changes in this Release
- First Change
- Second Change
=======
${{env.RELEASE_MESSAGE}}
>>>>>>> 34c9efdd2ed1275b7d4b3ea5db8865a58f4ae2e9
draft: false
prerelease: false