|
1 |
| -name: Upload Python Package |
2 |
| - |
| 1 | +name: Build distribution |
3 | 2 | on:
|
4 | 3 | release:
|
5 |
| - types: [created] |
| 4 | + types: |
| 5 | + - published |
| 6 | + push: |
| 7 | + branches: |
| 8 | + - main |
| 9 | + pull_request: |
| 10 | + branches: |
| 11 | + - main |
| 12 | + |
| 13 | +concurrency: |
| 14 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 15 | + cancel-in-progress: true |
6 | 16 |
|
7 | 17 | jobs:
|
8 |
| - deploy: |
| 18 | + build-artifacts: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + if: github.repository == 'xarray-contrib/datatree' |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v2 |
| 23 | + with: |
| 24 | + fetch-depth: 0 |
| 25 | + - uses: actions/setup-python@v2 |
| 26 | + name: Install Python |
| 27 | + with: |
| 28 | + python-version: 3.8 |
| 29 | + |
| 30 | + - name: Install dependencies |
| 31 | + run: | |
| 32 | + python -m pip install --upgrade pip |
| 33 | + python -m pip install build |
| 34 | +
|
| 35 | + - name: Build tarball and wheels |
| 36 | + run: | |
| 37 | + git clean -xdf |
| 38 | + git restore -SW . |
| 39 | + python -m build --sdist --wheel . |
| 40 | +
|
| 41 | +
|
| 42 | + - uses: actions/upload-artifact@v2 |
| 43 | + with: |
| 44 | + name: releases |
| 45 | + path: dist |
| 46 | + |
| 47 | + test-built-dist: |
| 48 | + needs: build-artifacts |
| 49 | + runs-on: ubuntu-latest |
| 50 | + steps: |
| 51 | + - uses: actions/setup-python@v2 |
| 52 | + name: Install Python |
| 53 | + with: |
| 54 | + python-version: '3.10' |
| 55 | + - uses: actions/download-artifact@v2 |
| 56 | + with: |
| 57 | + name: releases |
| 58 | + path: dist |
| 59 | + - name: List contents of built dist |
| 60 | + run: | |
| 61 | + ls -ltrh |
| 62 | + ls -ltrh dist |
| 63 | +
|
| 64 | + - name: Verify the built dist/wheel is valid |
| 65 | + if: github.event_name == 'push' |
| 66 | + run: | |
| 67 | + python -m pip install --upgrade pip |
| 68 | + python -m pip install dist/xarray-datatree*.whl |
| 69 | + python -c "import datatree; print(datatree.__version__)" |
| 70 | +
|
| 71 | + upload-to-pypi: |
| 72 | + needs: test-built-dist |
| 73 | + if: github.event_name == 'release' |
9 | 74 | runs-on: ubuntu-latest
|
10 | 75 | steps:
|
11 |
| - - uses: actions/checkout@v3 |
12 |
| - - name: Build distributions |
13 |
| - run: | |
14 |
| - $CONDA/bin/python -m pip install build |
15 |
| - $CONDA/bin/python -m build |
16 |
| - - name: Publish a Python distribution to PyPI |
17 |
| - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') |
18 |
| - uses: pypa/gh-action-pypi-publish@release/v1 |
19 |
| - with: |
20 |
| - user: ${{ secrets.PYPI_USERNAME }} |
21 |
| - password: ${{ secrets.PYPI_PASSWORD }} |
| 76 | + - uses: actions/download-artifact@v2 |
| 77 | + with: |
| 78 | + name: releases |
| 79 | + path: dist |
| 80 | + - name: Publish package to PyPI |
| 81 | + |
| 82 | + with: |
| 83 | + user: __token__ |
| 84 | + password: ${{ secrets.PYPI_PASSWORD }} |
| 85 | + verbose: true |
0 commit comments