@@ -216,17 +216,27 @@ on:
216
216
- source-zoom
217
217
- source-zuora
218
218
219
- basetag :
220
- description : ' Custom tag if you want the versioning to be based on a different tag than the latest '
219
+ customtag :
220
+ description : ' Custom tag (If entered, the image will be build using this tag) '
221
221
222
222
change_type :
223
- description : ' Choose between minor and patch (Major will be changed during upstream sync )'
223
+ description : ' Change type (only applicable when image build from main, choose n/a for resuing latest tag )'
224
224
required : true
225
225
type : choice
226
226
default : " minor"
227
227
options :
228
228
- minor
229
229
- patch
230
+ - n/a
231
+
232
+ sort_by :
233
+ description : ' Latest tag by'
234
+ required : true
235
+ type : choice
236
+ default : " version"
237
+ options :
238
+ - date
239
+ - version
230
240
jobs :
231
241
build-and-push :
232
242
runs-on : ubuntu-latest
@@ -243,44 +253,95 @@ jobs:
243
253
fetch-depth : 0
244
254
245
255
- name : Get previous tag
246
- id : previoustag
247
- uses : " WyriHaximus/github-action-get-previous-tag@v1"
256
+ if : ${{ github.event.inputs.customtag == '' }}
257
+ id : current_tag
258
+ uses :
" debanjan97/[email protected] "
248
259
env :
249
260
GITHUB_TOKEN : " ${{ secrets.GITHUB_TOKEN }}"
261
+ with :
262
+ sort : ${{ github.event.inputs.sort_by }}
263
+ stable : true # ignores alpha builds
250
264
251
- - name : Get Next Version
252
- id : nextversion
265
+ - name : Check if version bump is required
266
+ if : ${{ github.ref_name == 'main' }}
267
+ id : bump
268
+ run : |
269
+ if [ "${{ github.event.inputs.customtag }}" != "" ]; then
270
+ # custom tag exists, no version bump required
271
+ echo "required=false" >> $GITHUB_OUTPUT
272
+ exit 0
273
+ fi;
274
+
275
+ if [ "${{ github.event.inputs.change_type }}"="n/a" ]; then
276
+ echo "change type is marked n/a, assuming no version bump is required"
277
+ echo "required=false" >> $GITHUB_OUTPUT
278
+ exit 0
279
+ fi;
280
+
281
+ last_commit=${git rev-list -n 1 ${{ steps.current_tag.outputs.tag }}}
282
+ current_commit=${{ github.sha }}
283
+ if [ $last_commit = $current_commit ]; then
284
+ echo "no new commits from the last tag, no version bump is required"
285
+ required=false
286
+ else
287
+ required=true
288
+ fi;
289
+ echo "required=$required" >> $GITHUB_OUTPUT
290
+
291
+ - name : Calculate Next Versions
292
+ if : ${{ steps.bump.outputs.required == 'true' }}
293
+ id : calculatenextversion
253
294
uses : " WyriHaximus/github-action-next-semvers@v1"
254
295
with :
255
- version : ${{ github.event.inputs.basetag || steps.previoustag .outputs.tag }}
296
+ version : ${{ steps.current_tag .outputs.tag }}
256
297
257
- - name : Generate Next Version according to change_type
258
- id : version
298
+ - name : Generate New Version according to change_type
299
+ if : ${{ steps.bump.outputs.required == 'true' }}
300
+ id : newversion
259
301
run : |
260
302
if [ "${{ github.event.inputs.change_type }}" = "minor" ]; then
261
- nextversion =${{ steps.nextversion .outputs.v_minor }}
303
+ newversion =${{ steps.calculatenextversion .outputs.v_minor }}
262
304
else
263
- nextversion=${{ steps.nextversion.outputs.v_patch }}
305
+ newversion=${{ steps.calculatenextversion.outputs.v_patch }}
306
+ fi;
307
+ echo "version=$newversion" >> $GITHUB_OUTPUT
308
+
309
+ - name : Get Build Tag
310
+ id : buildtag
311
+ run : |
312
+ # if custom tag is present, return it
313
+ if [ "${{ github.event.inputs.customtag }}" != "" ]; then
314
+ tag="${{ github.event.inputs.customtag }}"
315
+ echo "tag=$tag" >> $GITHUB_OUTPUT
316
+ exit 0
264
317
fi;
318
+
265
319
source_branch_name="${GITHUB_REF##*/}"
266
- git_hash=$(git rev-parse --short "$GITHUB_SHA")
267
-
268
- # for dev branches, prefix "-alpha.<commit-hash>"
269
- if [ $source_branch_name != "main" ]; then
270
- nextversion=$nextversion"-alpha."$git_hash
320
+ if [ $source_branch_name = "main" ]; then
321
+ if [ "${{ steps.bump.outputs.required }}"="false" ]; then
322
+ # return current tag, if no new commits
323
+ echo "no version bump required, proceeding with current version"
324
+ tag=${{ steps.current_tag.outputs.tag }}
325
+ else
326
+ tag=${{ steps.newversion.outputs.version }}
327
+ fi;
328
+ else
329
+ # if branch is feature branch, append alpha.<commit_hash> to the latest tag
330
+ git_hash=$(git rev-parse --short "$GITHUB_SHA")
331
+ tag=${{ steps.current_tag.outputs.tag }}"-alpha."$git_hash
271
332
fi;
272
-
273
- echo "next_version=$nextversion" >> $GITHUB_OUTPUT
333
+ echo "tag=$tag" >> $GITHUB_OUTPUT
274
334
275
335
336
+ name : Check if the generated tag exists
276
337
id : checkTag
277
338
with :
278
- tag : ${{ steps.version .outputs.next_version }}
339
+ tag : ${{ steps.buildtag .outputs.tag }}
279
340
280
341
- name : Publish version as a tag
281
342
if : ${{ steps.checkTag.outputs.exists != 'true' }}
282
343
run : |
283
- git tag ${{ steps.version .outputs.next_version }}
344
+ git tag ${{ steps.buildtag .outputs.tag }}
284
345
git push --tag
285
346
286
347
- name : Build and Push
@@ -290,7 +351,7 @@ jobs:
290
351
file : ./airbyte-integrations/connectors/${{ github.event.inputs.connector }}/Dockerfile
291
352
push : true
292
353
platforms : linux/amd64
293
- tags : rudderstack/${{ github.event.inputs.connector }}:${{ steps.version .outputs.next_version }}
354
+ tags : rudderstack/${{ github.event.inputs.connector }}:${{ steps.buildtag .outputs.tag }}
294
355
295
356
296
357
0 commit comments