Skip to content

Commit 00d53ec

Browse files
authored
Merge pull request #28 from IABTechLab/tjm-UID2-2281-gcp-component-build
Add the check for a Release to the shared action
2 parents cbdd7ff + 98f7233 commit 00d53ec

File tree

2 files changed

+36
-24
lines changed

2 files changed

+36
-24
lines changed

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

+5-24
Original file line numberDiff line numberDiff line change
@@ -49,25 +49,11 @@ jobs:
4949
jar_version: ${{ steps.version.outputs.new_version }}
5050
image_tag: ${{ steps.updatePom.outputs.image_tag }}
5151
steps:
52-
- name: Check if Release
52+
- name: Check branch and release type
5353
id: checkRelease
54-
run: |
55-
FORCE_RELEASE=${{ inputs.force_release == 'yes' }}
56-
FORCE_NOT_RELEASE=${{ inputs.force_release == 'not' }}
57-
CHECK_BRANCH_FOR_RELEASE=${{ inputs.force_release == 'branch' }}
58-
BRANCH_ALLOWS_RELEASE=${{ (inputs.release_type == 'Major' || inputs.release_type == 'Minor' || inputs.release_type == 'Patch') && (github.event.repository.default_branch == github.ref_name) }}
59-
if $FORCE_RELEASE; then
60-
ISRELEASE=true
61-
elif $FORCE_NOT_RELEASE; then
62-
ISRELEASE=false
63-
elif ($CHECK_BRANCH_FOR_RELEASE) && ($BRANCH_ALLOWS_RELEASE); then
64-
ISRELEASE=true
65-
else
66-
ISRELEASE=false
67-
fi
68-
echo "Setting IS_RELEASE to $ISRELEASE"
69-
echo "IS_RELEASE=$ISRELEASE" >> $GITHUB_OUTPUT
70-
echo "NOT_SNAPSHOT=$BRANCH_ALLOWS_RELEASE" >> $GITHUB_OUTPUT
54+
uses: IABTechLab/uid2-shared-actions/actions/[email protected]
55+
with:
56+
release_type: ${{ inputs.release_type }}
7157

7258
- name: Show Context
7359
run: |
@@ -77,12 +63,7 @@ jobs:
7763
env:
7864
GITHUB_CONTEXT: ${{ toJson(github) }}
7965
IS_RELEASE: ${{ steps.checkRelease.outputs.IS_RELEASE }}
80-
81-
- name: Check branch and release type
82-
uses: IABTechLab/uid2-shared-actions/actions/[email protected]
83-
with:
84-
release_type: ${{ inputs.release_type }}
85-
66+
8667
- name: Set up JDK
8768
uses: actions/setup-java@v3
8869
with:

actions/check_branch_and_release_type/action.yaml

+31
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,41 @@ inputs:
44
release_type:
55
description: The type of version number to return. Must be one of [Snapshot, Patch, Minor or Major]
66
required: true
7+
force_release:
8+
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.
9+
default: 'branch'
10+
outputs:
11+
is_release:
12+
description: True if a release should be created
13+
value: ${{ steps.checkRelease.outputs.IS_RELEASE }}
14+
not_snapshot:
15+
description: True if the release type is not a snapshot or pre-release build
16+
value: ${{ steps.checkRelease.outputs.NOT_SNAPSHOT }}
717
runs:
818
using: "composite"
919

1020
steps:
21+
- name: Check if Release
22+
id: checkRelease
23+
shell: bash
24+
run: |
25+
FORCE_RELEASE=${{ inputs.force_release == 'yes' }}
26+
FORCE_NOT_RELEASE=${{ inputs.force_release == 'no' }}
27+
CHECK_BRANCH_FOR_RELEASE=${{ inputs.force_release == 'branch' }}
28+
BRANCH_ALLOWS_RELEASE=${{ (inputs.release_type == 'Major' || inputs.release_type == 'Minor' || inputs.release_type == 'Patch') && (github.event.repository.default_branch == github.ref_name) }}
29+
if $FORCE_RELEASE; then
30+
ISRELEASE=true
31+
elif $FORCE_NOT_RELEASE; then
32+
ISRELEASE=false
33+
elif ($CHECK_BRANCH_FOR_RELEASE) && ($BRANCH_ALLOWS_RELEASE); then
34+
ISRELEASE=true
35+
else
36+
ISRELEASE=false
37+
fi
38+
echo "Setting IS_RELEASE to $ISRELEASE"
39+
echo "IS_RELEASE=$ISRELEASE" >> $GITHUB_OUTPUT
40+
echo "NOT_SNAPSHOT=$BRANCH_ALLOWS_RELEASE" >> $GITHUB_OUTPUT
41+
1142
- name: Fail if Pre-release on Default branch
1243
if: ${{ inputs.release_type == 'Snapshot' && github.event.repository.default_branch == github.ref_name }}
1344
uses: actions/github-script@v7

0 commit comments

Comments
 (0)