-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (54 loc) · 1.77 KB
/
publish.yml
File metadata and controls
68 lines (54 loc) · 1.77 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
name: Publish to PyPI
on:
release:
types: [published]
permissions:
contents: write
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
pip install -e .
- name: Run tests
run: python -m unittest discover -s tests -v
- name: Verify version matches tag
run: |
TAG="${{ github.event.release.tag_name }}"
# Remove 'v' prefix if present
TAG_VERSION="${TAG#v}"
# Get version from setup.py
SETUP_VERSION=$(python -c "import re; content=open('setup.py').read(); print(re.search(r\"version='([^']+)'\", content).group(1))")
if [ "$TAG_VERSION" != "$SETUP_VERSION" ]; then
echo "❌ Version mismatch!"
echo " Tag version: $TAG_VERSION"
echo " setup.py version: $SETUP_VERSION"
echo ""
echo "Please update the version in setup.py and ujeebu_python/__init__.py before releasing."
exit 1
fi
echo "✅ Version matches: $TAG_VERSION"
- name: Build package
run: python -m build
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: twine upload dist/*
- name: Upload release assets
uses: softprops/action-gh-release@v1
with:
files: dist/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}