Skip to content

Commit 736f42b

Browse files
committed
Add GitHub Actions workflow to publish releases to PyPI
1 parent 2827cb0 commit 736f42b

File tree

1 file changed

+122
-0
lines changed

1 file changed

+122
-0
lines changed

.github/workflows/package.yml

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: Package
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
jobs:
8+
9+
build-wheel:
10+
runs-on: ubuntu-latest
11+
name: Build wheel distribution
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v2
15+
with:
16+
submodules: true
17+
- name: Setup Python ${{ matrix.python-version }}
18+
uses: actions/setup-python@v2
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
- name: Update build dependencies
22+
run: python -m pip install -U pip wheel setuptools
23+
- name: Build wheel distribution
24+
run: python setup.py bdist_wheel
25+
- name: Store built wheel
26+
uses: actions/upload-artifact@v2
27+
with:
28+
name: dist
29+
path: dist/*
30+
31+
build-sdist:
32+
runs-on: ubuntu-latest
33+
name: Build source distribution
34+
steps:
35+
- name: Checkout code
36+
uses: actions/checkout@v2
37+
with:
38+
submodules: true
39+
- name: Set up Python 3.9
40+
uses: actions/setup-python@v2
41+
with:
42+
python-version: 3.9
43+
- name: Update build dependencies
44+
run: python -m pip install -U pip wheel setuptools
45+
- name: Build source distribution
46+
run: python setup.py sdist
47+
- name: Store source distribution
48+
uses: actions/upload-artifact@v2
49+
with:
50+
name: dist
51+
path: dist/*
52+
53+
test-sdist:
54+
runs-on: ubuntu-latest
55+
name: Test source distribution
56+
needs:
57+
- build-sdist
58+
steps:
59+
- name: Checkout code
60+
uses: actions/checkout@v2
61+
with:
62+
submodules: true
63+
- name: Download source distribution
64+
uses: actions/download-artifact@v2
65+
with:
66+
name: dist
67+
path: dist
68+
- name: Install source distribution
69+
run: python -m pip install dist/fs-*.tar.gz
70+
- name: Remove source code
71+
run: rm -rvd fs
72+
- name: Install test requirements
73+
run: python -m pip install -r tests/requirements.txt
74+
- name: Test installed package
75+
run: python -m unittest discover -vv
76+
77+
test-wheel:
78+
runs-on: ubuntu-latest
79+
name: Test wheel distribution
80+
needs:
81+
- build-wheel
82+
steps:
83+
- name: Checkout code
84+
uses: actions/checkout@v2
85+
with:
86+
submodules: true
87+
- name: Download source distribution
88+
uses: actions/download-artifact@v2
89+
with:
90+
name: dist
91+
path: dist
92+
- name: Install source distribution
93+
run: python -m pip install dist/fs-*.whl
94+
- name: Remove source code
95+
run: rm -rvd fs
96+
- name: Install test requirements
97+
run: python -m pip install -r tests/requirements.txt
98+
- name: Test installed package
99+
run: python -m unittest discover -vv
100+
101+
upload:
102+
environment: PyPI
103+
runs-on: ubuntu-latest
104+
name: Upload
105+
needs:
106+
- build-sdist
107+
- build-wheel
108+
- test-sdist
109+
- test-wheel
110+
steps:
111+
- name: Download built distributions
112+
uses: actions/download-artifact@v2
113+
with:
114+
name: dist
115+
path: dist
116+
- name: Publish distributions to PyPI
117+
if: startsWith(github.ref, 'refs/tags/v')
118+
uses: pypa/gh-action-pypi-publish@master
119+
with:
120+
user: __token__
121+
password: ${{ secrets.PYPI_API_TOKEN }}
122+
skip_existing: false

0 commit comments

Comments
 (0)