-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (87 loc) · 3.04 KB
/
Copy pathrelease.yml
File metadata and controls
98 lines (87 loc) · 3.04 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
name: Release
# Release is triggered by pushing a vX.Y.Z tag.
# Prerequisite: merge develop → main via PR before tagging (tag must be on main).
# Publishes vecq-core to crates.io, then verifies via the crates.io API.
on:
push:
tags:
- 'v*'
env:
CARGO_TERM_COLOR: always
jobs:
verify-main:
name: Verify tag is on main
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Check tag is on main
run: |
git fetch origin main
TAG_SHA=$(git rev-parse "${{ github.ref }}^{commit}")
MAIN_SHA=$(git rev-parse origin/main)
echo "Tag: $TAG_SHA"
echo "main: $MAIN_SHA"
if [ "$TAG_SHA" = "$MAIN_SHA" ]; then
echo "✅ Tag is main HEAD"
elif git merge-base --is-ancestor "$TAG_SHA" origin/main 2>/dev/null; then
echo "✅ Tag commit $TAG_SHA is in main history"
else
echo "::error::Tag commit $TAG_SHA is NOT on main."
echo "Merge develop → main via PR before tagging."
exit 1
fi
publish-crates:
name: Publish to crates.io
needs: [verify-main]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- name: Publish vecq-core
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }} -p vecq-core
continue-on-error: true
- name: Verify crates.io version
run: |
VERSION="${GITHUB_REF_NAME#v}"
fail=0
for attempt in 1 2 3 4 5; do
MAX=$(curl -sf -A "vecq-release-verify" "https://crates.io/api/v1/crates/vecq-core" | jq -r '.crate.max_version') || MAX=""
[ "$MAX" = "$VERSION" ] && break
echo "attempt $attempt: vecq-core at $MAX (want $VERSION), waiting..."
sleep 30
done
if [ "$MAX" = "$VERSION" ]; then
echo "✓ vecq-core $VERSION live on crates.io"
else
echo "::error::vecq-core not at $VERSION on crates.io (found: $MAX) — publish step failed silently"
fail=1
fi
exit $fail
release:
name: Create GitHub Release
needs: [publish-crates]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v7
- name: Extract changelog for this version
id: changelog
run: |
VER="${GITHUB_REF_NAME#v}"
awk "/^## \[${VER}\]/{found=1; next} /^## \[/{found=0} found" CHANGELOG.md > changelog-body.md
if [ ! -s changelog-body.md ]; then
echo "No changelog entry found for ${VER}." > changelog-body.md
fi
- name: Create GitHub Release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
body_path: changelog-body.md
draft: false
prerelease: ${{ contains(github.ref_name, '-') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}