Skip to content

Commit 0cfcbb6

Browse files
committed
Gate releases on exact-SHA CI
1 parent 4ac4747 commit 0cfcbb6

2 files changed

Lines changed: 55 additions & 2 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,59 @@ env:
1010
NODE_VERSION: '22'
1111

1212
jobs:
13+
verify-ci:
14+
name: Verify exact-SHA CI before release
15+
runs-on: ubuntu-latest
16+
if: github.ref == 'refs/heads/main'
17+
timeout-minutes: 31
18+
permissions:
19+
actions: read
20+
contents: read
21+
22+
steps:
23+
- name: Wait for successful CI on this commit
24+
shell: bash
25+
env:
26+
GH_TOKEN: ${{ github.token }}
27+
run: |
28+
set -euo pipefail
29+
deadline=$((SECONDS + 1800))
30+
ci_workflow_id=$(gh api "repos/${GITHUB_REPOSITORY}/actions/workflows" \
31+
--jq '[.workflows[] | select(.path == ".github/workflows/ci.yml")][0].id // empty')
32+
if [[ -z "$ci_workflow_id" ]]; then
33+
echo "Could not resolve this repository's CI workflow; release publication is blocked."
34+
exit 1
35+
fi
36+
37+
while (( SECONDS < deadline )); do
38+
run=$(gh api "repos/${GITHUB_REPOSITORY}/actions/runs" \
39+
-f head_sha="$GITHUB_SHA" \
40+
-F per_page=100 \
41+
--jq "[.workflow_runs[] | select(.workflow_id == $ci_workflow_id and .head_sha == \"$GITHUB_SHA\" and .head_branch == \"main\" and .event == \"push\")] | sort_by(.created_at) | last // empty")
42+
43+
if [[ -z "$run" ]]; then
44+
echo "Waiting for the CI run for this exact commit to appear."
45+
else
46+
status=$(jq -r '.status' <<<"$run")
47+
conclusion=$(jq -r '.conclusion // ""' <<<"$run")
48+
echo "Exact-SHA CI status: $status; conclusion: ${conclusion:-pending}."
49+
50+
if [[ "$status" == "completed" ]]; then
51+
if [[ "$conclusion" == "success" ]]; then
52+
exit 0
53+
fi
54+
55+
echo "Exact-SHA CI did not succeed; release publication is blocked."
56+
exit 1
57+
fi
58+
fi
59+
60+
sleep 15
61+
done
62+
63+
echo "Timed out waiting for successful exact-SHA CI; release publication is blocked."
64+
exit 1
65+
1366
build:
1467
name: Build and Test
1568
runs-on: ubuntu-latest
@@ -91,7 +144,7 @@ jobs:
91144

92145
publish-nuget:
93146
name: Publish to NuGet
94-
needs: build
147+
needs: [build, verify-ci]
95148
runs-on: ubuntu-latest
96149
if: github.ref == 'refs/heads/main'
97150

‎Directory.Build.props‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<PublishRepositoryUrl>true</PublishRepositoryUrl>
3333
<EmbedUntrackedSources>true</EmbedUntrackedSources>
3434
<EnablePackageValidation>true</EnablePackageValidation>
35-
<Version>1.1.8</Version>
35+
<Version>1.1.9</Version>
3636
<PackageVersion>$(Version)</PackageVersion>
3737
</PropertyGroup>
3838

0 commit comments

Comments
 (0)