Skip to content

Commit 9a88a64

Browse files
authored
Merge pull request #24 from IABTechLab/tjm-UID2-2294-public-operator-component-build
Update docker pipeline to force a release not to be created.
2 parents 3a7b597 + 6cfaaa5 commit 9a88a64

File tree

1 file changed

+44
-13
lines changed

1 file changed

+44
-13
lines changed

.github/workflows/shared-publish-docker-versioned.yaml

+44-13
Original file line numberDiff line numberDiff line change
@@ -24,37 +24,57 @@ on:
2424
type: string
2525
default: ''
2626
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.
2828
type: string
29-
default: ''
29+
default: 'branch'
3030
outputs:
3131
version_number_output:
3232
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 }}
3537
env:
3638
REGISTRY: ghcr.io
3739
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-
4040
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:
4342
runs-on: ubuntu-latest
4443
permissions:
4544
contents: write
4645
security-events: write
4746
packages: write
4847
outputs:
4948
jar_version: ${{ steps.version.outputs.new_version }}
49+
image_tag: ${{ steps.updatePom.outputs.image_tag }}
5050
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+
5170
- name: Show Context
5271
run: |
5372
printenv
5473
echo "$GITHUB_CONTEXT"
5574
shell: bash
5675
env:
5776
GITHUB_CONTEXT: ${{ toJson(github) }}
77+
IS_RELEASE: ${{ steps.checkRelease.outputs.IS_RELEASE }}
5878

5979
- name: Check branch and release type
6080
uses: IABTechLab/uid2-shared-actions/actions/[email protected]
@@ -85,11 +105,13 @@ jobs:
85105
branch_name: ${{ github.ref }}
86106

87107
- name: Update pom.xml
108+
id: updatePom
88109
run: |
89110
current_version=$(grep -o '<version>.*</version>' pom.xml | head -1 | sed 's/<version>\(.*\)<\/version>/\1/')
90111
new_version=${{ steps.version.outputs.new_version }}
91112
sed -i "0,/$current_version/s/$current_version/$new_version/" pom.xml
92113
echo "Version number updated from $current_version to $new_version"
114+
echo "image_tag=${{ steps.version.outputs.new_version }}-${{ inputs.cloud_provider }}" >> $GITHUB_OUTPUT
93115
94116
- name: Package JAR
95117
id: package
@@ -99,7 +121,16 @@ jobs:
99121
echo "git_commit=$(git show --format="%h" --no-patch)" >> $GITHUB_OUTPUT
100122
101123
- 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+
author_email: [email protected]
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' }}
103134
uses: EndBug/add-and-commit@v9
104135
with:
105136
add: 'pom.xml version.json'
@@ -121,7 +152,7 @@ jobs:
121152
with:
122153
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
123154
tags: |
124-
type=raw,value=${{ steps.version.outputs.new_version }}-${{ inputs.cloud_provider }}
155+
type=raw,value=${{ steps.updatePom.outputs.image_tag }}
125156
126157
- name: Build and export to Docker
127158
uses: docker/build-push-action@v5
@@ -175,19 +206,19 @@ jobs:
175206
176207
- name: Build Changelog
177208
id: github_release
178-
if: ${{ env.IS_RELEASE == 'true' }}
209+
if: ${{ steps.checkRelease.outputs.IS_RELEASE == 'true' }}
179210
uses: mikepenz/release-changelog-builder-action@v3
180211
with:
181212
configurationJson: |
182213
{
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}}",
184215
"pr_template": " - #{{TITLE}} - ( PR: ##{{NUMBER}} )"
185216
}
186217
env:
187218
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
188219

189220
- name: Create Release
190-
if: ${{ env.IS_RELEASE == 'true' }}
221+
if: ${{ steps.checkRelease.outputs.IS_RELEASE == 'true' }}
191222
uses: softprops/action-gh-release@v1
192223
with:
193224
name: ${{ steps.version.outputs.new_version }}

0 commit comments

Comments
 (0)