Skip to content

Commit 62f49cd

Browse files
committed
Conditionally run steps
1 parent e0eb19a commit 62f49cd

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

.github/workflows/release.yml

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,14 @@ jobs:
7171
run_job: true
7272
runs-on: ubuntu-22.04
7373
steps:
74-
- if: ${{ !matrix.run_job }}
75-
run: |
76-
echo "Erlang/OTP ${{ matrix.otp_build }} build not required for this branch - skipping job"
77-
exit 0
78-
7974
- uses: actions/checkout@v4
75+
if: matrix.run_job
8076
with:
8177
fetch-depth: 50
8278

8379
- name: "Build Release"
8480
uses: ./.github/workflows/release_pre_built
81+
if: matrix.run_job
8582
with:
8683
otp_version: ${{ matrix.otp_version }}
8784
otp: ${{ matrix.otp }}
@@ -90,36 +87,39 @@ jobs:
9087
- name: "Attest docs provenance"
9188
uses: actions/attest-build-provenance@v2
9289
id: attest-docs-provenance
93-
if: ${{ matrix.build_docs }}
90+
if: matrix.run_job && matrix.build_docs
9491
with:
9592
subject-path: "Docs.zip"
93+
9694
- name: "Copy docs provenance"
97-
if: ${{ matrix.build_docs }}
95+
if: matrix.run_job && matrix.build_docs
9896
run: cp "$ATTESTATION" Docs.zip.sigstore
9997
env:
10098
ATTESTATION: "${{ steps.attest-docs-provenance.outputs.bundle-path }}"
10199

102100
- name: Create Docs Hashes
103-
if: ${{ matrix.build_docs }}
101+
if: matrix.run_job && matrix.build_docs
104102
run: |
105103
shasum -a 1 Docs.zip > Docs.zip.sha1sum
106104
shasum -a 256 Docs.zip > Docs.zip.sha256sum
107105
108106
- name: "Upload linux release artifacts"
109107
uses: actions/upload-artifact@v4
108+
if: matrix.run_job
110109
with:
111110
name: build-linux-elixir-otp-${{ matrix.otp }}
112111
path: elixir-otp-${{ matrix.otp }}.zip
113112

114113
- name: "Upload windows release artifacts"
115114
uses: actions/upload-artifact@v4
115+
if: matrix.run_job
116116
with:
117117
name: build-windows-elixir-otp-${{ matrix.otp }}
118118
path: elixir-otp-${{ matrix.otp }}.exe
119119

120120
- name: "Upload doc artifacts"
121121
uses: actions/upload-artifact@v4
122-
if: ${{ matrix.build_docs }}
122+
if: matrix.run_job && matrix.build_docs
123123
with:
124124
name: Docs
125125
path: Docs.zip*
@@ -145,15 +145,9 @@ jobs:
145145
with:
146146
name: build-${{ matrix.flavor }}-elixir-otp-${{ matrix.otp }}
147147

148-
- name: "Check download status"
149-
if: steps.download.outcome != 'success'
150-
run: |
151-
echo "Erlang/OTP ${{ matrix.otp_build }} build not found - skipping job"
152-
exit 0
153-
154148
- name: "Sign files with Trusted Signing"
155-
if: github.repository == 'elixir-lang/elixir' && matrix.flavor == 'windows'
156149
uses: azure/[email protected]
150+
if: github.repository == 'elixir-lang/elixir' && matrix.flavor == 'windows' && steps.download.outcome == 'success'
157151
with:
158152
azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
159153
azure-client-id: ${{ secrets.AZURE_CLIENT_ID }}
@@ -168,18 +162,21 @@ jobs:
168162
timestamp-digest: SHA256
169163

170164
- name: "Attest release provenance"
171-
uses: actions/attest-build-provenance@v2
172165
id: attest-provenance
166+
uses: actions/attest-build-provenance@v2
167+
if: steps.download.outcome == 'success'
173168
with:
174169
subject-path: ${{ env.RELEASE_FILE }}
170+
175171
- name: "Copy release .zip provenance"
172+
if: steps.download.outcome == 'success'
176173
shell: bash
177174
run: cp "$ATTESTATION" "${RELEASE_FILE}.sigstore"
178175
env:
179176
ATTESTATION: "${{ steps.attest-provenance.outputs.bundle-path }}"
180177

181178
- name: Create Release Hashes
182-
if: matrix.flavor == 'windows'
179+
if: matrix.flavor == 'windows' && steps.download.outcome == 'success'
183180
shell: pwsh
184181
run: |
185182
$sha1 = Get-FileHash "$env:RELEASE_FILE" -Algorithm SHA1
@@ -189,14 +186,15 @@ jobs:
189186
$sha256.Hash.ToLower() + " " + $env:RELEASE_FILE | Out-File "$env:RELEASE_FILE.sha256sum"
190187
191188
- name: Create Release Hashes
192-
if: matrix.flavor == 'linux'
189+
if: matrix.flavor == 'linux' && steps.download.outcome == 'success'
193190
shell: bash
194191
run: |
195192
shasum -a 1 "$RELEASE_FILE" > "${RELEASE_FILE}.sha1sum"
196193
shasum -a 256 "$RELEASE_FILE" > "${RELEASE_FILE}.sha256sum"
197194
198195
- name: "Upload linux release artifacts"
199196
uses: actions/upload-artifact@v4
197+
if: steps.download.outcome == 'success'
200198
with:
201199
name: sign-${{ matrix.flavor }}-elixir-otp-${{ matrix.otp }}
202200
path: ${{ env.RELEASE_FILE }}*

0 commit comments

Comments
 (0)