11name : Release
22
33on :
4- workflow_run :
5- workflows : [CI]
6- types : [completed]
4+ push :
5+ tags :
6+ - " v* "
77
88permissions :
99 contents : write
10+ actions : read
1011
1112env :
1213 CARGO_TERM_COLOR : always
1314
1415jobs :
16+ # Wait for CI to pass
17+ wait-for-ci :
18+ runs-on : ubuntu-latest
19+ steps :
20+ - name : Wait for CI workflow to complete
21+ uses : actions/github-script@v7
22+ with :
23+ script : |
24+ const workflows = await github.rest.actions.listWorkflowRunsForRepo({
25+ owner: context.repo.owner,
26+ repo: context.repo.repo,
27+ event: 'push',
28+ head_sha: context.sha,
29+ });
30+
31+ const ciRun = workflows.data.workflow_runs.find(run => run.name === 'CI');
32+ if (!ciRun) {
33+ throw new Error('CI workflow not found');
34+ }
35+
36+ // Poll until CI completes
37+ let status = ciRun.status;
38+ let conclusion = ciRun.conclusion;
39+
40+ while (status !== 'completed') {
41+ await new Promise(resolve => setTimeout(resolve, 10000));
42+ const run = await github.rest.actions.getWorkflowRun({
43+ owner: context.repo.owner,
44+ repo: context.repo.repo,
45+ run_id: ciRun.id,
46+ });
47+ status = run.data.status;
48+ conclusion = run.data.conclusion;
49+ }
50+
51+ if (conclusion !== 'success') {
52+ throw new Error(`CI workflow failed with conclusion: ${conclusion}`);
53+ }
54+
1555 build :
16- # Only run if CI succeeded and this was triggered by a tag
17- if : |
18- github.event.workflow_run.conclusion == 'success' &&
19- github.event.workflow_run.event == 'push' &&
20- startsWith(github.event.workflow_run.head_branch, 'refs/tags/v')
56+ needs : wait-for-ci
2157 runs-on : ${{ matrix.os }}
2258 strategy :
2359 matrix :
3773
3874 steps :
3975 - uses : actions/checkout@v4
40- with :
41- ref : ${{ github.event.workflow_run.head_branch }}
4276
4377 - name : Install Rust
4478 uses : dtolnay/rust-toolchain@stable
@@ -88,10 +122,6 @@ jobs:
88122 release :
89123 needs : build
90124 runs-on : ubuntu-latest
91- if : |
92- github.event.workflow_run.conclusion == 'success' &&
93- github.event.workflow_run.event == 'push' &&
94- startsWith(github.event.workflow_run.head_branch, 'refs/tags/v')
95125 steps :
96126 - name : Download all artifacts
97127 uses : actions/download-artifact@v4
@@ -101,7 +131,6 @@ jobs:
101131 - name : Create Release
102132 uses : softprops/action-gh-release@v1
103133 with :
104- tag_name : ${{ github.event.workflow_run.head_branch }}
105134 files : artifacts/**/*
106135 draft : false
107136 prerelease : false
0 commit comments