@@ -143,6 +143,8 @@ jobs:
143143 - dependency-vulnerability-analysis
144144 - sast-snyk
145145 - sast-iac-trivy-hadolint
146+ outputs :
147+ is-dryrun-version-bumped : ${{ steps.step1.outputs.is-dryrun-version-bumped }}
146148 steps :
147149 - uses : actions/checkout@v4
148150 with :
@@ -153,7 +155,7 @@ jobs:
153155 - id : bump-version
154156 uses :
abhisheksr01/github-actions/[email protected] 155157 with :
156- dry-run : true
158+ dry-run : true # Since we are setting dryrun argument the bump-version will always be available until 'current-version' is pushed as release
157159 - name : check-bump-version-output
158160 run : |
159161 echo "previous-version: ${{ steps.bump-version.outputs.previous-version }}"
@@ -170,6 +172,7 @@ jobs:
170172 - name : Set up Docker Buildx
171173 uses : docker/setup-buildx-action@v3
172174 - name : Docker meta
175+ if : ${{ steps.bump-version.outputs.is-dryrun-version-bumped == 'true' }}
173176 id : meta
174177 uses : docker/metadata-action@v5
175178 with :
@@ -188,10 +191,39 @@ jobs:
188191 "org.opencontainers.image.revision": ${{ github.sha }},
189192 "org.opencontainers.image.licenses": "MIT"
190193 - name : Build and push
194+ if : ${{ steps.bump-version.outputs.is-dryrun-version-bumped == 'true' }}
191195 uses : docker/build-push-action@v6
192196 with :
193197 push : ${{ github.event_name != 'pull_request' && steps.bump-version.outputs.is-dryrun-version-bumped == 'true' }} # Only push on main branch & when version is bumped with dryrun. We will create tags and creates separately after proper testing
194198 tags : ${{ steps.meta.outputs.tags }}
195199 labels : ${{ steps.meta.outputs.labels }}
196200 sbom : true
197201 provenance : true
202+ create-release :
203+ if : ${{ needs.docker-build-push.outputs.is-dryrun-version-bumped == 'true' }}
204+ runs-on : ubuntu-latest
205+ permissions :
206+ contents : write # to be able to publish a GitHub release
207+ needs :
208+ - docker-build-push
209+ environment :
210+ name : approve-release # Manual Approval to decide if we are ready to push tags and release
211+ steps :
212+ - uses : actions/checkout@v4
213+ with :
214+ fetch-depth : 0
215+ fetch-tags : true
216+ -
uses :
abhisheksr01/github-actions/[email protected] # Publishing the tags217+ id : tag-version
218+ - name : Generate changelog
219+ run : cog changelog --at v${{ steps.bump-version.outputs.current-version }} -t full_hash > CHANGELOG.md
220+ - run : |
221+ set -euo pipefail
222+ echo "Creating release from tag $tag"
223+ gh release create "$tag" \
224+ --title="$tag" \
225+ --repo="$GITHUB_REPOSITORY" \
226+ --notes-file CHANGELOG.md
227+ env:
228+ tag: v${{ needs.tag-version.outputs.current-version }}
229+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
0 commit comments