-
Notifications
You must be signed in to change notification settings - Fork 0
106 lines (87 loc) · 3.01 KB
/
Copy pathrelease.yaml
File metadata and controls
106 lines (87 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
---
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Tag to release (e.g. v0.6.7)"
required: true
permissions:
actions: read
contents: write
jobs:
release:
runs-on: ubuntu-latest
permissions:
actions: read
contents: write
id-token: write
steps:
- name: Resolve tag
id: tag
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "name=${{ github.event.inputs.tag }}" >> "$GITHUB_OUTPUT"
else
echo "name=${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
fi
- uses: actions/checkout@v5
with:
ref: ${{ steps.tag.outputs.name }}
- name: Wait for CI to pass for this tag
uses: actions/github-script@v9
with:
script: |
const owner = context.repo.owner;
const repo = context.repo.repo;
const workflowName = "CI";
const tag = "${{ steps.tag.outputs.name }}";
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
const maxAttempts = 40;
const delayMs = 15000;
for (let i = 1; i <= maxAttempts; i++) {
const runs = await github.paginate(github.rest.actions.listWorkflowRunsForRepo, {
owner,
repo,
event: "push",
per_page: 100,
});
const ciRun = runs.find((r) => r.name === workflowName && r.head_branch === tag);
if (!ciRun) {
core.info(`Attempt ${i}/${maxAttempts}: CI run not found yet for tag ${tag}.`);
await sleep(delayMs);
continue;
}
core.info(
`Attempt ${i}/${maxAttempts}: CI run ${ciRun.id} status=${ciRun.status} conclusion=${ciRun.conclusion}`
);
if (ciRun.status !== "completed") {
await sleep(delayMs);
continue;
}
if (ciRun.conclusion !== "success") {
core.setFailed(`CI workflow concluded with '${ciRun.conclusion}'. Aborting release.`);
return;
}
core.info("CI passed for this tag. Proceeding with release.");
return;
}
core.setFailed("Timed out waiting for CI workflow completion.");
- name: Install Rust
run: rustup toolchain install stable
- name: Authenticate to crates.io with trusted publishing
id: auth
uses: rust-lang/[email protected]
- name: Publish to crates.io
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
- name: Create GitHub release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ steps.tag.outputs.name }}
generate_release_notes: true
prerelease: ${{ contains(steps.tag.outputs.name, '-') }}