1+ # Taken from Xee and minimally modified: https://github.com/google/Xee/blob/main/.github/workflows/publish.yml
2+ #
3+ # Copyright 2023 Google LLC
4+ #
5+ # Licensed under the Apache License, Version 2.0 (the "License");
6+ # you may not use this file except in compliance with the License.
7+ # You may obtain a copy of the License at
8+ #
9+ # https://www.apache.org/licenses/LICENSE-2.0
10+ #
11+ # Unless required by applicable law or agreed to in writing, software
12+ # distributed under the License is distributed on an "AS IS" BASIS,
13+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+ # See the License for the specific language governing permissions and
15+ # limitations under the License.
16+ name : Publish to PyPi
17+
18+ on :
19+ release :
20+ types : [published]
21+
22+ jobs :
23+ build-artifacts :
24+ runs-on : ubuntu-latest
25+ steps :
26+ - uses : actions/checkout@v2
27+ - name : Set up Python
28+ uses : actions/setup-python@v2.3.1
29+ with :
30+ python-version : 3.9
31+
32+ - name : Install dependencies
33+ run : |
34+ python -m pip install --upgrade pip
35+ python -m pip install setuptools setuptools-scm wheel twine check-manifest
36+
37+ - name : Build tarball and wheels
38+ run : |
39+ git clean -xdf
40+ git restore -SW .
41+ python -m build --sdist --wheel .
42+ - name : Check built artifacts
43+ run : |
44+ python -m twine check dist/*
45+ pwd
46+ - uses : actions/upload-artifact@v2
47+ with :
48+ name : releases
49+ path : dist
50+
51+ test-built-dist :
52+ needs : build-artifacts
53+ runs-on : ubuntu-latest
54+ steps :
55+ - uses : actions/setup-python@v2.3.1
56+ name : Install Python
57+ with :
58+ python-version : 3.9
59+ - uses : actions/download-artifact@v2
60+ with :
61+ name : releases
62+ path : dist
63+ - name : List contents of built dist
64+ run : |
65+ ls -ltrh
66+ ls -ltrh dist
67+ - name : Publish package to TestPyPI
68+ if : github.event_name == 'push'
69+ uses : pypa/gh-action-pypi-publish@v1.4.2
70+ with :
71+ user : __token__
72+ password : ${{ secrets.TESTPYPI_TOKEN }}
73+ repository_url : https://test.pypi.org/legacy/
74+ verbose : true
75+
76+ - name : Check uploaded package
77+ if : github.event_name == 'push'
78+ run : |
79+ sleep 3
80+ python -m pip install --upgrade pip
81+ python -m pip install --extra-index-url https://test.pypi.org/simple --upgrade dee
82+ python -c "import dee; print(dee.__version__)"
83+ upload-to-pypi :
84+ needs : test-built-dist
85+ if : github.event_name == 'release'
86+ runs-on : ubuntu-latest
87+ steps :
88+ - uses : actions/download-artifact@v2
89+ with :
90+ name : releases
91+ path : dist
92+ - name : Publish package to PyPI
93+ uses : pypa/gh-action-pypi-publish@v1.4.2
94+ with :
95+ user : __token__
96+ password : ${{ secrets.PYPI_TOKEN }}
97+ verbose : true
0 commit comments