Skip to content

Commit

Permalink
Add github actions upload to PyPI action
Browse files Browse the repository at this point in the history
  • Loading branch information
lucianopaz committed Apr 12, 2023
1 parent e7443d1 commit ad629c9
Showing 1 changed file with 80 additions and 0 deletions.
80 changes: 80 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: PyPI release
on:
release:
types: [published]

jobs:
build:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Build the sdist and the wheel
run: |
pip install build
python -m build
- name: Check the sdist installs and imports
run: |
mkdir -p test-sdist
cd test-sdist
python -m venv venv-sdist
venv-sdist/bin/python -m pip install ../dist/CausalPy*.tar.gz
# check import
venv-sdist/bin/python -c "import causalpy; assert causalpy.__version__ == '${{ github.ref_name }}'"
- name: Check the bdist installs and imports
run: |
mkdir -p test-bdist
cd test-bdist
python -m venv venv-bdist
venv-bdist/bin/python -m pip install ../dist/CausalPy*.whl
# check import
venv-bdist/bin/python -c "import causalpy; assert causalpy.__version__ == '${{ github.ref_name }}'"
- uses: actions/upload-artifact@v3
with:
name: artifact
path: dist/*
test:
name: Upload to Test PyPI
needs: [build]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
with:
skip_existing: true
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
- uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Test pip install from test.pypi
run: |
python -m venv venv-test-pypi
venv-test-pypi/bin/python -m pip install --index-url https://test.pypi.org/simple/ causalpy
# check import
venv-test-pypi/bin/python -c "import causalpy; assert causalpy.__version__ == '${{ github.ref_name }}'"
publish:
name: Upload release to PyPI
needs: [build, test]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}

0 comments on commit ad629c9

Please sign in to comment.