24
24
type : string
25
25
default : ' '
26
26
force_release :
27
- description : If true , will create a release. Only used for testing .
27
+ description : If 'yes' , will force the creation a release, if 'no' will not create a release. 'branch' will use release_type and the branch to determine if a release should be created .
28
28
type : string
29
- default : ' '
29
+ default : ' branch '
30
30
outputs :
31
31
version_number_output :
32
32
description : The complete version number
33
- value : ${{ jobs.build-publish-docker.outputs.jar_version }}
34
-
33
+ value : ${{ jobs.buildImage.outputs.jar_version }}
34
+ image_tag :
35
+ description : The tag used to describe the image in docker
36
+ value : ${{ jobs.buildImage.outputs.image_tag }}
35
37
env :
36
38
REGISTRY : ghcr.io
37
39
IMAGE_NAME : ${{ github.repository }}
38
- IS_RELEASE : ${{ ((inputs.release_type == 'Major' || inputs.release_type == 'Minor' || inputs.release_type == 'Patch') && (github.event.repository.default_branch == github.ref_name )) || inputs.force_release == 'true' }}
39
-
40
40
jobs :
41
- release :
42
- name : ${{ (((inputs.release_type == 'Major' || inputs.release_type == 'Minor' || inputs.release_type == 'Patch') && (github.event.repository.default_branch == github.ref_name )) || inputs.force_release == 'true') && 'Create Release' || 'Publish Pre-release' }}
41
+ buildImage :
43
42
runs-on : ubuntu-latest
44
43
permissions :
45
44
contents : write
46
45
security-events : write
47
46
packages : write
48
47
outputs :
49
48
jar_version : ${{ steps.version.outputs.new_version }}
49
+ image_tag : ${{ steps.updatePom.outputs.image_tag }}
50
50
steps :
51
+ - name : Check if Release
52
+ id : checkRelease
53
+ run : |
54
+ FORCE_RELEASE=${{ inputs.force_release == 'yes' }}
55
+ FORCE_NOT_RELEASE=${{ inputs.force_release == 'not' }}
56
+ CHECK_BRANCH_FOR_RELEASE=${{ inputs.force_release == 'branch' }}
57
+ BRANCH_ALLOWS_RELEASE=${{ (inputs.release_type == 'Major' || inputs.release_type == 'Minor' || inputs.release_type == 'Patch') && (github.event.repository.default_branch == github.ref_name) }}
58
+ if $FORCE_RELEASE; then
59
+ ISRELEASE=true
60
+ elif $FORCE_NOT_RELEASE; then
61
+ ISRELEASE=false
62
+ elif ($CHECK_BRANCH_FOR_RELEASE) && ($BRANCH_ALLOWS_RELEASE); then
63
+ ISRELEASE=true
64
+ else
65
+ ISRELEASE=false
66
+ fi
67
+ echo "Setting IS_RELEASE to $ISRELEASE"
68
+ echo "IS_RELEASE=$ISRELEASE" >> $GITHUB_OUTPUT
69
+
51
70
- name : Show Context
52
71
run : |
53
72
printenv
54
73
echo "$GITHUB_CONTEXT"
55
74
shell : bash
56
75
env :
57
76
GITHUB_CONTEXT : ${{ toJson(github) }}
77
+ IS_RELEASE : ${{ steps.checkRelease.outputs.IS_RELEASE }}
58
78
59
79
- name : Check branch and release type
60
80
uses :
IABTechLab/uid2-shared-actions/actions/[email protected]
@@ -85,11 +105,13 @@ jobs:
85
105
branch_name : ${{ github.ref }}
86
106
87
107
- name : Update pom.xml
108
+ id : updatePom
88
109
run : |
89
110
current_version=$(grep -o '<version>.*</version>' pom.xml | head -1 | sed 's/<version>\(.*\)<\/version>/\1/')
90
111
new_version=${{ steps.version.outputs.new_version }}
91
112
sed -i "0,/$current_version/s/$current_version/$new_version/" pom.xml
92
113
echo "Version number updated from $current_version to $new_version"
114
+ echo "image_tag=${{ steps.version.outputs.new_version }}-${{ inputs.cloud_provider }}" >> $GITHUB_OUTPUT
93
115
94
116
- name : Package JAR
95
117
id : package
@@ -99,7 +121,16 @@ jobs:
99
121
echo "git_commit=$(git show --format="%h" --no-patch)" >> $GITHUB_OUTPUT
100
122
101
123
- name : Commit pom.xml and version.json
102
- if : ${{ inputs.version_number_input == '' }}
124
+ if : ${{ inputs.version_number_input == '' && steps.checkRelease.outputs.IS_RELEASE != 'true' }}
125
+ uses : EndBug/add-and-commit@v9
126
+ with :
127
+ add : ' pom.xml version.json'
128
+ author_name : Release Workflow
129
+
130
+ message : ' Released ${{ inputs.release_type }} version: ${{ steps.version.outputs.new_version }}'
131
+
132
+ - name : Commit pom.xml, version.json and set tag
133
+ if : ${{ inputs.version_number_input == '' && steps.checkRelease.outputs.IS_RELEASE == 'true' }}
103
134
uses : EndBug/add-and-commit@v9
104
135
with :
105
136
add : ' pom.xml version.json'
@@ -121,7 +152,7 @@ jobs:
121
152
with :
122
153
images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
123
154
tags : |
124
- type=raw,value=${{ steps.version .outputs.new_version }}-${{ inputs.cloud_provider }}
155
+ type=raw,value=${{ steps.updatePom .outputs.image_tag }}
125
156
126
157
- name : Build and export to Docker
127
158
uses : docker/build-push-action@v5
@@ -175,19 +206,19 @@ jobs:
175
206
176
207
- name : Build Changelog
177
208
id : github_release
178
- if : ${{ env .IS_RELEASE == 'true' }}
209
+ if : ${{ steps.checkRelease.outputs .IS_RELEASE == 'true' }}
179
210
uses : mikepenz/release-changelog-builder-action@v3
180
211
with :
181
212
configurationJson : |
182
213
{
183
- "template": "#{{CHANGELOG}}\n## Installation\n```\ndocker pull ${{ steps.meta.outputs.tags }}\n```\n\n## Changelog\n#{{UNCATEGORIZED}}",
214
+ "template": "#{{CHANGELOG}}\n## Installation\n```\ndocker pull ${{ steps.meta.outputs.tags }}\n```\n\n## Image reference to deploy: \n```\n${{ steps.updatePom.outputs.image_tag }}\n```\n\n## Changelog\n#{{UNCATEGORIZED}}",
184
215
"pr_template": " - #{{TITLE}} - ( PR: ##{{NUMBER}} )"
185
216
}
186
217
env :
187
218
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
188
219
189
220
- name : Create Release
190
- if : ${{ env .IS_RELEASE == 'true' }}
221
+ if : ${{ steps.checkRelease.outputs .IS_RELEASE == 'true' }}
191
222
uses : softprops/action-gh-release@v1
192
223
with :
193
224
name : ${{ steps.version.outputs.new_version }}
0 commit comments