-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (78 loc) · 3.21 KB
/
release.yml
File metadata and controls
90 lines (78 loc) · 3.21 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
name: Release
# Creates a GitHub Release with changelog and artifacts
# when a version tag is pushed. Runs after PyPI upload.
on:
push:
tags:
- 'v*'
jobs:
github-release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract version
id: meta
run: |
VERSION="${GITHUB_REF_NAME#v}"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "tag=$GITHUB_REF_NAME" >> "$GITHUB_OUTPUT"
- name: Wait for PyPI availability
run: |
VERSION="${{ steps.meta.outputs.version }}"
echo "Waiting for gemstack $VERSION on PyPI..."
for i in $(seq 1 30); do
if curl -sf "https://pypi.org/pypi/gemstack/$VERSION/json" > pypi.json; then
if python3 -c "import sys,json; data=json.load(open('pypi.json')); sys.exit(0 if any(u['packagetype']=='sdist' for u in data.get('urls', [])) else 1)" 2>/dev/null; then
echo "✅ Package and sdist available on PyPI"
exit 0
fi
fi
echo " Attempt $i/30 — waiting 10s..."
sleep 10
done
echo "::error::Package not found on PyPI after 5 minutes"
exit 1
- name: Download release artifacts from PyPI
run: |
VERSION="${{ steps.meta.outputs.version }}"
mkdir -p dist/
# Use PyPI metadata already fetched by the Wait step
if [ ! -s pypi.json ]; then
echo "::error::PyPI metadata file missing or empty!"
exit 1
fi
WHEEL_URL=$(python3 -c "import sys,json; urls=json.load(open('pypi.json'))['urls']; print(next(u['url'] for u in urls if u['packagetype']=='bdist_wheel'))")
SDIST_URL=$(python3 -c "import sys,json; urls=json.load(open('pypi.json'))['urls']; print(next(u['url'] for u in urls if u['packagetype']=='sdist'))")
curl -fSL "$WHEEL_URL" -o "dist/gemstack-${VERSION}-py3-none-any.whl"
curl -fSL "$SDIST_URL" -o "dist/gemstack-${VERSION}.tar.gz"
ls -lh dist/
- name: Extract changelog for this version
run: |
VERSION="${{ steps.meta.outputs.version }}"
NOTES=$(awk "/^## \\[$VERSION\\]/{found=1; next} /^## \\[/{if(found) exit} found{print}" CHANGELOG.md)
if [ -z "$NOTES" ]; then
NOTES="Release v${VERSION}. See [CHANGELOG.md](https://github.com/arvarik/gemstack/blob/main/CHANGELOG.md) for details."
fi
echo "$NOTES" > /tmp/release-notes.md
cat >> /tmp/release-notes.md << 'EOF'
---
## Install
```bash
pipx install "gemstack[all]" # Recommended
uv tool install "gemstack[all]" # Fastest
pip install "gemstack[all]" # Standard
```
EOF
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.meta.outputs.tag }}
name: "Gemstack ${{ steps.meta.outputs.tag }}"
body_path: /tmp/release-notes.md
files: dist/*
draft: false
prerelease: ${{ contains(steps.meta.outputs.tag, '-') }}