Skip to content

Commit 2f289e9

Browse files
committed
update actions
1 parent 4fddda3 commit 2f289e9

3 files changed

Lines changed: 77 additions & 50 deletions

File tree

Lines changed: 69 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,87 @@
1-
# This workflow will upload a Python Package using Twine when a release is created
2-
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3-
4-
# This workflow uses actions that are not certified by GitHub.
5-
# They are provided by a third-party and are governed by
6-
# separate terms of service, privacy policy, and support
7-
# documentation.
8-
9-
name: Upload Python Package
1+
name: Publish to PyPI
102

113
on:
124
push:
135
tags:
14-
- "[0-9]+.[0-9]+.[0-9]+"
6+
- '[0-9]+\.[0-9]+\.[0-9+]+'
157

168
permissions:
17-
contents: write
9+
contents: read
1810

1911
jobs:
20-
deploy:
21-
12+
test:
2213
runs-on: ubuntu-latest
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
2318

2419
steps:
2520
- uses: actions/checkout@v4
26-
- name: Set up Python
21+
- name: Set up Python ${{ matrix.python-version }}
2722
uses: actions/setup-python@v5
2823
with:
29-
python-version: '3.x'
24+
python-version: ${{ matrix.python-version }}
3025
- name: Install dependencies
3126
run: |
3227
python -m pip install --upgrade pip
33-
pip install setuptools
34-
pip install -r requirements.txt
35-
- name: Test code
36-
run: pytest
37-
- name: Bumpversion
38-
run: bumpversion --new-version=${{ github.ref_name }} minor
39-
- name: Fail if bumpversion changed files
28+
python -m pip install flake8 pytest
29+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
30+
- name: Lint with flake8
4031
run: |
41-
if [ -n "$(git status --porcelain)" ]; then
42-
echo "bumpversion modified files; failing the job."
43-
git status --porcelain
44-
exit 1
45-
else
46-
echo "No changes after bumpversion."
47-
fi
48-
- name: Clean dist/
49-
run: rm dist/* -f
50-
- name: Build package
51-
run: python setup.py sdist bdist_wheel
52-
- name: Check package
53-
run: python -m twine check dist/*
54-
- name: Publish package
55-
uses: pypa/gh-action-pypi-publish@0ab0b79471669eb3a4d647e625009c62f9f3b241
56-
with:
57-
user: __token__
58-
password: ${{ secrets.PYPI_API_TOKEN }}
59-
- name: Create GitHub Release
60-
uses: actions/create-release@v1
61-
env:
62-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63-
with:
64-
tag_name: ${{ github.ref_name }}
65-
release_name: ${{ github.ref_name }}
66-
draft: false
67-
prerelease: false
32+
# stop the build if there are Python syntax errors or undefined names
33+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
34+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
35+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
36+
- name: Test with pytest
37+
run: |
38+
pytest
39+
40+
deploy:
41+
runs-on: ubuntu-latest
42+
needs: test
43+
steps:
44+
- uses: actions/checkout@v4
45+
46+
- name: Set up Python
47+
uses: actions/setup-python@v5
48+
with:
49+
python-version: '3.x'
50+
51+
- name: Install build tools
52+
run: |
53+
python -m pip install --upgrade pip
54+
python -m pip install build
55+
56+
- name: Verify tag matches package version
57+
run: |
58+
python - << 'PY'
59+
import re, pathlib
60+
init = pathlib.Path('gcodeparser/__init__.py').read_text(encoding='utf-8')
61+
m = re.search(r"__version__\s*=\s*['\"]([^'\"]+)['\"]", init)
62+
if not m:
63+
raise SystemExit('Version not found in gcodeparser/__init__.py')
64+
pkg_version = m.group(1)
65+
tag = '${{ github.ref_name }}'
66+
if pkg_version != tag:
67+
raise SystemExit(f'Tag ({tag}) does not match package version ({pkg_version})')
68+
print(f'Version check passed: {pkg_version}')
69+
PY
70+
71+
- name: Build distributions
72+
run: python -m build
73+
74+
- name: Publish to PyPI
75+
uses: pypa/gh-action-pypi-publish@release/v1
76+
with:
77+
user: __token__
78+
password: ${{ secrets.PYPI_API_TOKEN }}
79+
- name: Create GitHub Release
80+
uses: actions/create-release@v1
81+
env:
82+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
83+
with:
84+
tag_name: ${{ github.ref_name }}
85+
release_name: ${{ github.ref_name }}
86+
draft: false
87+
prerelease: false

.github/workflows/python-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
python-version: ["3.9", "3.10", "3.11", "3.12"]
19+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
2020

2121
steps:
2222
- uses: actions/checkout@v4

setup.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
version="0.3.0",
1414
include_package_data=True,
1515
packages=find_packages(),
16+
python_requires=">=3.10",
1617
install_requires=[],
1718
author="Andy Everitt",
1819
author_email="andreweveritt@e3d-online.com",
@@ -23,6 +24,12 @@
2324
classifiers=[
2425
"License :: OSI Approved :: MIT License",
2526
"Programming Language :: Python :: 3",
27+
"Programming Language :: Python :: 3 :: Only",
28+
"Programming Language :: Python :: 3.10",
29+
"Programming Language :: Python :: 3.11",
30+
"Programming Language :: Python :: 3.12",
31+
"Programming Language :: Python :: 3.13",
32+
"Programming Language :: Python :: 3.14",
2633
"Operating System :: OS Independent",
2734
],
2835
)

0 commit comments

Comments
 (0)