-
Notifications
You must be signed in to change notification settings - Fork 5
77 lines (74 loc) · 2.38 KB
/
release_pypi.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
name: PyPI package
on:
push:
branches:
- master
tags:
- v*
pull_request:
jobs:
test:
name: Test package
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
steps:
# checkout the repo
- uses: actions/checkout@v2
# setup python environment
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
# install the test dependencies
- name: Install test dependencies
run: |
python -m pip install --upgrade pip
pip install pipenv
pipenv lock --dev --keep-outdated
pipenv sync --dev
- name: Test package
run: |
pipenv run pytest
build-publish:
name: Build and publish package
if: ${{ github.event_name == 'push' }}
needs: test
runs-on: ubuntu-latest
steps:
# checkout the repo
- uses: actions/checkout@v2
with:
# fetch complete history because it's needed in setup.py
fetch-depth: 0
# also fetch all tags
- run: git fetch origin +refs/tags/*:refs/tags/*
# setup python environment
- name: Set up Python 3.6
uses: actions/setup-python@v2
with:
python-version: "3.6"
# install the build dependencies
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade setuptools wheel twine pipenv-setup chardet
- name: Update setup.py according to Pipfile
run: pipenv-setup sync
- name: Build package
run: python setup.py sdist bdist_wheel
# on a regular push publish the package to test PyPI repo
- name: Publish test package
env:
TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TEST_TOKEN }}
run: twine upload dist/*
# on a release push publish the package to the regular PyPI repo
- name: Publish release package
if: startsWith(github.event.ref, 'refs/tags')
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: twine upload dist/*