Skip to content

Commit 532132c

Browse files
committed
publishing to pypi
1 parent 4b258f7 commit 532132c

File tree

3 files changed

+101
-0
lines changed

3 files changed

+101
-0
lines changed

.github/workflows/release.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # Trigger on version tags
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write # Needed for creating releases
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: '3.10'
21+
22+
- name: Install dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install build twine wheel
26+
pip install -e ".[dev]"
27+
28+
- name: Run tests
29+
run: pytest
30+
31+
- name: Build package
32+
run: python -m build
33+
34+
- name: Get version from tag
35+
id: get_version
36+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
37+
38+
- name: Create Release
39+
uses: softprops/action-gh-release@v1
40+
with:
41+
name: Release ${{ steps.get_version.outputs.VERSION }}
42+
draft: false
43+
prerelease: false
44+
files: |
45+
dist/*
46+
body: |
47+
Release of version ${{ steps.get_version.outputs.VERSION }}
48+
49+
Please refer to [CHANGELOG.md](./CHANGELOG.md) for details.
50+
51+
- name: Publish to PyPI
52+
if: github.repository == 'notry-cloud/pypi'
53+
env:
54+
TWINE_USERNAME: __token__
55+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
56+
run: twine upload dist/*

makefile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
.PHONY: help test clean build release
2+
3+
VERSION ?= $(error Please set VERSION variable to create a release: make release VERSION=0.1.0)
4+
5+
help:
6+
@echo "Available commands:"
7+
@echo " make test - Run tests"
8+
@echo " make clean - Remove build artifacts"
9+
@echo " make build - Build the package"
10+
@echo " make release - Create a new release (requires VERSION=X.Y.Z)"
11+
12+
test:
13+
pytest
14+
15+
clean:
16+
rm -rf build/
17+
rm -rf dist/
18+
rm -rf *.egg-info
19+
find . -type d -name __pycache__ -exec rm -rf {} +
20+
find . -type f -name "*.pyc" -delete
21+
22+
build: clean
23+
python -m build
24+
25+
release: test clean
26+
@echo "Creating release for version $(VERSION)"
27+
@# Update version in __init__.py
28+
@sed -i "s/__version__ = .*/__version__ = '$(VERSION)'/" tfsumpy/__init__.py
29+
@# Update version in setup.py if it exists
30+
@if grep -q "version=" setup.py; then \
31+
sed -i "s/version=.*/version='$(VERSION)',/" setup.py; \
32+
fi
33+
@# Commit changes
34+
git add tfsumpy/__init__.py setup.py
35+
git commit -m "Bump version to $(VERSION)"
36+
@# Create and push tag
37+
git tag -a v$(VERSION) -m "Release version $(VERSION)"
38+
git push origin main
39+
git push origin v$(VERSION)
40+
@echo "Release v$(VERSION) created and pushed. GitHub Actions will handle the rest."

setup.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
author_email='[email protected]',
1111
url='https://github.com/notry-cloud/tfsumpy',
1212
packages=find_packages(),
13+
project_urls={
14+
'Bug Tracker': 'https://github.com/notry-cloud/tfsumpy/issues',
15+
'Source Code': 'https://github.com/notry-cloud/tfsumpy',
16+
"GitHub": "https://github.com/notry-cloud/tfsumpy",
17+
},
1318
package_data={
1419
'tfsumpy': ['rules_config.json'],
1520
},

0 commit comments

Comments
 (0)