Skip to content

Commit b16e8f9

Browse files
ci: add automated release workflow
1 parent c76c0b3 commit b16e8f9

1 file changed

Lines changed: 107 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: Create Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*' # Triggers on version tags like v0.1.0, v1.2.3, etc.
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
create-release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Extract version from tag
21+
id: version
22+
run: |
23+
TAG=${GITHUB_REF#refs/tags/}
24+
VERSION=${TAG#v}
25+
echo "tag=$TAG" >> $GITHUB_OUTPUT
26+
echo "version=$VERSION" >> $GITHUB_OUTPUT
27+
echo "📦 Creating release for $TAG"
28+
29+
- name: Extract release notes from CHANGELOG
30+
id: changelog
31+
run: |
32+
VERSION="${{ steps.version.outputs.version }}"
33+
34+
# Extract the section for this version from CHANGELOG.md
35+
awk -v ver="$VERSION" '
36+
/^## \['"$VERSION"'\]/ { found=1; next }
37+
found && /^## \[/ { exit }
38+
found { print }
39+
' CHANGELOG.md > release_notes.md
40+
41+
if [ ! -s release_notes.md ]; then
42+
echo "⚠️ No changelog entry found for version $VERSION"
43+
echo "No changelog entry found for this version." > release_notes.md
44+
fi
45+
46+
# Format release notes
47+
{
48+
echo "# LongProbe ${{ steps.version.outputs.tag }}"
49+
echo ""
50+
cat release_notes.md
51+
echo ""
52+
echo "---"
53+
echo ""
54+
echo "## 📦 Installation"
55+
echo ""
56+
echo "\`\`\`bash"
57+
echo "pip install longprobe==$VERSION"
58+
echo "\`\`\`"
59+
echo ""
60+
echo "## 📚 Documentation"
61+
echo ""
62+
echo "- [README](https://github.com/ENDEVSOLS/LongProbe#readme)"
63+
echo "- [CHANGELOG](https://github.com/ENDEVSOLS/LongProbe/blob/main/CHANGELOG.md)"
64+
echo "- [CONTRIBUTING](https://github.com/ENDEVSOLS/LongProbe/blob/main/CONTRIBUTING.md)"
65+
echo ""
66+
echo "## 🔗 Links"
67+
echo ""
68+
echo "- **PyPI**: https://pypi.org/project/longprobe/$VERSION/"
69+
echo "- **Homepage**: https://endevsols.com/open-source/longprobe"
70+
echo "- **Issues**: https://github.com/ENDEVSOLS/LongProbe/issues"
71+
echo ""
72+
echo "---"
73+
echo ""
74+
echo "**Part of the [EnDevSols Long Suite](https://endevsols.com/open-source)** 🔬"
75+
} > final_release_notes.md
76+
77+
echo "✅ Release notes prepared"
78+
79+
- name: Set up Python
80+
uses: actions/setup-python@v5
81+
with:
82+
python-version: '3.12'
83+
84+
- name: Install uv
85+
uses: astral-sh/setup-uv@v4
86+
with:
87+
version: "latest"
88+
89+
- name: Build package
90+
run: |
91+
echo "🔨 Building package..."
92+
uv build
93+
ls -lh dist/
94+
95+
- name: Create GitHub Release
96+
uses: softprops/action-gh-release@v2
97+
with:
98+
name: LongProbe ${{ steps.version.outputs.tag }}
99+
body_path: final_release_notes.md
100+
files: |
101+
dist/*.whl
102+
dist/*.tar.gz
103+
draft: false
104+
prerelease: ${{ contains(steps.version.outputs.tag, 'alpha') || contains(steps.version.outputs.tag, 'beta') || contains(steps.version.outputs.tag, 'rc') }}
105+
generate_release_notes: false
106+
env:
107+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)