-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update pypi publish workflow xarray-contrib/datatree#120
- Loading branch information
1 parent
4c8f05d
commit 0b845f3
Showing
2 changed files
with
80 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters