Skip to content

Commit 97488a8

Browse files
authored
[Build/CI Change] Publish to test pypi during the release workflow (#44)
1 parent 12e7011 commit 97488a8

File tree

2 files changed

+74
-4
lines changed

2 files changed

+74
-4
lines changed

.github/workflows/publish-to-pypi.yml

Lines changed: 73 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ permissions:
1616
contents: read
1717

1818
jobs:
19-
deploy:
19+
build-artifact:
20+
name: Build package
2021
runs-on: ubuntu-latest
21-
permissions:
22-
id-token: write
2322
steps:
2423
- uses: actions/checkout@v3
2524
- name: Set up Python
@@ -31,6 +30,76 @@ jobs:
3130
python -m pip install --upgrade pip
3231
pip install build
3332
- name: Build package
34-
run: python -m build
33+
run: |
34+
python -m build
35+
echo ""
36+
echo "Generated files:"
37+
ls -lh dist/
38+
- uses: actions/upload-artifact@v3
39+
with:
40+
name: releases
41+
path: dist
42+
test-built-dist:
43+
name: Test package
44+
needs: build-artifact
45+
runs-on: ubuntu-latest
46+
steps:
47+
- uses: actions/checkout@v3
48+
- name: Set up Python
49+
uses: actions/setup-python@v4
50+
with:
51+
python-version: '3.10'
52+
- uses: actions/download-artifact@v3
53+
with:
54+
name: releases
55+
path: dist
56+
- name: List contents of built dist
57+
run: |
58+
ls -ltrh
59+
ls -ltrh dist
60+
- name: Publish distribution 📦 to TestPyPI
61+
uses: pypa/gh-action-pypi-publish@release/v1
62+
with:
63+
# TODO: Set up TEST_PYPI_API_TOKEN secret in GitHub Actions settings
64+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
65+
repository-url: https://test.pypi.org/legacy/
66+
verbose: true
67+
skip_existing: true
68+
- name: Check pypi packages
69+
id: check_pkg
70+
run: |
71+
# Install local wheel to get the version number
72+
echo "=== Testing wheel file ==="
73+
pip install dist/autora_doc*.whl
74+
latest_version="$(python -c 'from autora import doc; print(doc.__version__)')";export latest_version
75+
echo "latest_version=$latest_version" >> $GITHUB_OUTPUT
76+
echo "=== Got version $latest_version from local wheel install ==="
77+
python -m pip uninstall --yes autora-doc
78+
sleep 5
79+
80+
python -m pip install --upgrade pip
81+
echo "=== Testing Test PyPi installation ==="
82+
# Install wheel to get dependencies and check import
83+
python -m pip install --extra-index-url https://test.pypi.org/simple --upgrade --pre autora-doc==$latest_version
84+
echo "=== Done testing Test PyPi file ==="
85+
echo "=== Testing source tar file ==="
86+
# Install tar gz and check import
87+
python -m pip uninstall --yes autora-doc
88+
python -m pip install --extra-index-url https://test.pypi.org/simple --upgrade --pre --no-binary=autora-doc autora-doc==$latest_version
89+
python -c "from autora import doc; print(doc.__version__)"
90+
echo "=== Done testing source tar file ==="
91+
outputs:
92+
package-version: ${{steps.check_pkg.outputs.latest_version}}
93+
publish:
94+
name: Publish distribution 📦 to PyPI
95+
needs: test-built-dist
96+
runs-on: ubuntu-latest
97+
permissions:
98+
id-token: write
99+
steps:
100+
- uses: actions/download-artifact@v3
101+
with:
102+
name: releases
103+
path: dist
35104
- name: Publish package
36105
uses: pypa/gh-action-pypi-publish@release/v1

src/autora/doc/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from ._version import __version__

0 commit comments

Comments
 (0)