Skip to content

Commit bcb8eb2

Browse files
committed
Add PyPI release workflow
1 parent 0bba2ef commit bcb8eb2

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

.github/workflows/pypi-release.yaml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Build and Upload pythia-datasets to PyPI
2+
on:
3+
release:
4+
types:
5+
- published
6+
7+
jobs:
8+
build-artifacts:
9+
runs-on: ubuntu-latest
10+
if: github.repository == 'ProjectPythia/pythia-datasets'
11+
steps:
12+
- uses: actions/checkout@v2
13+
with:
14+
fetch-depth: 0
15+
- uses: actions/setup-python@v2
16+
name: Install Python
17+
with:
18+
python-version: 3.8
19+
20+
- name: Install dependencies
21+
run: |
22+
python -m pip install --upgrade pip
23+
python -m pip install setuptools setuptools-scm wheel twine check-manifest
24+
25+
- name: Build tarball and wheels
26+
run: |
27+
git clean -xdf
28+
git restore -SW .
29+
python -m build --sdist --wheel .
30+
31+
- name: Check built artifacts
32+
run: |
33+
python -m twine check dist/*
34+
pwd
35+
if [ -f dist/pythia-datasets-0.0.0.tar.gz ]; then
36+
echo "❌ INVALID VERSION NUMBER"
37+
exit 1
38+
else
39+
echo "✅ Looks good"
40+
fi
41+
- uses: actions/upload-artifact@v2
42+
with:
43+
name: releases
44+
path: dist
45+
46+
test-built-dist:
47+
needs: build-artifacts
48+
runs-on: ubuntu-latest
49+
steps:
50+
- uses: actions/setup-python@v2
51+
name: Install Python
52+
with:
53+
python-version: 3.8
54+
- uses: actions/download-artifact@v2
55+
with:
56+
name: releases
57+
path: dist
58+
- name: List contents of built dist
59+
run: |
60+
ls -ltrh
61+
ls -ltrh dist
62+
63+
upload-to-pypi:
64+
needs: test-built-dist
65+
if: github.event_name == 'release'
66+
runs-on: ubuntu-latest
67+
steps:
68+
- uses: actions/download-artifact@v2
69+
with:
70+
name: releases
71+
path: dist
72+
- name: Publish package to PyPI
73+
uses: pypa/[email protected]
74+
with:
75+
user: __token__
76+
password: ${{ secrets.PYPI_TOKEN }}
77+
verbose: true

0 commit comments

Comments
 (0)