-
Notifications
You must be signed in to change notification settings - Fork 2
87 lines (80 loc) · 2.69 KB
/
python-package.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Build, Test and Release Python Package
on:
push:
pull_request:
branches: [ master ]
jobs:
build:
# Currently Ubuntu 20.04
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.5", "3.6", "3.7", "3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .
python -m pip install pytest
- name: Test with pytest
run: |
python -m pytest --doctest-modules --junitxml junit/test-results-${{ matrix.python-version }}.xml
- name: Publish pytest test results
uses: mikepenz/action-junit-report@v2
with:
report_paths: junit/test-results*.xml
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}
deploy-test:
runs-on: ubuntu-latest
environment: Development
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
# Build on the latest version of Python
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build --sdist --wheel
- name: Publish package to Test PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.DEV_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true
deploy-production:
runs-on: ubuntu-latest
environment: Production
if: startsWith(github.ref, 'refs/tags')
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
# Build on the latest version of Python
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build --sdist --wheel
- name: Publish package to PyPi
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PROD_PYPI_API_TOKEN }}