Skip to content

Commit bc78a89

Browse files
committed
Always run build step. Only run upload steps on releases. Add pypi url extra index
1 parent ad629c9 commit bc78a89

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

.github/workflows/release.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: PyPI release
22
on:
3+
pull_request:
4+
branches: [main]
5+
push:
6+
branches: [main]
37
release:
48
types: [published]
59

@@ -24,16 +28,18 @@ jobs:
2428
cd test-sdist
2529
python -m venv venv-sdist
2630
venv-sdist/bin/python -m pip install ../dist/CausalPy*.tar.gz
27-
# check import
28-
venv-sdist/bin/python -c "import causalpy; assert causalpy.__version__ == '${{ github.ref_name }}'"
31+
echo "Checking import and version number (on release)"
32+
venv-sdist/bin/python -c "import causalpy; assert causalpy.__version__ == '${{ github.ref_name }}' if '${{ github.ref_type }}' == 'tag' else causalpy.__version__; print(causalpy.__version__)"
33+
cd ..
2934
- name: Check the bdist installs and imports
3035
run: |
3136
mkdir -p test-bdist
3237
cd test-bdist
3338
python -m venv venv-bdist
3439
venv-bdist/bin/python -m pip install ../dist/CausalPy*.whl
35-
# check import
36-
venv-bdist/bin/python -c "import causalpy; assert causalpy.__version__ == '${{ github.ref_name }}'"
40+
echo "Checking import and version number (on release)"
41+
venv-bdist/bin/python -c "import causalpy; assert causalpy.__version__ == '${{ github.ref_name }}' if '${{ github.ref_type }}' == 'tag' else causalpy.__version__; print(causalpy.__version__)"
42+
cd ..
3743
- uses: actions/upload-artifact@v3
3844
with:
3945
name: artifact
@@ -59,9 +65,12 @@ jobs:
5965
python-version: 3.8
6066
- name: Test pip install from test.pypi
6167
run: |
68+
# Give time to test.pypi to update its index. If we don't wait,
69+
# we might request to install before test.pypi is aware that it actually has the package
70+
sleep 5s
6271
python -m venv venv-test-pypi
63-
venv-test-pypi/bin/python -m pip install --index-url https://test.pypi.org/simple/ causalpy
64-
# check import
72+
venv-test-pypi/bin/python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple causalpy
73+
echo "Checking import and version number"
6574
venv-test-pypi/bin/python -c "import causalpy; assert causalpy.__version__ == '${{ github.ref_name }}'"
6675
6776
publish:

0 commit comments

Comments
 (0)