Skip to content

Commit

Permalink
update pypi publish workflow xarray-contrib/datatree#120
Browse files Browse the repository at this point in the history
  • Loading branch information
andersy005 authored Jul 14, 2022
1 parent 4c8f05d commit 0b845f3
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 15 deletions.
94 changes: 79 additions & 15 deletions .github/workflows/pypipublish.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,85 @@
name: Upload Python Package

name: Build distribution
on:
release:
types: [created]
types:
- published
push:
branches:
- main
pull_request:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
deploy:
build-artifacts:
runs-on: ubuntu-latest
if: github.repository == 'xarray-contrib/datatree'
steps:
- uses: actions/checkout@v2
with:
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
python -m pip install build
- name: Build tarball and wheels
run: |
git clean -xdf
git restore -SW .
python -m build --sdist --wheel .
- 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.10'
- uses: actions/download-artifact@v2
with:
name: releases
path: dist
- name: List contents of built dist
run: |
ls -ltrh
ls -ltrh dist
- name: Verify the built dist/wheel is valid
if: github.event_name == 'push'
run: |
python -m pip install --upgrade pip
python -m pip install dist/xarray-datatree*.whl
python -c "import datatree; print(datatree.__version__)"
upload-to-pypi:
needs: test-built-dist
if: github.event_name == 'release'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build distributions
run: |
$CONDA/bin/python -m pip install build
$CONDA/bin/python -m build
- name: Publish a Python distribution to PyPI
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: ${{ secrets.PYPI_USERNAME }}
password: ${{ secrets.PYPI_PASSWORD }}
- uses: actions/download-artifact@v2
with:
name: releases
path: dist
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@v1.5.0
with:
user: __token__
password: ${{ secrets.PYPI_PASSWORD }}
verbose: true
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ requires = [
"wheel",
"setuptools_scm[toml]>=3.4",
"setuptools_scm_git_archive",
"check-manifest"
]

[tool.setuptools_scm]
Expand Down

0 comments on commit 0b845f3

Please sign in to comment.