Skip to content

Commit 1bf17d6

Browse files
committed
[IMP] github actions: build/publish
Build packages on each PR Publish on Pypi on release creation
1 parent 5eab392 commit 1bf17d6

File tree

2 files changed

+68
-5
lines changed

2 files changed

+68
-5
lines changed

.github/workflows/python-build.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Python package
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
pull_request:
7+
branches: [ "master" ]
8+
9+
jobs:
10+
build:
11+
name: Build wheels on ${{ matrix.os }}
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
os: [ubuntu-latest]
17+
python-version: [ "3.11" ]
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Set up Python ${{ matrix.python-version }}
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
- name: Install dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
python -m pip install flake8 pytest build
29+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
30+
- name: Lint with flake8
31+
run: |
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: Build wheels
37+
run: python -m build --wheel --outdir build
38+
- uses: actions/upload-artifact@v4
39+
with:
40+
name: ${{ matrix.os }}-${{ matrix.python-version }}
41+
path: build/*.whl
42+
43+
build-sdist:
44+
name: Build sdist on ${{ matrix.os }}
45+
runs-on: ${{ matrix.os }}
46+
strategy:
47+
fail-fast: false
48+
matrix:
49+
os: [ubuntu-latest]
50+
51+
steps:
52+
- uses: actions/checkout@v4
53+
- name: Set up Python
54+
uses: actions/setup-python@v5
55+
- name: Install dependencies
56+
run: |
57+
python -m pip install --upgrade pip
58+
python -m pip install build
59+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
60+
- name: Build sdist
61+
run: python -m build --sdist --outdir build
62+
- uses: actions/upload-artifact@v4
63+
with:
64+
name: sdist
65+
path: ./sbuild/*.tar.gz
66+

.github/workflows/python-package.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
name: Python package
22

33
on:
4-
push:
5-
branches: [ "master" ]
6-
pull_request:
7-
branches: [ "master" ]
4+
release:
5+
types: [created]
86

97
jobs:
108
build:
@@ -66,7 +64,6 @@ jobs:
6664

6765
publish-to-pypi:
6866
name: Publish Python 🐍 distribution 📦 to PyPI
69-
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
7067
needs: [ build, build-sdist ]
7168
runs-on: ubuntu-latest
7269
environment:

0 commit comments

Comments
 (0)