Skip to content

Commit 5c1a8fd

Browse files
indroraclaude
andcommitted
Gate release creation on a successful build (prepare -> build -> release)
Insert a build phase between prepare and release in starter.yml so that a build failure blocks the GitHub release from being created. Exactly one build path runs based on detected language: - C#: compile the assembly (no release_url, build-only validation) - Go: goreleaser `build --snapshot` (no release_version, validates only) - other: a no-op step so every project type has a build before release The release job waits on all three and runs when each is success or skipped, so the untaken paths don't block it. Existing post-release artifact upload behavior is unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 666e1bf commit 5c1a8fd

1 file changed

Lines changed: 58 additions & 1 deletion

File tree

.github/workflows/starter.yml

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,65 @@ jobs:
115115
run:
116116
echo "platform_matrix=`cat integration-manifest.json | jq '.platform_matrix'`" | tee -a $GITHUB_OUTPUT | tee -a $GITHUB_STEP_SUMMARY
117117

118+
# ---------------------------------------------------------------------------
119+
# Build phase: prepare -> [dotnet | go | other] build -> release
120+
#
121+
# Exactly one of the three build jobs below runs, based on the detected
122+
# language. Each compiles/validates the project WITHOUT creating or uploading
123+
# to a release (no release_url/release_version is passed). The release job
124+
# then waits on all three, so a build failure blocks the release. The "other"
125+
# job is a no-op that guarantees there is always a build step before release.
126+
# ---------------------------------------------------------------------------
127+
128+
# .NET path: compile the assembly to validate the build.
129+
call-dotnet-build-validation-workflow:
130+
needs: [ check-token-workflow, call-get-primary-language, call-assign-from-json-workflow ]
131+
if: needs.call-get-primary-language.outputs.primary_language == 'C#'
132+
uses: keyfactor/actions/.github/workflows/dotnet-build-and-release.yml@v4
133+
with:
134+
release_dir: ${{ needs.call-assign-from-json-workflow.outputs.release_dir }}
135+
release_project: ${{ needs.call-assign-from-json-workflow.outputs.release_project }}
136+
integration_type: ${{ needs.call-assign-from-json-workflow.outputs.integration_type }}
137+
secrets:
138+
token: ${{ secrets.token }}
139+
140+
# Go path: with no release_version, goreleaser runs `build --snapshot`, which
141+
# validates the build without producing a release.
142+
call-go-build-validation-workflow:
143+
needs: [ check-token-workflow, call-get-primary-language, call-goreleaser-exists ]
144+
if: needs.call-get-primary-language.outputs.primary_language == 'Go' && needs.call-goreleaser-exists.outputs.goreleaser-exists == 'true'
145+
uses: keyfactor/actions/.github/workflows/go-build-and-release.yml@v4
146+
secrets:
147+
token: ${{ secrets.GITHUB_TOKEN }}
148+
gpg_key: ${{ secrets.gpg_key }}
149+
gpg_pass: ${{ secrets.gpg_pass }}
150+
151+
# Other path: no build to perform, but keep a step before release so the
152+
# prepare -> build -> release shape holds for every project type.
153+
build-other:
154+
needs: [ check-token-workflow, call-get-primary-language, call-goreleaser-exists ]
155+
if: |
156+
needs.call-get-primary-language.outputs.primary_language != 'C#' &&
157+
!(needs.call-get-primary-language.outputs.primary_language == 'Go' && needs.call-goreleaser-exists.outputs.goreleaser-exists == 'true')
158+
runs-on: ubuntu-latest
159+
steps:
160+
- name: No build required
161+
run: echo "No language-specific build for primary language '${{ needs.call-get-primary-language.outputs.primary_language }}'; proceeding to release."
162+
118163
call-create-github-release-workflow:
119-
needs: check-token-workflow
164+
needs:
165+
- check-token-workflow
166+
- call-dotnet-build-validation-workflow
167+
- call-go-build-validation-workflow
168+
- build-other
169+
# Run once the build phase has passed. Exactly one build job runs; the
170+
# others are skipped, and a skipped build must not block the release.
171+
if: |
172+
always() &&
173+
needs.check-token-workflow.result == 'success' &&
174+
(needs.call-dotnet-build-validation-workflow.result == 'success' || needs.call-dotnet-build-validation-workflow.result == 'skipped') &&
175+
(needs.call-go-build-validation-workflow.result == 'success' || needs.call-go-build-validation-workflow.result == 'skipped') &&
176+
(needs.build-other.result == 'success' || needs.build-other.result == 'skipped')
120177
uses: Keyfactor/actions/.github/workflows/github-release.yml@v4
121178

122179
call-dotnet-build-and-release-workflow:

0 commit comments

Comments
 (0)