-
Notifications
You must be signed in to change notification settings - Fork 30
134 lines (107 loc) · 3.7 KB
/
ci.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: ci
on:
push:
branches:
- master
pull_request:
workflow_dispatch:
release:
types: [published]
jobs:
ci:
name: test-${{ matrix.os }}-python${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# this works like a loop; think `pytest.mark.parametrize`
python-version: [3.7, 3.8, 3.9, '3.10']
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: checkout build
id: checkout-build
uses: actions/checkout@v2
# with this we do not need to worry about the various ways in which
# each os installs python
- name: setup python
id: setup-python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: upgrade pip
id: upgrade-pip
run: |
python -m pip install --upgrade pip
# gets the path to wherever each os stores pip's cache
- name: get pip cache dir
id: get-pip-cache-dir
run: |
echo "::set-output name=dir::$(pip cache dir)"
- name: cache pip
uses: actions/cache@v2
id: cache-pip
with:
# set above with `get pip cache dir`
path: ${{ steps.get-pip-cache-dir.outputs.dir }}
# determines whether the hash of setup.py has changed
# CACHE_VERSION: slight hack, see https://stackoverflow.com/a/64819132
key: ${{ runner.os }}-pip-${{ secrets.CACHE_VERSION }}-${{ hashFiles('**/setup.py') }}
- name: install packages
id: install-packages
run: |
python -m pip install .[dev] codecov
- name: test
id: test
# python -m codecov only to run if exit status is 0
run: |
python -m pytest --cov=pipenv_setup --cov-report=xml && python -m codecov
test-deploy:
# this job publishes the package to TestPyPI; releases published with the
# "pre-release" tag are included
name: Publish to TestPyPI 🚀
needs: ci
runs-on: ubuntu-latest
if: github.event.release
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish to TestPyPI 🐍
# TestPyPI credentials are managed separately from PyPI
env:
TWINE_USERNAME: ${{ secrets.TEST_PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload -r testpypi dist/*
deploy:
# build and publish the package to PyPI; depend on the `test-deploy` job, and only
# run for non-draft, non-pre-release published releases.
name: Publish to PyPI 🚀
needs: test-deploy # ensure the test deployment has already passed
runs-on: ubuntu-latest
# only run for real releases, not drafts or pre-releases
if: github.event.release && !(github.event.release.draft || github.event.release.prerelease)
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish to PyPI 🐍
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*