1+ # https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
12name : Python package
23
34on :
45 push :
6+ tags :
7+ - ' [0-9]+.[0-9]+.[0-9]+' # release
8+ - ' [0-9]+.[0-9]+.[0-9]+a[0-9]+' # alpha
9+ - ' [0-9]+.[0-9]+.[0-9]+b[0-9]+' # beta
10+ - ' [0-9]+.[0-9]+.[0-9]+rc[0-9]+' # release candidate
11+ - ' [0-9]+.[0-9]+.[0-9]+.dev[0-9]+' # dev (not semver compliant)
12+ - ' [0-9]+.[0-9]+.[0-9]+.post[0-9]+' # post (not semver compliant)
513 pull_request :
614
715jobs :
816 cqa :
917 runs-on : ubuntu-latest
1018
1119 steps :
12- - uses : actions/checkout@v3
20+ - uses : actions/checkout@v4
21+
22+ - uses : awalsh128/cache-apt-pkgs-action@latest
23+ with :
24+ packages : zsh
25+ version : 1.0
1326
1427 - name : Set up Python
15- uses : actions/setup-python@v4
28+ uses : actions/setup-python@v5
1629 with :
17- python-version : " 3.10 "
30+ python-version : " 3.12 "
1831 cache : pip
19- cache-dependency-path : ' **/setup.cfg '
32+ cache-dependency-path : ' **/pyproject.yaml '
2033
2134 - name : Install test dependencies
2235 run : |
2336 python -m pip install --upgrade pip
24- pip install --use-deprecated=legacy-resolver -e .[dev]
37+ pip install --use-deprecated=legacy-resolver -e .[dev,test ]
2538
26- - name : Lint with flake8
39+ - name : Lint with Ruff
2740 run : |
28- # stop the build if there are Python syntax errors or undefined names
29- flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
30- # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
31- flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
32-
33- - name : Format check with isort
34- run : |
35- isort --check src
41+ ruff check .
3642
3743 - name : Format check with Ruff
3844 run : |
39- ruff format --check src
40-
41- # Disable bandit until issues are resolved
42- # - name: Security check with bandit
43- # run: |
44- # bandit -ll -r src
45+ ruff format --check .
4546
4647 test :
4748 runs-on : ubuntu-latest
@@ -52,10 +53,15 @@ jobs:
5253 python-version : ["3.10", "3.11", "3.12"]
5354
5455 steps :
55- - uses : actions/checkout@v3
56+ - uses : actions/checkout@v4
57+
58+ - uses : awalsh128/cache-apt-pkgs-action@latest
59+ with :
60+ packages : zsh
61+ version : 1.0
5662
5763 - name : Set up Python ${{ matrix.python-version }}
58- uses : actions/setup-python@v4
64+ uses : actions/setup-python@v5
5965 with :
6066 python-version : ${{ matrix.python-version }}
6167 cache : pip
@@ -64,46 +70,70 @@ jobs:
6470 - name : Install dependencies
6571 run : |
6672 python -m pip install --upgrade pip
67- pip install --use-deprecated=legacy-resolver -e .[test]
73+ make develop
6874
6975 - name : Test with pytest
7076 run : |
7177 make test
7278
73- deploy :
79+ - name : Upload coverage data to Codecov
80+ run : |
81+ # Verify integrity of codecov download
82+ curl https://uploader.codecov.io/verification.gpg | gpg --no-default-keyring --keyring trustedkeys.gpg --import
83+ curl -Os https://uploader.codecov.io/latest/linux/codecov
84+ curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM
85+ curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM.sig
86+ gpgv codecov.SHA256SUM.sig codecov.SHA256SUM
87+ shasum -a 256 -c codecov.SHA256SUM
88+ # Upload coverage report
89+ chmod +x codecov
90+ ./codecov
91+
92+ build :
93+ name : Build distribution
94+ if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
95+ runs-on : ubuntu-latest
7496 needs :
7597 - cqa
7698 - test
99+ steps :
100+ - uses : actions/checkout@v4
101+ - name : Set up Python
102+ uses : actions/setup-python@v5
103+ with :
104+ python-version : " 3.12"
105+ cache : pip
106+ cache-dependency-path : ' **/setup.cfg'
107+ - name : Install pypa/build
108+ run : >-
109+ python3 -m
110+ pip install
111+ build
112+ --user
113+ - name : Build a binary wheel and a source tarball
114+ run : python3 -m build
115+ - name : Store the distribution packages
116+ uses : actions/upload-artifact@v4
117+ with :
118+ name : python-package-distributions
119+ path : dist/
120+
121+ publish-to-pypi :
122+ name : >-
123+ Publish Python distribution to PyPI
124+ needs :
125+ - build
77126 runs-on : ubuntu-latest
78-
127+ environment :
128+ name : pypi
129+ url : https://pypi.org/p/bioutils
130+ permissions :
131+ id-token : write # IMPORTANT: mandatory for trusted publishing
79132 steps :
80- - name : hello world
81- run : |
82- echo "::group::Environment info"
83- echo github.event_name = ${{ github.event_name }}
84- echo refs = ${{ github.ref }}
85- echo tags = ${{ startsWith(github.ref, 'refs/tags') }}
86- echo "::endgroup::"
87-
88- - uses : actions/checkout@v3
89-
90- - name : Set up Python
91- uses : actions/setup-python@v4
92- with :
93- python-version : " 3.10"
94- cache : pip
95- cache-dependency-path : ' **/setup.cfg'
96-
97- - name : Install dependencies
98- run : |
99- python -m pip install --upgrade pip
100- pip install build
101-
102- - name : Build package
103- run : python -m build --wheel
104-
105- - name : Publish package
106- if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
107- uses : pypa/gh-action-pypi-publish@release/v1
108- with :
109- password : ${{ secrets.PYPI_API_TOKEN }}
133+ - name : Download all the dists
134+ uses : actions/download-artifact@v4
135+ with :
136+ name : python-package-distributions
137+ path : dist/
138+ - name : Publish distribution to PyPI
139+ uses : pypa/gh-action-pypi-publish@release/v1
0 commit comments