3131 - riscv64-musl-linux
3232 types :
3333 - completed
34- branches :
35- - release
3634
3735permissions :
3836 contents : write
@@ -41,10 +39,34 @@ permissions:
4139jobs :
4240 check-and-release :
4341 runs-on : ubuntu-latest
44- # Only run if the triggering workflow succeeded AND it ran on the release branch
45- if : ${{ github.event.workflow_run.head_branch == 'release' && github.event.workflow_run.conclusion == 'success' }}
4642 steps :
43+ - name : Log trigger information
44+ run : |
45+ echo "Triggered by workflow: ${{ github.event.workflow_run.name }}"
46+ echo "Workflow status: ${{ github.event.workflow_run.conclusion }}"
47+ echo "Branch: ${{ github.event.workflow_run.head_branch }}"
48+ echo "Commit SHA: ${{ github.event.workflow_run.head_sha }}"
49+
50+ - name : Validate release branch and workflow success
51+ id : validate
52+ run : |
53+ if [ "${{ github.event.workflow_run.head_branch }}" != "release" ]; then
54+ echo "Skipping: Not on release branch (on ${{ github.event.workflow_run.head_branch }})"
55+ echo "proceed=false" >> $GITHUB_OUTPUT
56+ exit 0
57+ fi
58+
59+ if [ "${{ github.event.workflow_run.conclusion }}" != "success" ]; then
60+ echo "Skipping: Workflow did not succeed (conclusion: ${{ github.event.workflow_run.conclusion }})"
61+ echo "proceed=false" >> $GITHUB_OUTPUT
62+ exit 0
63+ fi
64+
65+ echo "Validation passed: On release branch with successful workflow"
66+ echo "proceed=true" >> $GITHUB_OUTPUT
67+
4768 - name : Check all workflow statuses
69+ if : steps.validate.outputs.proceed == 'true'
4870 id : check-all
4971 uses : actions/github-script@v7
5072 with :
@@ -104,42 +126,64 @@ jobs:
104126
105127 const failed = [];
106128 const pending = [];
129+ const succeeded = [];
107130
108131 for (const name of target_workflows) {
109132 const run = latest_runs[name];
110- if (!run || run.status !== 'completed') {
133+ if (!run) {
134+ console.log(` ${name}: NO RUN FOUND`);
135+ pending.push(name);
136+ } else if (run.status !== 'completed') {
137+ console.log(` ${name}: ${run.status}`);
111138 pending.push(name);
112139 } else if (run.conclusion !== 'success') {
140+ console.log(` ${name}: completed with ${run.conclusion}`);
113141 failed.push(name);
142+ } else {
143+ console.log(` ${name}: success`);
144+ succeeded.push(name);
114145 }
115146 }
116147
148+ console.log(`\nSummary: ${succeeded.length} succeeded, ${pending.length} pending, ${failed.length} failed`);
149+
117150 if (pending.length > 0) {
118- console.log(`Waiting for other workflows to complete: ${pending.join(', ')}`);
151+ console.log(`Waiting for ${pending.length} workflows to complete: ${pending.join(', ')}`);
152+ core.setOutput("ready", "false");
153+ core.notice(`Release skipped: waiting for ${pending.length} workflows to complete`);
119154 return; // Exit successfully but do nothing; wait for next trigger
120155 }
121156
122157 if (failed.length > 0) {
123158 core.setFailed(`One or more workflows failed: ${failed.join(', ')}`);
159+ core.setOutput("ready", "false");
124160 return;
125161 }
126162
127163 console.log("All target workflows passed successfully!");
164+ core.notice("All required workflows passed - creating release");
128165 core.setOutput("ready", "true");
129166
130167 - name : Perform Release
131- if : steps.check-all.outputs.ready == 'true'
168+ if : steps.validate.outputs.proceed == 'true' && steps. check-all.outputs.ready == 'true'
132169 uses : actions/checkout@v4
133170 with :
134171 ref : ${{ github.event.workflow_run.head_sha }}
135172 fetch-depth : 0
136173
137174 - name : Get Version
138- if : steps.check-all.outputs.ready == 'true'
139- run : echo "VERSION=$(cat VERSION)" >> $GITHUB_ENV
175+ if : steps.validate.outputs.proceed == 'true' && steps.check-all.outputs.ready == 'true'
176+ run : |
177+ if [ ! -f VERSION ]; then
178+ echo "ERROR: VERSION file not found"
179+ exit 1
180+ fi
181+ VERSION=$(cat VERSION)
182+ echo "Creating release for version: $VERSION"
183+ echo "VERSION=$VERSION" >> $GITHUB_ENV
140184
141185 - name : Get Release Details
142- if : steps.check-all.outputs.ready == 'true'
186+ if : steps.validate.outputs.proceed == 'true' && steps. check-all.outputs.ready == 'true'
143187 id : release_details
144188 uses : actions/github-script@v7
145189 with :
@@ -178,7 +222,7 @@ jobs:
178222 core.setOutput("body", body);
179223
180224 - name : Create Release
181- if : steps.check-all.outputs.ready == 'true'
225+ if : steps.validate.outputs.proceed == 'true' && steps. check-all.outputs.ready == 'true'
182226 uses : softprops/action-gh-release@v1
183227 with :
184228 tag_name : v${{ env.VERSION }}
0 commit comments