Repository navigation
105 lines (88 loc) · 2.96 KB
/
Copy pathrelease.yml
File metadata and controls
105 lines (88 loc) · 2.96 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
name: Release
on:
push:
tags:
- 'v*.*.*'
jobs:
build-and-publish:
name: Build and Publish to PyPI
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Extract version from tag
id: get_version
run: |
echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Update version in setup.py
run: |
sed -i "s/__version__ = .*/__version__ = '${{ steps.get_version.outputs.VERSION }}'/" snapflow/app.py
- name: Build package
run: |
python -m build
- name: Check distribution
run: |
twine check dist/*
- name: Publish to Test PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
run: |
twine upload --repository testpypi dist/* || echo "Test PyPI upload failed (may already exist)"
continue-on-error: true
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
twine upload dist/*
continue-on-error: true
- name: Generate Release Notes
id: release_notes
run: |
# Extract changes from CHANGELOG.md for this version
echo "RELEASE_NOTES<<EOF" >> $GITHUB_OUTPUT
echo "## What's Changed" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "Full Changelog: https://github.com/${{ github.repository }}/compare/${{ steps.get_version.outputs.TAG }}...HEAD" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: dist/*
body: ${{ steps.release_notes.outputs.RELEASE_NOTES }}
draft: false
prerelease: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload to GitHub Releases
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
notify-release:
name: Notify Release
runs-on: ubuntu-latest
needs: build-and-publish
steps:
- name: Extract version
id: get_version
run: |
echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Release notification
run: |
echo "🎉 Released version ${{ steps.get_version.outputs.VERSION }}"
echo "📦 Package: https://pypi.org/project/snapflow/${{ steps.get_version.outputs.VERSION }}/"
echo "🔖 Release: https://github.com/${{ github.repository }}/releases/tag/${GITHUB_REF#refs/tags/}"