@@ -2,48 +2,63 @@ name: Release SpacetimeDSL
22
33on :
44 push :
5- tags : [ 'v*' ] # Trigger release only on version tags
5+ tags : ["v*"] # Trigger release only on version tags
6+
7+ concurrency :
8+ group : ${{ github.workflow }}-${{ github.ref }}
9+ cancel-in-progress : true
610
711jobs :
812 # Verify tests passed before release
913 verify-tests :
10- name : Verify tests passed
14+ name : Verify tests passed
1115 runs-on : ubuntu-latest
1216 steps :
13- - name : Check latest workflow run
14- uses : actions/github-script@v7
15- with :
16- script : |
17- // Get the commit SHA for the tag
18- const tagRef = context.ref;
19- const tagSha = context.sha;
20-
21- console.log(`Checking tests for tag ${tagRef} (${tagSha})`);
22-
23- // Get recent workflow runs for the test workflow
24- const { data: workflows } = await github.rest.actions.listWorkflowRuns({
25- owner: context.repo.owner,
26- repo: context.repo.repo,
27- workflow_id: 'test.yml',
28- head_sha: tagSha,
29- per_page: 1
30- });
31-
32- if (workflows.total_count === 0) {
33- console.log('⚠️ No test workflow found for this commit');
34- console.log('This might be expected if this is the first run after adding the tag trigger');
35- return;
36- }
37-
38- const latestRun = workflows.workflow_runs[0];
39- console.log(`Latest test run: ${latestRun.status} (${latestRun.conclusion})`);
40-
41- if (latestRun.conclusion !== 'success') {
42- console.log('❌ Tests did not pass - release cannot proceed');
17+ - name : Wait for test workflow to complete
18+ uses : actions/github-script@v7
19+ with :
20+ script : |
21+ const tagRef = context.ref;
22+ const tagSha = context.sha;
23+ const pollIntervalMs = 30_000; // 30 seconds
24+ const timeoutMs = 30 * 60_000; // 30 minutes
25+
26+ console.log(`Waiting for test workflow to pass for tag ${tagRef} (${tagSha})`);
27+
28+ const startTime = Date.now();
29+
30+ while (Date.now() - startTime < timeoutMs) {
31+ const { data: workflows } = await github.rest.actions.listWorkflowRuns({
32+ owner: context.repo.owner,
33+ repo: context.repo.repo,
34+ workflow_id: 'test.yml',
35+ head_sha: tagSha,
36+ per_page: 1
37+ });
38+
39+ if (workflows.total_count === 0) {
40+ console.log('⏳ No test workflow run found yet, waiting...');
41+ } else {
42+ const run = workflows.workflow_runs[0];
43+ console.log(`Test run status: ${run.status}, conclusion: ${run.conclusion}`);
44+
45+ if (run.status === 'completed') {
46+ if (run.conclusion === 'success') {
47+ console.log('✅ Tests passed - release can proceed');
48+ return;
49+ }
50+ console.log('❌ Tests did not pass - release cannot proceed');
51+ process.exit(1);
52+ }
53+
54+ console.log('⏳ Test workflow still running, waiting...');
55+ }
56+
57+ await new Promise(r => setTimeout(r, pollIntervalMs));
58+ }
59+
60+ console.log('❌ Timed out waiting for test workflow to complete');
4361 process.exit(1);
44- }
45-
46- console.log('✅ Tests passed - release can proceed');
4762
4863 # Release job - publishes to crates.io when version tags are pushed
4964 release :
@@ -53,85 +68,85 @@ jobs:
5368 # Use GitHub environment for enhanced security and manual approval if desired
5469 environment : release
5570 permissions :
56- id-token : write # Required for OIDC token exchange with crates.io
57- contents : read # Required to read repository contents
71+ id-token : write # Required for OIDC token exchange with crates.io
72+ contents : read # Required to read repository contents
5873
5974 steps :
60- - name : Checkout code
61- uses : actions/checkout@v4
62-
63- - name : Extract version from tag
64- id : version
65- run : |
66- # Extract version from tag (e.g., refs/tags/v0.10.0 -> 0.10.0)
67- VERSION=${GITHUB_REF#refs/tags/v}
68- echo "version=$VERSION" >> $GITHUB_OUTPUT
69- echo "Extracted version: $VERSION"
70- echo "🏷️ Release triggered by tag: ${{ github.ref }}"
71-
72- - name : Install Rust toolchain
73- uses : actions-rust-lang/setup-rust-toolchain@v1
74- with :
75- toolchain : stable
76-
77- # Authenticate with crates.io using OIDC/Trusted Publishing
78- - name : Authenticate with crates.io
79- id : auth
80- uses : rust-lang/crates-io-auth-action@v1
81-
82- - name : Validate crate publishing readiness
83- run : |
84- cargo check
85- cargo build
86-
87- # Publish derive-input crate first (no dependencies)
88- - name : Publish spacetimedsl_derive-input to crates.io
89- run : |
90- echo "Publishing spacetimedsl_derive-input..."
91- cd derive-input
92- cargo publish
93- echo "✅ spacetimedsl_derive-input published successfully"
94- cd ..
95- env :
96- CARGO_REGISTRY_TOKEN : ${{ steps.auth.outputs.token }}
97-
98- # Verify derive-input crate is available before proceeding
99- - name : Verify spacetimedsl_derive-input availability
100- uses : ./.github/actions/verify-crate-availability
101- with :
102- crate-name : spacetimedsl_derive-input
103- version : ${{ steps.version.outputs.version }}
104-
105- # Publish derive crate second (depends on derive-input)
106- - name : Publish spacetimedsl_derive to crates.io
107- run : |
108- echo "Publishing spacetimedsl_derive..."
109- cd derive
110- cargo publish
111- echo "✅ spacetimedsl_derive published successfully"
112- cd ..
113- env :
114- CARGO_REGISTRY_TOKEN : ${{ steps.auth.outputs.token }}
115-
116- # Verify derive crate is available before proceeding
117- - name : Verify spacetimedsl_derive availability
118- uses : ./.github/actions/verify-crate-availability
119- with :
120- crate-name : spacetimedsl_derive
121- version : ${{ steps.version.outputs.version }}
122-
123- # Publish main crate last (depends on derive)
124- - name : Publish spacetimedsl to crates.io
125- run : |
126- echo "Publishing spacetimedsl (main crate)..."
127- cargo publish
128- echo "✅ All crates published successfully! 🎉"
129- env :
130- CARGO_REGISTRY_TOKEN : ${{ steps.auth.outputs.token }}
131-
132- # Final verification that main crate is available
133- - name : Verify spacetimedsl availability
134- uses : ./.github/actions/verify-crate-availability
135- with :
136- crate-name : spacetimedsl
137- version : ${{ steps.version.outputs.version }}
75+ - name : Checkout code
76+ uses : actions/checkout@v4
77+
78+ - name : Extract version from tag
79+ id : version
80+ run : |
81+ # Extract version from tag (e.g., refs/tags/v0.10.0 -> 0.10.0)
82+ VERSION=${GITHUB_REF#refs/tags/v}
83+ echo "version=$VERSION" >> $GITHUB_OUTPUT
84+ echo "Extracted version: $VERSION"
85+ echo "🏷️ Release triggered by tag: ${{ github.ref }}"
86+
87+ - name : Install Rust toolchain
88+ uses : actions-rust-lang/setup-rust-toolchain@v1
89+ with :
90+ toolchain : stable
91+
92+ # Authenticate with crates.io using OIDC/Trusted Publishing
93+ - name : Authenticate with crates.io
94+ id : auth
95+ uses : rust-lang/crates-io-auth-action@v1
96+
97+ - name : Validate crate publishing readiness
98+ run : |
99+ cargo check
100+ cargo build
101+
102+ # Publish derive-input crate first (no dependencies)
103+ - name : Publish spacetimedsl_derive-input to crates.io
104+ run : |
105+ echo "Publishing spacetimedsl_derive-input..."
106+ cd derive-input
107+ cargo publish
108+ echo "✅ spacetimedsl_derive-input published successfully"
109+ cd ..
110+ env :
111+ CARGO_REGISTRY_TOKEN : ${{ steps.auth.outputs.token }}
112+
113+ # Verify derive-input crate is available before proceeding
114+ - name : Verify spacetimedsl_derive-input availability
115+ uses : ./.github/actions/verify-crate-availability
116+ with :
117+ crate-name : spacetimedsl_derive-input
118+ version : ${{ steps.version.outputs.version }}
119+
120+ # Publish derive crate second (depends on derive-input)
121+ - name : Publish spacetimedsl_derive to crates.io
122+ run : |
123+ echo "Publishing spacetimedsl_derive..."
124+ cd derive
125+ cargo publish
126+ echo "✅ spacetimedsl_derive published successfully"
127+ cd ..
128+ env :
129+ CARGO_REGISTRY_TOKEN : ${{ steps.auth.outputs.token }}
130+
131+ # Verify derive crate is available before proceeding
132+ - name : Verify spacetimedsl_derive availability
133+ uses : ./.github/actions/verify-crate-availability
134+ with :
135+ crate-name : spacetimedsl_derive
136+ version : ${{ steps.version.outputs.version }}
137+
138+ # Publish main crate last (depends on derive)
139+ - name : Publish spacetimedsl to crates.io
140+ run : |
141+ echo "Publishing spacetimedsl (main crate)..."
142+ cargo publish
143+ echo "✅ All crates published successfully! 🎉"
144+ env :
145+ CARGO_REGISTRY_TOKEN : ${{ steps.auth.outputs.token }}
146+
147+ # Final verification that main crate is available
148+ - name : Verify spacetimedsl availability
149+ uses : ./.github/actions/verify-crate-availability
150+ with :
151+ crate-name : spacetimedsl
152+ version : ${{ steps.version.outputs.version }}
0 commit comments