1- name : Release
1+ name : Release Webhook Listener
22
33on :
44 push :
5- branches : [master ]
5+ branches : [main ]
66
77jobs :
88 build :
@@ -14,32 +14,57 @@ jobs:
1414 node-version : " 18.x"
1515 - run : npm install
1616
17- - name : get-package-details
18- id : package
19- uses :
codex-team/[email protected] 2017 - name : install npm packall
2118 run : npm install npm-pack-all
2219
2320 - run : node node_modules/.bin/npm-pack-all
24- - uses : Klemensas/action-autotag@stable
25- id : update_tag
21+
22+ # The below action will see the existing tags and will bump the current ones and this is only used to check whether the given tag already exists or not
23+ # We will be using the previous tag to compare with the current tag in the package.json
24+ # If both match then no new release would be triggered
25+ # Else New release will be created
26+ - name : Bump version and push tag
27+ id : tag_version
28+ uses :
mathieudutour/[email protected] 2629 with :
27- GITHUB_TOKEN : " ${{ secrets.GITHUB_TOKEN }}"
28- tag_prefix : " v"
30+ github_token : ${{ secrets.GITHUB_TOKEN }}
31+ default_bump : false
32+ # Getting the version info from package.json
33+ - name : get-npm-version
34+ id : package-version
35+ uses :
martinbeentjes/[email protected] 36+ # Here we are checking whether this is the first release or not and then checking if it is release or not
37+ - name : check-first-release
38+ env :
39+ First_Release : ${{steps.tag_version.outputs.previous_tag=='v0.0.0'}}
40+ run : |
41+ if ${First_Release} == true; then
42+ echo "fr=true" >> $GITHUB_ENV
43+ echo "flag set to true"
44+ else
45+ echo "fr=false" >> $GITHUB_ENV
46+ echo "flag set to false"
47+ fi
48+ - name : check-release-version
49+ if : ${{env.fr=='false'}}
50+ env :
51+ old_version : ${{steps.tag_version.outputs.previous_tag}}
52+ new_version : v${{steps.package-version.outputs.current-version}}
53+ run : |
54+ echo ${old_version}
55+ echo ${new_version}
56+ echo ${{env.old_version==env.new_version}}
57+ if ${{env.old_version!=env.new_version}}; then
58+ echo "fr=true" >> $GITHUB_ENV
59+ echo "flag set to true"
60+ else
61+ echo "fr=false" >> $GITHUB_ENV
62+ echo "flag set to false"
63+ fi
2964 - name : Create Release
30- if : steps.update_tag.outputs.tagname
3165 id : create_release
32- env :
33- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
34- run : gh release create v${{ steps.update_tag.outputs.version }} --title "Release ${{ steps.update_tag.outputs.version }}" --generate-notes
35- - name : Upload Release Asset
36- if : steps.update_tag.outputs.tagname
37- id : upload-release-asset
38- uses : actions/upload-release-asset@v1
66+ if : ${{env.fr=='true'}}
3967 env :
4068 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
41- with :
42- upload_url : ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing its ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
43- asset_path : ./contentstack-webhook-listener-${{ steps.package.outputs.version }}.tgz
44- asset_name : contentstack-webhook-listener-${{ steps.package.outputs.version }}.tgz
45- asset_content_type : application/tgz
69+ run : gh release create v${{steps.package-version.outputs.current-version}} --title "Release ${{steps.package-version.outputs.current-version}}" --generate-notes ./contentstack-webhook-listener-${{ steps.package-version.outputs.current-version }}.tgz
70+
0 commit comments