|
| 1 | +name: Build and Upload xarray to PyPI |
| 2 | +on: |
| 3 | + release: |
| 4 | + types: |
| 5 | + - published |
| 6 | + push: |
| 7 | + tags: |
| 8 | + - 'v*' |
| 9 | + |
| 10 | +jobs: |
| 11 | + build-artifacts: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + if: github.repository == 'pydata/xarray' |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v2 |
| 16 | + with: |
| 17 | + fetch-depth: 0 |
| 18 | + - uses: actions/setup-python@v2 |
| 19 | + name: Install Python |
| 20 | + with: |
| 21 | + python-version: 3.8 |
| 22 | + |
| 23 | + - name: Install dependencies |
| 24 | + run: | |
| 25 | + python -m pip install --upgrade pip |
| 26 | + python -m pip install setuptools setuptools-scm wheel twine check-manifest |
| 27 | +
|
| 28 | + - name: Build tarball and wheels |
| 29 | + run: | |
| 30 | + git clean -xdf |
| 31 | + git restore -SW . |
| 32 | + python -m build --sdist --wheel . |
| 33 | +
|
| 34 | + - name: Check built artifacts |
| 35 | + run: | |
| 36 | + python -m twine check dist/* |
| 37 | + pwd |
| 38 | + if [ -f dist/xarray-0.0.0.tar.gz ]; then |
| 39 | + echo "❌ INVALID VERSION NUMBER" |
| 40 | + exit 1 |
| 41 | + else |
| 42 | + echo "✅ Looks good" |
| 43 | + fi |
| 44 | + - uses: actions/upload-artifact@v2 |
| 45 | + with: |
| 46 | + name: releases |
| 47 | + path: dist |
| 48 | + |
| 49 | + test-built-dist: |
| 50 | + needs: build-artifacts |
| 51 | + runs-on: ubuntu-latest |
| 52 | + steps: |
| 53 | + - uses: actions/setup-python@v2 |
| 54 | + name: Install Python |
| 55 | + with: |
| 56 | + python-version: 3.8 |
| 57 | + - uses: actions/download-artifact@v2 |
| 58 | + with: |
| 59 | + name: releases |
| 60 | + path: dist |
| 61 | + - name: List contents of built dist |
| 62 | + run: | |
| 63 | + ls -ltrh |
| 64 | + ls -ltrh dist |
| 65 | + - name: Publish package to TestPyPI |
| 66 | + if: github.event_name == 'push' |
| 67 | + |
| 68 | + with: |
| 69 | + user: __token__ |
| 70 | + password: ${{ secrets.TESTPYPI_TOKEN }} |
| 71 | + repository_url: https://test.pypi.org/legacy/ |
| 72 | + verbose: true |
| 73 | + |
| 74 | + - name: Check uploaded package |
| 75 | + if: github.event_name == 'push' |
| 76 | + run: | |
| 77 | + sleep 3 |
| 78 | + python -m pip install --upgrade pip |
| 79 | + python -m pip install --extra-index-url https://test.pypi.org/simple --upgrade xarray |
| 80 | + python -m xarray.util.print_versions |
| 81 | +
|
| 82 | + upload-to-pypi: |
| 83 | + needs: test-built-dist |
| 84 | + if: github.event_name == 'release' |
| 85 | + runs-on: ubuntu-latest |
| 86 | + steps: |
| 87 | + - uses: actions/download-artifact@v2 |
| 88 | + with: |
| 89 | + name: releases |
| 90 | + path: dist |
| 91 | + - name: Publish package to PyPI |
| 92 | + |
| 93 | + with: |
| 94 | + user: __token__ |
| 95 | + password: ${{ secrets.PYPI_TOKEN }} |
| 96 | + verbose: true |
0 commit comments