Skip to content

Commit d5e1383

Browse files
committed
Adding GitHub actions for package and publish
1 parent cf9159c commit d5e1383

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

.github/workflows/python-package.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3+
4+
name: Python package
5+
6+
on:
7+
push:
8+
branches: [ "main" ]
9+
pull_request:
10+
branches: [ "main" ]
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
python-version: ["3.10", "3.11", "3.12"]
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
- name: Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
- name: Install PDM
28+
run: |
29+
python -m pip install --upgrade pip
30+
python -m pip install pdm
31+
- name: Install dependencies
32+
run: |
33+
pdm install
34+
- name: Lint with flake8
35+
run: |
36+
pdm run flake8 src tests --count --select=E9,F63,F7,F82 --show-source --statistics
37+
pdm run flake8 src tests --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
38+
- name: Test with pytest
39+
run: |
40+
pdm run pytest

.github/workflows/python-publish.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
name: Upload Python Package
5+
6+
on:
7+
release:
8+
types: [published]
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
deploy:
15+
16+
runs-on: ubuntu-latest
17+
environment: release
18+
permissions:
19+
# IMPORTANT: this permission is mandatory for trusted publishing
20+
id-token: write
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
- name: Set up Python
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: '3.x'
28+
- name: Install PDM and mypy
29+
run: |
30+
python -m pip install --upgrade pip
31+
python -m pip install pdm
32+
python -m pip install mypy # Install mypy for stubgen
33+
- name: Generate type stubs
34+
run: stubgen src -o src # Generate stubs directly into the src directory
35+
- name: Build package
36+
run: pdm build
37+
- name: Publish package
38+
uses: pypa/gh-action-pypi-publish@v1.8.14

0 commit comments

Comments
 (0)