@@ -2,9 +2,6 @@ name: Shared Publish Docker
2
2
on :
3
3
workflow_call :
4
4
inputs :
5
- tag :
6
- description : ' The tag to apply to the Docker file'
7
- type : string
8
5
cloud_provider :
9
6
description : ' Must be one of [aws, gcp, azure, default]'
10
7
required : false
15
12
required : true
16
13
type : string
17
14
java_version :
15
+ description : The version of Java to use to compile the JAR. Defaults to 11
18
16
type : string
19
17
default : ' 11'
20
18
publish_vulnerabilities :
19
+ description : If true, will attempt to publish any vulnerabilities to GitHub. Defaults to true. Set to false for private repos.
21
20
type : string
22
21
default : ' true'
23
22
version_number_input :
23
+ description : If set, the version number will not be incremented and the given number will be used.
24
+ type : string
25
+ default : ' '
26
+ force_release :
27
+ description : If true, will create a release. Only used for testing.
24
28
type : string
25
29
default : ' '
26
30
outputs :
31
35
env :
32
36
REGISTRY : ghcr.io
33
37
IMAGE_NAME : ${{ github.repository }}
34
- BRANCH_NAME : ${{ github.ref }}
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' }}
35
39
36
40
jobs :
37
- build-publish-docker :
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' }}
38
43
runs-on : ubuntu-latest
39
44
permissions :
40
45
contents : write
@@ -43,14 +48,27 @@ jobs:
43
48
outputs :
44
49
jar_version : ${{ steps.version.outputs.new_version }}
45
50
steps :
51
+ - name : Show Context
52
+ run : |
53
+ printenv
54
+ echo "$GITHUB_CONTEXT"
55
+ shell : bash
56
+ env :
57
+ GITHUB_CONTEXT : ${{ toJson(github) }}
58
+
59
+ - name : Check branch and release type
60
+ uses :
IABTechLab/uid2-shared-actions/actions/[email protected]
61
+ with :
62
+ release_type : ${{ inputs.release_type }}
63
+
46
64
- name : Set up JDK
47
65
uses : actions/setup-java@v3
48
66
with :
49
67
distribution : ' temurin'
50
68
java-version : ${{ inputs.java_version }}
51
69
52
70
- name : Checkout full history
53
- uses : actions/checkout@v3
71
+ uses : actions/checkout@v4
54
72
with :
55
73
# git-restore-mtime requires full git history. The default fetch-depth value (1) creates a shallow checkout.
56
74
fetch-depth : 0
@@ -64,13 +82,13 @@ jobs:
64
82
with :
65
83
type : ${{ inputs.release_type }}
66
84
version_number : ${{ inputs.version_number_input }}
67
- branch_name : ${{ env.BRANCH_NAME }}
85
+ branch_name : ${{ github.ref }}
68
86
69
87
- name : Update pom.xml
70
88
run : |
71
89
current_version=$(grep -o '<version>.*</version>' pom.xml | head -1 | sed 's/<version>\(.*\)<\/version>/\1/')
72
90
new_version=${{ steps.version.outputs.new_version }}
73
- sed -i "0,/$current_version/s//$new_version/" pom.xml
91
+ sed -i "0,/$current_version/s/$current_version /$new_version/" pom.xml
74
92
echo "Version number updated from $current_version to $new_version"
75
93
76
94
- name : Package JAR
@@ -88,25 +106,25 @@ jobs:
88
106
author_name : Release Workflow
89
107
90
108
message : ' Released ${{ inputs.release_type }} version: ${{ steps.version.outputs.new_version }}'
109
+ tag : v${{ steps.version.outputs.new_version }}
91
110
92
111
- name : Log in to the Docker container registry
93
- uses : docker/login-action@v2
112
+ uses : docker/login-action@v3
94
113
with :
95
114
registry : ${{ env.REGISTRY }}
96
115
username : ${{ github.actor }}
97
116
password : ${{ secrets.GITHUB_TOKEN }}
98
117
99
118
- name : Extract metadata (tags, labels) for Docker
100
119
id : meta
101
- uses : docker/metadata-action@v4
120
+ uses : docker/metadata-action@v5
102
121
with :
103
122
images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
104
123
tags : |
105
124
type=raw,value=${{ steps.version.outputs.new_version }}-${{ inputs.cloud_provider }}
106
- type=raw,value=${{ inputs.tag }}
107
125
108
126
- name : Build and export to Docker
109
- uses : docker/build-push-action@v3
127
+ uses : docker/build-push-action@v5
110
128
with :
111
129
context : .
112
130
load : true
@@ -117,7 +135,7 @@ jobs:
117
135
IMAGE_VERSION=${{ steps.version.outputs.new_version }}
118
136
119
137
- name : Generate Trivy vulnerability scan report
120
- uses : aquasecurity/trivy-action@0.12 .0
138
+ uses : aquasecurity/trivy-action@0.14 .0
121
139
if : inputs.publish_vulnerabilities == 'true'
122
140
with :
123
141
image-ref : ${{ steps.meta.outputs.tags }}
@@ -135,7 +153,7 @@ jobs:
135
153
sarif_file : ' trivy-results.sarif'
136
154
137
155
- name : Test with Trivy vulnerability scanner
138
- uses : aquasecurity/trivy-action@0.12 .0
156
+ uses : aquasecurity/trivy-action@0.14 .0
139
157
with :
140
158
image-ref : ${{ steps.meta.outputs.tags }}
141
159
format : ' table'
@@ -145,7 +163,7 @@ jobs:
145
163
hide-progress : true
146
164
147
165
- name : Push to Docker
148
- uses : docker/build-push-action@v3
166
+ uses : docker/build-push-action@v5
149
167
with :
150
168
context : .
151
169
push : true
@@ -154,3 +172,24 @@ jobs:
154
172
build-args : |
155
173
JAR_VERSION=${{ steps.version.outputs.new_version }}
156
174
IMAGE_VERSION=${{ steps.version.outputs.new_version }}
175
+
176
+ - name : Build Changelog
177
+ id : github_release
178
+ if : ${{ env.IS_RELEASE == 'true' }}
179
+ uses : mikepenz/release-changelog-builder-action@v3
180
+ with :
181
+ configurationJson : |
182
+ {
183
+ "template": "#{{CHANGELOG}}\n## Installation\n```\ndocker pull ${{ steps.meta.outputs.tags }}\n```\n\n## Changelog\n#{{UNCATEGORIZED}}",
184
+ "pr_template": " - #{{TITLE}} - ( PR: ##{{NUMBER}} )"
185
+ }
186
+ env :
187
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
188
+
189
+ - name : Create Release
190
+ if : ${{ env.IS_RELEASE == 'true' }}
191
+ uses : softprops/action-gh-release@v1
192
+ with :
193
+ name : ${{ steps.version.outputs.new_version }}
194
+ body : ${{ steps.github_release.outputs.changelog }}
195
+ draft : true
0 commit comments