Skip to content

Commit

Permalink
Adopt more finegrained publish action from xarray (#53)
Browse files Browse the repository at this point in the history
* Adopt more finegrained publish action from xarray

This implements the packaging for each test run, but only publishes to pypi when its triggered by a release

* Trigger for pull requests

* Update pythonpublish.yaml

* Add numpy to required packages

* Check version when building package
  • Loading branch information
jbusecke committed May 28, 2021
1 parent 42e6e01 commit 66ba787
Showing 1 changed file with 83 additions and 17 deletions.
100 changes: 83 additions & 17 deletions .github/workflows/pythonpublish.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,96 @@

name: Upload Python Package

name: Build and Upload xmovie to PyPI
on:
release:
types: [created]
types:
- published
pull_request:
branches:
- "*"

jobs:
deploy:
if: github.repository == 'jbusecke/xmovie'
build-artifacts:
runs-on: ubuntu-latest
if: github.repository == 'jbusecke/xmovie'
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2.2.2
with:
python-version: '3.x'
fetch-depth: 0
- uses: actions/setup-python@v2
name: Install Python
with:
python-version: 3.8

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools setuptools-scm wheel twine toml
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
python -m pip install setuptools setuptools-scm wheel twine check-manifest
- name: Check current package version
run: |
python setup.py --version
- name: Build tarball and wheels
run: |
git clean -xdf
git restore -SW .
python -m build --sdist --wheel .
- name: Check built artifacts
run: |
python -m twine check dist/*
pwd
if [ -f dist/xmovie-0.0.0.tar.gz ]; then
echo "❌ INVALID VERSION NUMBER"
exit 1
else
echo "✅ Looks good"
fi
- uses: actions/upload-artifact@v2
with:
name: releases
path: dist

test-built-dist:
needs: build-artifacts
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v2
name: Install Python
with:
python-version: 3.8
- uses: actions/download-artifact@v2
with:
name: releases
path: dist
- name: List contents of built dist
run: |
ls -ltrh
ls -ltrh dist
- name: Publish package to TestPyPI
if: github.event_name == 'pull_request'
uses: pypa/gh-action-pypi-publish@v1.4.2
with:
user: __token__
password: ${{ secrets.TESTPYPI_TOKEN }}
repository_url: https://test.pypi.org/legacy/
verbose: true

- name: Check uploaded package
if: github.event_name == 'pull_request'
run: |
python setup.py sdist bdist_wheel
sleep 3
python -m pip install --upgrade pip
python -m pip install --extra-index-url https://test.pypi.org/simple --upgrade xmovie
python setup.py --version
twine check dist/*
twine upload dist/*
upload-to-pypi:
needs: test-built-dist
if: github.event_name == 'release'
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
with:
name: releases
path: dist
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@v1.4.2
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
verbose: true

0 comments on commit 66ba787

Please sign in to comment.