Skip to content

Commit f6a5dd4

Browse files
authored
Merge pull request #332 from effigies/ci/fork_safe_packaging
CI: Check for secrets before deploying, switch to python-build
2 parents af61e91 + 6df9c98 commit f6a5dd4

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

.github/workflows/package.yml

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,27 +35,34 @@ jobs:
3535
python-version: ${{ matrix.python-version }}
3636
- name: Display Python version
3737
run: python -c "import sys; print(sys.version)"
38-
- name: Check python version and upgrade pip
38+
- name: Check python version and install build
3939
run: |
4040
python --version
41-
python -m pip install -U pip setuptools virtualenv twine
41+
python -m pip install -U build twine
4242
- name: Build fitlins
4343
run: |
44-
virtualenv --python=python /tmp/venv/build
45-
source /tmp/venv/build/bin/activate
46-
pip install --upgrade pip setuptools wheel
47-
python setup.py sdist
48-
pip wheel --no-deps -w dist/ .
44+
python -m build
45+
- name: Check distributions
46+
run: twine check dist/*
47+
- name: Check for PyPI token
48+
id: deployable
49+
env:
50+
TEST_PYPI_API_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }}
51+
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
52+
run: |
53+
if [ -n "$PYPI_API_TOKEN" ]; then echo ::set-output name=DEPLOY::true; fi
54+
if [ -n "$TEST_PYPI_API_TOKEN" ]; then echo ::set-output name=TEST_DEPLOY::true; fi
4955
- name: Test PyPI upload
50-
uses: pypa/gh-action-pypi-publish@master
56+
if: steps.deployable.outputs.TEST_DEPLOY
57+
uses: pypa/gh-action-pypi-publish@release/v1
5158
with:
5259
user: __token__
5360
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
5461
repository_url: https://test.pypi.org/legacy/
5562
skip_existing: true
5663
- name: Upload to PyPI (on tags)
57-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
58-
uses: pypa/gh-action-pypi-publish@master
64+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') && steps.deployable.outputs.DEPLOY
65+
uses: pypa/gh-action-pypi-publish@release/v1
5966
with:
6067
user: __token__
6168
password: ${{ secrets.PYPI_API_TOKEN }}

0 commit comments

Comments
 (0)