11name : Haskell CI
22
33on :
4+ merge_group :
45 pull_request :
56 push :
67 # we need this to populate cache for `main` branch to make it available to the child branches, see
@@ -140,15 +141,30 @@ jobs:
140141 KEEP_WORKSPACE : 1
141142 run : cabal test all --enable-tests --test-show-details=direct
142143
143- check :
144- needs : build
144+ build-successful :
145+ needs : [build]
146+ if : ${{ always() }}
147+ runs-on : ubuntu-latest
148+ steps :
149+ - name : Check if any previous job failed
150+ run : |
151+ if [[ "${{ needs.build.result }}" == "failure" ]]; then
152+ # this ignores skipped dependencies
153+ echo 'Required jobs failed to build.'
154+ exit 1
155+ else
156+ echo 'Build complete'
157+ fi
158+
159+ make-tag :
160+ needs : build-successful
161+ if : ${{ github.ref == 'refs/heads/main' }}
145162 runs-on : ubuntu-latest
146163 outputs :
147164 tag : ${{ steps.tag.outputs.tag }}
148165
149166 steps :
150167 - uses : actions/checkout@v3
151-
152168 - name : Check if cabal project is sane
153169 run : |
154170 PROJECT_DIR="$PWD"
@@ -160,7 +176,6 @@ jobs:
160176
161177 - name : Tag new version
162178 id : tag
163- if : ${{ github.ref == 'refs/heads/main' }}
164179 run : |
165180 package_version="$(cat *.cabal | grep '^version:' | cut -d : -f 2 | xargs)"
166181
@@ -176,19 +191,22 @@ jobs:
176191
177192 echo "::set-output name=tag::v$package_version"
178193 fi
194+ else
195+ echo "Tag v$package_version already exists. Not making new git tag."
179196 fi
180197
181- - name : Show tag
198+ - name : Show new tag
199+ if : steps.tag.outputs.tag != ''
182200 run : |
183201 echo "Ref: ${{ github.ref }}"
184202 echo "Tag: ${{ steps.tag.outputs.tag }}"
185203
186204
187205 release :
188- needs : [build, check ]
206+ needs : [make-tag ]
189207 runs-on : ubuntu-latest
190208
191- if : ${{ needs.check .outputs.tag != '' || startsWith(github.ref, 'refs/tags/v') }}
209+ if : ${{ needs.make-tag .outputs.tag != '' || startsWith(github.ref, 'refs/tags/v') }}
192210
193211 outputs :
194212 upload_url : ${{ steps.create_release.outputs.upload_url }}
@@ -249,8 +267,9 @@ jobs:
249267 id : create_release
250268 uses : softprops/action-gh-release@v2
251269 with :
252- tag_name : ${{ needs.check .outputs.tag != '' && needs.check .outputs.tag || github.ref_name }}
253- name : Release ${{ needs.check .outputs.tag != '' && needs.check .outputs.tag || github.ref_name }}
270+ tag_name : ${{ needs.make-tag .outputs.tag != '' && needs.make-tag .outputs.tag || github.ref_name }}
271+ name : Release ${{ needs.make-tag .outputs.tag != '' && needs.make-tag .outputs.tag || github.ref_name }}
254272 body_path : changelog.txt
255273 draft : false
256274 prerelease : false
275+
0 commit comments