-
Notifications
You must be signed in to change notification settings - Fork 10
66 lines (53 loc) · 2.22 KB
/
build-and-publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
name: Build and Publish
on:
# Triggers the workflow on push events but only for the main branch
push:
branches: [ main ]
permissions:
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8"]
# "PUBLISH-PYPI" or "PUBLISH-TESTPYPI" is treated as a command
if: "contains(github.event.head_commit.message, 'PUBLISH-')"
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
# You can test your matrix by printing the current Python version
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
pip install flake8 pytest
# if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=15 --max-line-length=127 --statistics
- name: Build package
run: python -m build --wheel --outdir dist/
- name: Publish distribution 📦 to Test PyPI
if: "contains(github.event.head_commit.message, 'PUBLISH-TESTPYPI')"
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
- name: Publish distribution 📦 to PYPI
if: "contains(github.event.head_commit.message, 'PUBLISH-PYPI')"
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}