-
Notifications
You must be signed in to change notification settings - Fork 0
120 lines (101 loc) · 3.7 KB
/
Copy pathrelease.yml
File metadata and controls
120 lines (101 loc) · 3.7 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: Release and Publish
on:
push:
branches:
- "releases/**"
env:
PYTHON_VERSION: "3.9"
jobs:
release:
runs-on: ubuntu-latest
environment:
name: pypi
permissions:
contents: write
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract version from branch name
run: |
BRANCH_NAME="${GITHUB_REF#refs/heads/}"
VERSION="${BRANCH_NAME#releases/}"
echo "PACKAGE_VERSION=$VERSION" >> $GITHUB_ENV
echo "Branch version: $VERSION"
- name: Extract version from pyproject.toml
run: |
TOML_VERSION=$(grep -E '^version = ' pyproject.toml | sed -E 's/version = "(.*)"/\1/')
echo "TOML_VERSION=$TOML_VERSION" >> $GITHUB_ENV
echo "TOML version: $TOML_VERSION"
- name: Extract version from __init__.py
run: |
INIT_VERSION=$(grep -E '^__version__ = ' src/notchpay/__init__.py | sed -E 's/__version__ = "(.*)"/\1/')
echo "INIT_VERSION=$INIT_VERSION" >> $GITHUB_ENV
echo "__init__.py version: $INIT_VERSION"
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Set up Python
run: uv python install
- name: Verify versions match
run: |
if [ "${{ env.TOML_VERSION }}" != "${{ env.PACKAGE_VERSION }}" ]; then
echo "❌ Version mismatch: branch=${{ env.PACKAGE_VERSION }}, pyproject.toml=${{ env.TOML_VERSION }}"
exit 1
fi
if [ "${{ env.INIT_VERSION }}" != "${{ env.PACKAGE_VERSION }}" ]; then
echo "❌ Version mismatch: branch=${{ env.PACKAGE_VERSION }}, __init__.py=${{ env.INIT_VERSION }}"
exit 1
fi
echo "✅ All versions match: ${{ env.PACKAGE_VERSION }}"
- name: Install the project
run: uv sync --locked --all-extras --dev
- name: Build package
run: uv build
- name: Upload wheel artifact
uses: actions/upload-artifact@v4
with:
name: wheel-package
path: dist/*.whl
- name: Upload source distribution artifact
uses: actions/upload-artifact@v4
with:
name: source-distribution
path: dist/*.tar.gz
- name: Create GitHub Release
if: startsWith(github.ref, 'refs/heads/releases/')
uses: softprops/action-gh-release@v2
with:
files: |
dist/*.whl
dist/*.tar.gz
token: ${{ secrets.GITHUB_TOKEN }}
name: "Release v${{ env.PACKAGE_VERSION }}"
body: |
## 🚀 Release v${{ env.PACKAGE_VERSION }}
### 📝 Latest Changes
${{ github.event.head_commit.message }}
### 📦 Installation
```bash
pip install notchpay==${{ env.PACKAGE_VERSION }}
```
### 🔗 Links
- [Documentation](https://developer.notchpay.co/sdks/python)
- [PyPI Package](https://pypi.org/project/notchpay/${{ env.PACKAGE_VERSION }}/)
- [Changelog](https://github.com/${{ github.repository }}/blob/master/CHANGELOG.md)
tag_name: "v${{ env.PACKAGE_VERSION }}"
draft: false
prerelease: false
- name: Publish to PyPI
if: startsWith(github.ref, 'refs/heads/releases/')
env:
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
run: uv publish --token $UV_PUBLISH_TOKEN
- name: Delete release branch
if: startsWith(github.ref, 'refs/heads/releases/')
run: |
BRANCH_NAME=${GITHUB_REF#refs/heads/}
git push origin --delete $BRANCH_NAME