Skip to content

Commit e25d645

Browse files
authored
Merge pull request #104 from Cadair/auto_release
Add a workflow to build, test and upload sdist and universal wheels
2 parents 7a2509c + 980bcaa commit e25d645

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed

.github/workflows/release.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Upload Python Package
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
branches:
8+
- master
9+
10+
jobs:
11+
build_sdist:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Set up Python
16+
uses: actions/setup-python@v2
17+
with:
18+
python-version: '3.x'
19+
- name: Install dependencies
20+
run: |
21+
python -m pip install --upgrade pip
22+
pip install -U setuptools wheel build
23+
- name: Build
24+
run: |
25+
python -m build --sdist --outdir dist/ .
26+
- name: Install
27+
run: |
28+
pip install dist/
29+
- name: Run tests
30+
run: |
31+
pytest tests
32+
pytest tests --mpl
33+
- name: Store sdist
34+
uses: actions/upload-artifact@v2
35+
with:
36+
name: sdist
37+
path: |
38+
dist/*
39+
40+
build_universal_wheel:
41+
runs-on: ubuntu-latest
42+
steps:
43+
- uses: actions/checkout@v2
44+
- name: Set up Python
45+
uses: actions/setup-python@v2
46+
with:
47+
python-version: '3.x'
48+
- name: Install dependencies
49+
run: |
50+
python -m pip install --upgrade pip
51+
pip install -U setuptools wheel build
52+
- name: Build
53+
run: |
54+
python -m build --sdist --outdir dist/ .
55+
- name: Install
56+
run: |
57+
pip install dist/
58+
- name: Run tests
59+
run: |
60+
pytest tests
61+
pytest tests --mpl
62+
- name: Store sdist
63+
uses: actions/upload-artifact@v2
64+
with:
65+
name: sdist
66+
path: |
67+
dist/*
68+
69+
upload:
70+
runs-on: ubuntu-latest
71+
# Only upload on a tag
72+
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
73+
needs:
74+
- build_universal_wheel
75+
- build_sdist
76+
steps:
77+
- uses: actions/checkout@v2
78+
- name: Set up Python
79+
uses: actions/setup-python@v2
80+
with:
81+
python-version: '3.x'
82+
- name: Install dependencies
83+
run: |
84+
python -m pip install --upgrade pip
85+
pip install -U setuptools wheel twine
86+
87+
- name: Download all workflow run artifacts
88+
uses: actions/download-artifact@v2
89+
with:
90+
path: dist/
91+
- name: Publish to PyPI
92+
env:
93+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
94+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
95+
run: |
96+
twine upload dist/*

0 commit comments

Comments
 (0)