Skip to content

Commit efaf05b

Browse files
authored
Feature logging (#2)
* logging, error handling, comments * bump version * missing build dependency * trigger build in PR and publish in master * version handling * missing dependency
1 parent 0572119 commit efaf05b

File tree

3 files changed

+42
-7
lines changed

3 files changed

+42
-7
lines changed

.github/workflows/publish-to-pypi.yml

+39-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
name: Publish Python Package
1+
name: Build and Test Python Package
22

33
on:
4+
pull_request:
5+
branches:
6+
- '**' # Triggers on all branches with open PRs
7+
48
push:
59
branches:
6-
- master
10+
- master # Triggers on pushes to the main branch
711

812
jobs:
9-
build-and-publish:
13+
build-and-test:
1014
runs-on: ubuntu-latest
1115

1216
steps:
@@ -19,18 +23,48 @@ jobs:
1923
python-version: '3.x'
2024

2125
- name: Install dependencies
22-
run: pip install -r requirements.txt
26+
run: |
27+
pip install setuptools wheel
28+
pip install -r requirements.txt
2329
2430
- name: Get current version
2531
id: get_version
2632
run: |
27-
VERSION=$(python -c "exec(open('setup.py').read()); print(__version__)")
33+
VERSION=$(python -c "from version import __version__; print(__version__)")
2834
echo "VERSION=$VERSION" >> $GITHUB_ENV
2935
3036
- name: Build the package
3137
run: |
3238
python setup.py sdist bdist_wheel
3339
40+
# - name: Run tests
41+
# run: |
42+
# pip install pytest
43+
# pytest
44+
45+
publish-and-tag:
46+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
47+
runs-on: ubuntu-latest
48+
needs: build-and-test
49+
50+
steps:
51+
- name: Checkout code
52+
uses: actions/checkout@v2
53+
54+
- name: Set up Python
55+
uses: actions/setup-python@v2
56+
with:
57+
python-version: '3.x'
58+
59+
- name: Install dependencies
60+
run: |
61+
pip install setuptools wheel
62+
pip install -r requirements.txt
63+
64+
- name: Build the package
65+
run: |
66+
python setup.py sdist bdist_wheel
67+
3468
- name: Publish to PyPI
3569
env:
3670
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
@@ -40,10 +74,8 @@ jobs:
4074
twine upload dist/*
4175
4276
- name: Create Git tag
43-
if: success()
4477
run: |
4578
git config user.name "GitHub Actions"
4679
git config user.email "[email protected]"
4780
git tag -a v${{ env.VERSION }} -m "Release version ${{ env.VERSION }}"
4881
git push origin v${{ env.VERSION }}
49-

setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from setuptools import setup, find_packages
2+
from version import __version__
23

34
__version__ = "0.2.0"
45

version.py

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# version.py
2+
__version__ = "0.2.0"

0 commit comments

Comments
 (0)