14
14
type : string
15
15
default : >-
16
16
[""]
17
+ custom-version :
18
+ required : false
19
+ description : ' Version of release in the form of "x.x.x" string, specified by user instead of automatically generated semantic release'
20
+ type : string
21
+ default : " "
22
+ execute-tests-on-push-to-develop :
23
+ required : false
24
+ description : ' Flag to run all tests on push to develop branch'
25
+ type : string
26
+ default : ' false'
27
+ execute-tests-on-push-to-release :
28
+ required : false
29
+ description : ' Flag to run all tests on push to release branch'
30
+ type : string
31
+ default : ' false'
17
32
k8s-environment :
18
33
required : false
19
34
description : Specifies which environment to use for k8s testing. ["production", "staging"]
@@ -77,6 +92,24 @@ concurrency:
77
92
group : ${{ github.head_ref || github.run_id }}
78
93
cancel-in-progress : true
79
94
jobs :
95
+ validate-custom-version :
96
+ runs-on : ubuntu-latest
97
+ if : ${{ github.event.inputs.custom-version != '' }}
98
+ steps :
99
+ - uses : actions/checkout@v4
100
+ - name : Validate custom version
101
+ run : |
102
+ if [[ ! ${{ github.event.inputs.custom-version }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
103
+ echo "Invalid custom version provided. Please provide a valid semver version."
104
+ exit 1
105
+ fi
106
+
107
+ git fetch --tags
108
+ if [ "$(git tag -l 'v${{ github.event.inputs.custom-version }}')" ]; then
109
+ echo "The provided version already exists. Please provide a unique version."
110
+ exit 1
111
+ fi
112
+
80
113
setup-workflow :
81
114
runs-on : ubuntu-latest
82
115
outputs :
@@ -140,7 +173,10 @@ jobs:
140
173
fi
141
174
;;
142
175
"push")
143
- if ${{ github.ref_name == 'main' }} || ${{ github.ref_name == 'develop' }} || ${{ github.ref_type == 'tag' }} ; then
176
+ if ${{ github.ref_name == 'main' }} ||
177
+ ${{ github.ref_name == 'develop' && inputs.execute-tests-on-push-to-develop == 'true' }} ||
178
+ ${{ startsWith(github.ref_name, 'release/') && inputs.execute-tests-on-push-to-release == 'true' }} ||
179
+ ${{ github.ref_type == 'tag' }} ; then
144
180
for test_type in "${TESTSET[@]}"; do
145
181
EXECUTE_LABELED["$test_type"]="true"
146
182
done
@@ -151,6 +187,13 @@ jobs:
151
187
EXECUTE_LABELED["$test_type"]="true"
152
188
done
153
189
;;
190
+ "workflow_dispatch")
191
+ if ${{ inputs.custom-version != '' }} ; then
192
+ for test_type in "${TESTSET[@]}"; do
193
+ EXECUTE_LABELED["$test_type"]="true"
194
+ done
195
+ fi
196
+ ;;
154
197
*)
155
198
echo "No tests were labeled for execution!"
156
199
;;
@@ -415,6 +458,7 @@ jobs:
415
458
build :
416
459
runs-on : ubuntu-latest
417
460
needs :
461
+ - validate-custom-version
418
462
- setup-workflow
419
463
- test-inventory
420
464
- meta
@@ -424,7 +468,7 @@ jobs:
424
468
- semgrep
425
469
- run-unit-tests
426
470
- fossa-scan
427
- if : ${{ !cancelled() && (needs.run-unit-tests.result == 'success' || needs.run-unit-tests.result == 'skipped') }}
471
+ if : ${{ !cancelled() && (needs.run-unit-tests.result == 'success' || needs.run-unit-tests.result == 'skipped') && (needs.validate-custom-version.result == 'success' || needs.validate-custom-version.result == 'skipped') }}
428
472
outputs :
429
473
buildname : ${{ steps.buildupload.outputs.name }}
430
474
permissions :
@@ -495,7 +539,7 @@ jobs:
495
539
- name : Determine the version to build
496
540
id : BuildVersion
497
541
run : |
498
- INPUT_SEMVER="${{ steps.semantic.outputs.new_release_version }}"
542
+ INPUT_SEMVER="${{ github.event.inputs.custom-version != '' && github.event.inputs.custom-version || steps.semantic.outputs.new_release_version }}"
499
543
echo "Initial semver ${INPUT_SEMVER}"
500
544
INPUT_PRNUMBER="${{ github.event.number }}"
501
545
SEMVER_REGEX='^v?[0-9]+\.[0-9]+\.[0-9]+$'
@@ -602,6 +646,7 @@ jobs:
602
646
build-3_9 :
603
647
runs-on : ubuntu-latest
604
648
needs :
649
+ - validate-custom-version
605
650
- setup-workflow
606
651
- test-inventory
607
652
- meta
@@ -613,7 +658,8 @@ jobs:
613
658
- fossa-scan
614
659
if : |
615
660
always() &&
616
- (needs.run-unit-tests-3_9.result == 'success' || needs.run-unit-tests-3_9.result == 'skipped')
661
+ (needs.run-unit-tests-3_9.result == 'success' || needs.run-unit-tests-3_9.result == 'skipped') &&
662
+ (needs.validate-custom-version.result == 'success' || needs.validate-custom-version.result == 'skipped')
617
663
permissions :
618
664
contents : write
619
665
packages : read
@@ -673,7 +719,7 @@ jobs:
673
719
GITHUB_TOKEN : ${{ github.token }}
674
720
- id : BuildVersion
675
721
run : |
676
- INPUT_SEMVER="${{ steps.semantic.outputs.new_release_version }}"
722
+ INPUT_SEMVER="${{ github.event.inputs.custom-version != '' && github.event.inputs.custom-version || steps.semantic.outputs.new_release_version }}"
677
723
echo "Initial semver ${INPUT_SEMVER}"
678
724
INPUT_PRNUMBER="${{ github.event.number }}"
679
725
SEMVER_REGEX='^v?[0-9]+\.[0-9]+\.[0-9]+$'
@@ -1819,7 +1865,10 @@ jobs:
1819
1865
${{ needs.setup.outputs.directory-path }}/diag*
1820
1866
1821
1867
run-scripted-input-tests-full-matrix :
1822
- if : ${{ !cancelled() && needs.build.result == 'success' && needs.test-inventory.outputs.scripted_inputs == 'true' && ( github.base_ref == 'main' || github.ref_name == 'main' ) && needs.setup-workflow.outputs.execute-scripted_inputs-labeled == 'true' }}
1868
+ if : |
1869
+ ( !cancelled() && needs.build.result == 'success' && needs.test-inventory.outputs.scripted_inputs == 'true' ) &&
1870
+ ( github.base_ref == 'main' || github.ref_name == 'main' || ( github.ref_name == 'develop' && inputs.execute-tests-on-push-to-develop == 'true' ) || ( startsWith(github.ref_name, 'release/') && inputs.execute-tests-on-push-to-release == 'true' ) ) &&
1871
+ ( needs.setup-workflow.outputs.execute-scripted_inputs-labeled == 'true' )
1823
1872
needs :
1824
1873
- build
1825
1874
- test-inventory
@@ -2044,12 +2093,13 @@ jobs:
2044
2093
${{ needs.setup.outputs.directory-path }}/diag*
2045
2094
2046
2095
pre-publish :
2047
- if : ${{ !cancelled() }}
2096
+ if : ${{ !cancelled() && needs.validate-custom-version.result == 'success' }}
2048
2097
# The following line will rename 'pre-publish' to 'pre-publish-not_main_pr' when PR is created towards main branch
2049
2098
# It is necessary to avoid confusion caused by githubactions considering pre-publish for both push to develop branch
2050
2099
# and pull_request to main branch events.
2051
2100
name : ${{ github.event_name == 'pull_request' && github.base_ref == 'main' && 'pre-publish' || 'pre-publish-not_main_pr' }}
2052
2101
needs :
2102
+ - validate-custom-version
2053
2103
- meta
2054
2104
- compliance-copyrights
2055
2105
- lint
@@ -2086,9 +2136,14 @@ jobs:
2086
2136
exit 1
2087
2137
2088
2138
publish :
2089
- if : ${{ !cancelled() && needs.pre-publish.result == 'success' && github.event_name != 'pull_request' && github.event_name != 'schedule' }}
2139
+ if : |
2140
+ (!cancelled() && needs.pre-publish.result == 'success' && github.event_name != 'pull_request' && github.event_name != 'schedule') ||
2141
+ (!cancelled() && needs.pre-publish.result == 'success' && github.event.inputs.custom-version != '' && needs.validate-custom-version.result == 'success')
2142
+ name : ${{ github.event.inputs.custom-version == '' && 'publish' || 'publish-custom-version' }}
2143
+
2090
2144
needs :
2091
2145
- pre-publish
2146
+ - validate-custom-version
2092
2147
runs-on : ubuntu-latest
2093
2148
permissions :
2094
2149
contents : write
@@ -2102,6 +2157,7 @@ jobs:
2102
2157
submodules : false
2103
2158
persist-credentials : false
2104
2159
- name : Semantic Release
2160
+ if : ${{ github.event.inputs.custom-version == '' }}
2105
2161
id : semantic
2106
2162
uses : splunk/semantic-release-action@v1.3
2107
2163
env :
@@ -2111,46 +2167,55 @@ jobs:
2111
2167
git_committer_email : ${{ secrets.SA_GH_USER_EMAIL }}
2112
2168
gpg_private_key : ${{ secrets.SA_GPG_PRIVATE_KEY }}
2113
2169
passphrase : ${{ secrets.SA_GPG_PASSPHRASE }}
2170
+ - name : Release custom version
2171
+ if : ${{ github.event.inputs.custom-version != '' }}
2172
+ id : custom
2173
+ uses : " softprops/action-gh-release@v2"
2174
+ with :
2175
+ token : " ${{ secrets.GH_TOKEN_ADMIN }}"
2176
+ tag_name : v${{ github.event.inputs.custom-version }}
2177
+ target_commitish : " ${{github.ref_name}}"
2178
+ make_latest : false
2114
2179
- name : Download package-deployment
2115
- if : ${{ steps.semantic.outputs.new_release_published == 'true' }}
2180
+ if : ${{ steps.semantic.outputs.new_release_published == 'true' || steps.custom.outputs.upload_url != '' }}
2116
2181
uses : actions/download-artifact@v4
2117
2182
id : download-package-deployment
2118
2183
with :
2119
2184
name : package-deployment
2120
2185
path : download/artifacts/
2121
2186
- name : Download package-splunkbase
2122
- if : ${{ steps.semantic.outputs.new_release_published == 'true' }}
2187
+ if : ${{ steps.semantic.outputs.new_release_published == 'true' || steps.custom.outputs.upload_url != '' }}
2123
2188
uses : actions/download-artifact@v4
2124
2189
id : download-package-splunkbase
2125
2190
with :
2126
2191
name : package-splunkbase
2127
2192
path : download/artifacts/deployment
2128
2193
- name : Download cim-compliance-report
2129
2194
id : download-cim-compliance-report
2130
- if : ${{ steps.semantic.outputs.new_release_published == 'true' }}
2195
+ if : ${{ steps.semantic.outputs.new_release_published == 'true' || steps.custom.outputs.upload_url != '' }}
2131
2196
continue-on-error : true
2132
2197
uses : actions/download-artifact@v4
2133
2198
with :
2134
2199
name : cim-compliance-report
2135
2200
path : download/artifacts/deployment
2136
2201
- name : Download cim-field-report
2137
2202
id : download-cim-field-report
2138
- if : ${{ steps.semantic.outputs.new_release_published == 'true' }}
2203
+ if : ${{ steps.semantic.outputs.new_release_published == 'true' || steps.custom.outputs.upload_url != '' }}
2139
2204
continue-on-error : true
2140
2205
uses : actions/download-artifact@v4
2141
2206
with :
2142
2207
name : cim-field-report
2143
2208
path : download/artifacts/deployment
2144
2209
- name : List of assets
2145
- if : ${{ steps.semantic.outputs.new_release_published == 'true' }}
2210
+ if : ${{ steps.semantic.outputs.new_release_published == 'true'|| steps.custom.outputs.upload_url != '' }}
2146
2211
run : |
2147
2212
ls -la ${{ steps.download-package-splunkbase.outputs.download-path }}
2148
2213
- name : Upload assets to release
2149
- if : ${{ steps.semantic.outputs.new_release_published == 'true' }}
2214
+ if : ${{ steps.semantic.outputs.new_release_published == 'true' || steps.custom.outputs.upload_url != '' }}
2150
2215
uses : svenstaro/upload-release-action@v2
2151
2216
with :
2152
2217
repo_token : ${{ github.token }}
2153
2218
file : ${{ steps.download-package-splunkbase.outputs.download-path }}/*
2154
2219
overwrite : true
2155
2220
file_glob : true
2156
- tag : v${{ steps.semantic.outputs.new_release_version }}
2221
+ tag : v${{ github.event.inputs.custom-version != '' && github.event.inputs.custom-version || steps.semantic.outputs.new_release_version }}
0 commit comments