1+ name : Build and Upload symmray to PyPI
2+ on :
3+ workflow_dispatch :
4+ release :
5+ types :
6+ - published
7+ push :
8+ tags :
9+ - ' v*'
10+
11+ jobs :
12+ build-artifacts :
13+ runs-on : ubuntu-latest
14+ if : github.repository == 'jcmgray/symmray'
15+ steps :
16+ - uses : actions/checkout@v6
17+ with :
18+ fetch-depth : 0
19+ - uses : actions/setup-python@v6
20+ name : Install Python
21+ with :
22+ python-version : " 3.12"
23+
24+ - name : Install dependencies
25+ run : |
26+ python -m pip install --upgrade pip
27+ python -m pip install build twine
28+
29+ - name : Build tarball and wheels
30+ run : |
31+ git clean -xdf
32+ git restore -SW .
33+ python -m build
34+
35+ - name : Check built artifacts
36+ run : |
37+ python -m twine check --strict dist/*
38+ pwd
39+ if [ -f dist/symmray-0.0.0.tar.gz ]; then
40+ echo "❌ INVALID VERSION NUMBER"
41+ exit 1
42+ else
43+ echo "✅ Looks good"
44+ fi
45+ - uses : actions/upload-artifact@v5
46+ with :
47+ name : releases
48+ path : dist
49+
50+ test-built-dist :
51+ needs : build-artifacts
52+ runs-on : ubuntu-latest
53+ steps :
54+ - uses : actions/setup-python@v6
55+ name : Install Python
56+ with :
57+ python-version : " 3.12"
58+ - uses : actions/download-artifact@v6
59+ with :
60+ name : releases
61+ path : dist
62+ - name : List contents of built dist
63+ run : |
64+ ls -ltrh
65+ ls -ltrh dist
66+
67+ - name : Verify the built dist/wheel is valid
68+ if : github.event_name == 'push'
69+ run : |
70+ python -m pip install --upgrade pip
71+ python -m pip install dist/symmray*.whl
72+
73+ upload-to-test-pypi :
74+ needs : test-built-dist
75+ if : github.event_name == 'push'
76+ runs-on : ubuntu-latest
77+
78+ environment :
79+ name : pypi
80+ url : https://test.pypi.org/p/symmray
81+ permissions :
82+ id-token : write
83+
84+ steps :
85+ - uses : actions/download-artifact@v6
86+ with :
87+ name : releases
88+ path : dist
89+ - name : Publish package to TestPyPI
90+ if : github.event_name == 'push'
91+ uses : pypa/gh-action-pypi-publish@v1.13.0
92+ with :
93+ repository-url : https://test.pypi.org/legacy/
94+ verbose : true
95+
96+ upload-to-pypi :
97+ needs : test-built-dist
98+ if : github.event_name == 'release'
99+ runs-on : ubuntu-latest
100+
101+ environment :
102+ name : pypi
103+ url : https://pypi.org/p/symmray
104+ permissions :
105+ id-token : write
106+
107+ steps :
108+ - uses : actions/download-artifact@v6
109+ with :
110+ name : releases
111+ path : dist
112+ - name : Publish package to PyPI
113+ uses : pypa/gh-action-pypi-publish@v1.13.0
114+ with :
115+ verbose : true
0 commit comments