Skip to content

Commit

Permalink
Update PyPI workflow to build and upload intake-thredds package (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
andersy005 authored Mar 1, 2024
1 parent acf0005 commit 1c3e178
Showing 1 changed file with 56 additions and 38 deletions.
94 changes: 56 additions & 38 deletions .github/workflows/pypi.yaml
Original file line number Diff line number Diff line change
@@ -1,66 +1,84 @@
name: Upload intake-thredds to PyPI
name: Build and Upload intake-thredds to PyPI

on:
release:
types:
- published
workflow_dispatch:
push:

jobs:
test-deploy:
if: github.repository == 'intake/intake-thredds'
build-artifacts:
runs-on: ubuntu-latest
if: github.repository == 'intake/intake-thredds'
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
fetch-depth: 0
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: "3.11"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install setuptools setuptools-scm wheel twine check-manifest
- name: Build tarball and wheels
run: |
python setup.py sdist bdist_wheel
python -m pip wheel . -w dist --no-deps
- name: Test the artifacts
git clean -xdf
git restore -SW .
python -m build --sdist --wheel .
- name: Check built artifacts
run: |
python -m twine check dist/*
- name: Publish package to TestPyPI
uses: pypa/[email protected]
pwd
if [ -f dist/intake-thredds-unknown.tar.gz ]; then
echo "❌ INVALID VERSION NUMBER"
exit 1
else
echo "✅ Looks good"
fi
- uses: actions/upload-artifact@v4
with:
user: __token__
password: ${{ secrets.TESTPYPI_PASSWORD }}
repository-url: https://test.pypi.org/legacy/
verbose: true
name: releases
path: dist

deploy:
needs: test-deploy
if: startsWith(github.ref, 'refs/tags')
test-built-dist:
needs: build-artifacts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install setuptools setuptools-scm wheel twine check-manifest
- name: Build tarball and wheels
python-version: "3.11"
- uses: actions/download-artifact@v4
with:
name: releases
path: dist
- name: List contents of built dist
run: |
python setup.py sdist bdist_wheel
python -m pip wheel . -w dist --no-deps
- name: Test the artifacts
ls -ltrh
ls -ltrh dist
- name: Verify the built dist/wheel is valid
if: github.event_name == 'push'
run: |
python -m twine check dist/*
python -m pip install --upgrade pip
python -m pip install dist/intake_thredds*.whl
python -c "import intake_thredds; print(intake_thredds.__version__)"
upload-to-pypi:
needs: test-built-dist
if: github.event_name == 'release'
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
name: releases
path: dist
- name: Publish package to PyPI
uses: pypa/[email protected]
with:
user: ${{ secrets.PYPI_USERNAME }}
password: ${{ secrets.PYPI_PASSWORD }}
skip-existing: true
verbose: true

0 comments on commit 1c3e178

Please sign in to comment.