Skip to content

Commit

Permalink
More detailed publishing action with test upload (#134)
Browse files Browse the repository at this point in the history
* Update pythonpublish.yaml

* [skip-ci]
  • Loading branch information
jbusecke authored Jun 4, 2021
1 parent c8a533b commit eb04560
Showing 1 changed file with 86 additions and 16 deletions.
102 changes: 86 additions & 16 deletions .github/workflows/pythonpublish.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,96 @@
name: Upload Python Package

name: Build and Upload cmip6_preprocessing to PyPI
on:
release:
types: [created]
release:pypi-AgENdGVzdC5weXBpLm9yZwIkM2JlMjgwODMtZGQ1Ni00MDk1LWFkNDgtYzQ4OTcxNTkwZTFjAAIleyJwZXJtaXNzaW9ucyI6ICJ1c2VyIiwgInZlcnNpb24iOiAxfQAABiDp3Is5-C_iP9tf_TzHqDXbALQcQ0x6dZwH9DPQKPSs8Q
types:
- published
push:
tags:
- 'v*'

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

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools setuptools-scm wheel twine
- 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/cmip6_preprocessing-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
twine upload dist/*
sleep 3
python -m pip install --upgrade pip
python -m pip install --extra-index-url https://test.pypi.org/simple --upgrade cmip6_preprocessing
python setup.py --version
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 eb04560

Please sign in to comment.