From eecf2e950d4584a847e443a7f4ec54567a6fac70 Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Sat, 1 May 2021 22:36:31 -0600 Subject: [PATCH 01/21] Add GitHub action for publishing artifacts to PyPI --- .github/workflows/pypi-release.yaml | 52 +++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/pypi-release.yaml diff --git a/.github/workflows/pypi-release.yaml b/.github/workflows/pypi-release.yaml new file mode 100644 index 00000000000..4b4ccae48fe --- /dev/null +++ b/.github/workflows/pypi-release.yaml @@ -0,0 +1,52 @@ +name: Build and Upload xarray to PyPI +on: + release: + types: + - published + push: + pull_request: + + +jobs: + build-artifacts: + runs-on: ubuntu-latest + 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 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 + run: | + python -m twine check dist/* + + - uses: actions/upload-artifact@v2 + with: + name: releases + path: dist + + test-built-dist: + needs: build-artifacts + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v2 + with: + name: releases + path: dist + - name: List contents of built dist + run: | + ls -ltrh + ls -ltrh dist From f62aa07199d273bf3234ceb1f63775d6b5d1c102 Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Sat, 1 May 2021 22:43:27 -0600 Subject: [PATCH 02/21] Attempt at installing built artifacts --- .github/workflows/pypi-release.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/pypi-release.yaml b/.github/workflows/pypi-release.yaml index 4b4ccae48fe..47f7cba527b 100644 --- a/.github/workflows/pypi-release.yaml +++ b/.github/workflows/pypi-release.yaml @@ -42,6 +42,10 @@ jobs: needs: build-artifacts runs-on: ubuntu-latest steps: + - uses: actions/setup-python@v2 + name: Install Python + with: + python-version: 3.8 - uses: actions/download-artifact@v2 with: name: releases @@ -50,3 +54,7 @@ jobs: run: | ls -ltrh ls -ltrh dist + + - name: Install built artifacts + run: | + python -m pip install dist/*.tar.gz From 15dc8fe1c7164e62f744fe3bcab41678c0519214 Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Sat, 1 May 2021 23:02:31 -0600 Subject: [PATCH 03/21] Add job for publishing to PyPI --- .github/workflows/pypi-release.yaml | 30 +++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pypi-release.yaml b/.github/workflows/pypi-release.yaml index 47f7cba527b..973ae31eb65 100644 --- a/.github/workflows/pypi-release.yaml +++ b/.github/workflows/pypi-release.yaml @@ -12,8 +12,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - with: - fetch-depth: 0 - uses: actions/setup-python@v2 name: Install Python with: @@ -26,12 +24,22 @@ jobs: - name: Build tarball and wheels run: | + git clean -xdf + git restore -SW . python setup.py sdist bdist_wheel python -m pip wheel . -w dist --no-deps - name: Test the artifacts run: | python -m twine check dist/* + git describe + pwd + if [ -f dist/xarray-999.tar.gz ]; then + echo "❌ INVALID VERSION NUMBER" + exit 1 + else + echo "✅ Looks good" + fi - uses: actions/upload-artifact@v2 with: @@ -58,3 +66,21 @@ jobs: - name: Install built artifacts run: | python -m pip install dist/*.tar.gz + + upload-to-pypi: + needs: build-artifacts + runs-on: ubuntu-latest + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') + steps: + - uses: actions/download-artifact@v2 + with: + name: releases + path: dist + + - name: Publish package to PyPI + uses: pypa/gh-action-pypi-publish@v1.4.2 + with: + user: ${{ secrets.PYPI_USERNAME }} + password: ${{ secrets.PYPI_PASSWORD }} + skip_existing: true + verbose: true From 652c1e3ee5aba0b78168c268d470f2396f22203b Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Sat, 1 May 2021 23:07:57 -0600 Subject: [PATCH 04/21] Remove git describe and put fetch-depth back --- .github/workflows/pypi-release.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pypi-release.yaml b/.github/workflows/pypi-release.yaml index 973ae31eb65..323495ff58e 100644 --- a/.github/workflows/pypi-release.yaml +++ b/.github/workflows/pypi-release.yaml @@ -12,6 +12,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + with: + fetch-depth: 0 - uses: actions/setup-python@v2 name: Install Python with: @@ -32,7 +34,6 @@ jobs: - name: Test the artifacts run: | python -m twine check dist/* - git describe pwd if [ -f dist/xarray-999.tar.gz ]; then echo "❌ INVALID VERSION NUMBER" From 9217924e01e79f0958382afd2331b447124bbb09 Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Sat, 1 May 2021 23:09:13 -0600 Subject: [PATCH 05/21] remove fetch-depth --- .github/workflows/pypi-release.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/pypi-release.yaml b/.github/workflows/pypi-release.yaml index 323495ff58e..35b9bba7144 100644 --- a/.github/workflows/pypi-release.yaml +++ b/.github/workflows/pypi-release.yaml @@ -12,8 +12,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - with: - fetch-depth: 0 - uses: actions/setup-python@v2 name: Install Python with: @@ -35,7 +33,7 @@ jobs: run: | python -m twine check dist/* pwd - if [ -f dist/xarray-999.tar.gz ]; then + if [ -f dist/xarray-0.0.0.tar.gz ]; then echo "❌ INVALID VERSION NUMBER" exit 1 else From 1abd62991c4f55e477814ab59ec192e8cb0b5acf Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Sat, 1 May 2021 23:12:53 -0600 Subject: [PATCH 06/21] Remove push and pull_request event triggers --- .github/workflows/pypi-release.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/pypi-release.yaml b/.github/workflows/pypi-release.yaml index 35b9bba7144..3c4832672d0 100644 --- a/.github/workflows/pypi-release.yaml +++ b/.github/workflows/pypi-release.yaml @@ -3,8 +3,7 @@ on: release: types: - published - push: - pull_request: + jobs: From a9c5da0b6a29f9b8da9fe09f020cdea593444fea Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Mon, 3 May 2021 11:05:10 -0600 Subject: [PATCH 07/21] [skip-ci] Use python -m build --- .github/workflows/pypi-release.yaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pypi-release.yaml b/.github/workflows/pypi-release.yaml index 3c4832672d0..49e913f6fbc 100644 --- a/.github/workflows/pypi-release.yaml +++ b/.github/workflows/pypi-release.yaml @@ -3,8 +3,7 @@ on: release: types: - published - - + push: jobs: build-artifacts: @@ -25,8 +24,7 @@ jobs: run: | git clean -xdf git restore -SW . - python setup.py sdist bdist_wheel - python -m pip wheel . -w dist --no-deps + python -m build --sdist --wheel . - name: Test the artifacts run: | From 1b9544c72a71752f3f204ebe60fad01ec4fcacb5 Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Mon, 3 May 2021 11:05:59 -0600 Subject: [PATCH 08/21] [skip-ci] Set user to __token__ --- .github/workflows/pypi-release.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pypi-release.yaml b/.github/workflows/pypi-release.yaml index 49e913f6fbc..1407ce8d263 100644 --- a/.github/workflows/pypi-release.yaml +++ b/.github/workflows/pypi-release.yaml @@ -76,7 +76,7 @@ jobs: - name: Publish package to PyPI uses: pypa/gh-action-pypi-publish@v1.4.2 with: - user: ${{ secrets.PYPI_USERNAME }} - password: ${{ secrets.PYPI_PASSWORD }} + user: __token__ + password: ${{ secrets.PYPI_TOKEN }} skip_existing: true verbose: true From 5d201da776db81bac25f0ee4383ba027c14d493e Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Mon, 3 May 2021 11:07:54 -0600 Subject: [PATCH 09/21] [skip-ci] Fetch all history --- .github/workflows/pypi-release.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pypi-release.yaml b/.github/workflows/pypi-release.yaml index 1407ce8d263..353d1e9cfa0 100644 --- a/.github/workflows/pypi-release.yaml +++ b/.github/workflows/pypi-release.yaml @@ -10,6 +10,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + with: + fetch-depth: 0 - uses: actions/setup-python@v2 name: Install Python with: From 73f04673a733dbb9afcb94271a1d3aaf871b0d73 Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Mon, 3 May 2021 11:23:42 -0600 Subject: [PATCH 10/21] [skip-ci] Remove debugging push event trigger --- .github/workflows/pypi-release.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/pypi-release.yaml b/.github/workflows/pypi-release.yaml index 353d1e9cfa0..b90e92c3755 100644 --- a/.github/workflows/pypi-release.yaml +++ b/.github/workflows/pypi-release.yaml @@ -3,7 +3,6 @@ on: release: types: - published - push: jobs: build-artifacts: From 01ff602bd1e9d9df6fc523915eeb1546925f747b Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Mon, 3 May 2021 14:25:21 -0600 Subject: [PATCH 11/21] [skip-ci] Use single job --- .github/workflows/pypi-release.yaml | 35 +++-------------------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/.github/workflows/pypi-release.yaml b/.github/workflows/pypi-release.yaml index b90e92c3755..79ccd0a15da 100644 --- a/.github/workflows/pypi-release.yaml +++ b/.github/workflows/pypi-release.yaml @@ -5,7 +5,7 @@ on: - published jobs: - build-artifacts: + build-and-publish-artifacts: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -37,44 +37,15 @@ jobs: else echo "✅ Looks good" fi + python -m pip install dist/*.tar.gz - - 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.8 - - uses: actions/download-artifact@v2 - with: - name: releases - path: dist - name: List contents of built dist run: | ls -ltrh ls -ltrh dist - - name: Install built artifacts - run: | - python -m pip install dist/*.tar.gz - - upload-to-pypi: - needs: build-artifacts - runs-on: ubuntu-latest - if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') - steps: - - uses: actions/download-artifact@v2 - with: - name: releases - path: dist - - name: Publish package to PyPI + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') uses: pypa/gh-action-pypi-publish@v1.4.2 with: user: __token__ From 43d8ed78f7de24a79c6af3dedef0717805748a5d Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Thu, 6 May 2021 06:16:11 -0600 Subject: [PATCH 12/21] Add step for uploading to testPyPI --- .github/workflows/pypi-release.yaml | 45 +++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pypi-release.yaml b/.github/workflows/pypi-release.yaml index 79ccd0a15da..8a2c0b1680c 100644 --- a/.github/workflows/pypi-release.yaml +++ b/.github/workflows/pypi-release.yaml @@ -3,10 +3,14 @@ on: release: types: - published + push: + # branches: + # - master jobs: - build-and-publish-artifacts: + build-artifacts: runs-on: ubuntu-latest + if: github.repository == 'pydata/xarray' steps: - uses: actions/checkout@v2 with: @@ -37,13 +41,50 @@ jobs: else echo "✅ Looks good" fi - python -m pip install dist/*.tar.gz + - 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.8 + - uses: actions/download-artifact@v2 + with: + name: releases + path: dist - name: List contents of built dist run: | ls -ltrh ls -ltrh dist + - name: Install built artifacts + run: | + python -m pip install dist/*.tar.gz + python -m xarray.util.print_versions + + upload-to-pypi: + needs: test-built-dist + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v2 + with: + name: releases + path: dist + + - name: Publish package to TestPyPI + uses: pypa/gh-action-pypi-publish@v1.4.2 + with: + user: __token__ + password: ${{ secrets.TESTPYPI_TOKEN }} + repository_url: https://test.pypi.org/legacy/ + verbose: true + - name: Publish package to PyPI if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') uses: pypa/gh-action-pypi-publish@v1.4.2 From 844016bf44cdfe6cd2bf80de0fad89d1b45fe618 Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Thu, 6 May 2021 06:17:09 -0600 Subject: [PATCH 13/21] [skip-ci] Disable if for debugging --- .github/workflows/pypi-release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pypi-release.yaml b/.github/workflows/pypi-release.yaml index 8a2c0b1680c..e6d1240ecbb 100644 --- a/.github/workflows/pypi-release.yaml +++ b/.github/workflows/pypi-release.yaml @@ -10,7 +10,7 @@ on: jobs: build-artifacts: runs-on: ubuntu-latest - if: github.repository == 'pydata/xarray' + # if: github.repository == 'pydata/xarray' steps: - uses: actions/checkout@v2 with: From f5031987abde554bc9a49e2b6ba0050fc1d31cda Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Thu, 6 May 2021 06:20:58 -0600 Subject: [PATCH 14/21] Remove debugging statements --- .github/workflows/pypi-release.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pypi-release.yaml b/.github/workflows/pypi-release.yaml index e6d1240ecbb..8ceb58ced90 100644 --- a/.github/workflows/pypi-release.yaml +++ b/.github/workflows/pypi-release.yaml @@ -4,13 +4,13 @@ on: types: - published push: - # branches: - # - master + branches: + - master jobs: build-artifacts: runs-on: ubuntu-latest - # if: github.repository == 'pydata/xarray' + if: github.repository == 'pydata/xarray' steps: - uses: actions/checkout@v2 with: @@ -31,7 +31,7 @@ jobs: git restore -SW . python -m build --sdist --wheel . - - name: Test the artifacts + - name: Check built artifacts run: | python -m twine check dist/* pwd From c44638f1cb1a0ec5b43b76048803460b2f128374 Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Thu, 6 May 2021 06:21:15 -0600 Subject: [PATCH 15/21] [skip-ci] From e883bf161b593ae386021294e9ed0a64ccd4ce41 Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Thu, 6 May 2021 08:10:34 -0600 Subject: [PATCH 16/21] Fix github.event_name --- .github/workflows/pypi-release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pypi-release.yaml b/.github/workflows/pypi-release.yaml index 8ceb58ced90..fb72950d170 100644 --- a/.github/workflows/pypi-release.yaml +++ b/.github/workflows/pypi-release.yaml @@ -86,7 +86,7 @@ jobs: verbose: true - name: Publish package to PyPI - if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') + if: github.event_name == 'release' && startsWith(github.event.ref, 'refs/tags/v') uses: pypa/gh-action-pypi-publish@v1.4.2 with: user: __token__ From f6e3153ec0f2871c9544dfc259eab67d901ece97 Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Thu, 6 May 2021 08:10:44 -0600 Subject: [PATCH 17/21] [skip-ci] From a4607b1b5b1525fef35b60933a2f9c3d4d642b9d Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Thu, 6 May 2021 08:23:06 -0600 Subject: [PATCH 18/21] Install uploaded package --- .github/workflows/pypi-release.yaml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pypi-release.yaml b/.github/workflows/pypi-release.yaml index fb72950d170..1b0f5ce9731 100644 --- a/.github/workflows/pypi-release.yaml +++ b/.github/workflows/pypi-release.yaml @@ -72,12 +72,17 @@ jobs: needs: test-built-dist runs-on: ubuntu-latest steps: + - uses: actions/setup-python@v2 + name: Install Python + with: + python-version: 3.8 - uses: actions/download-artifact@v2 with: name: releases path: dist - name: Publish package to TestPyPI + if: github.event_name == 'push' || startsWith(github.event.ref, 'refs/tags/v') uses: pypa/gh-action-pypi-publish@v1.4.2 with: user: __token__ @@ -85,11 +90,17 @@ jobs: repository_url: https://test.pypi.org/legacy/ verbose: true + - name: Check uploaded package + if: github.event_name == 'push' || startsWith(github.event.ref, 'refs/tags/v') + run: | + python -m pip install --upgrade pip + python -m pip install --index-url https://test.pypi.org/simple --upgrade xarray + python -m xarray.util.print_versions + - name: Publish package to PyPI if: github.event_name == 'release' && startsWith(github.event.ref, 'refs/tags/v') uses: pypa/gh-action-pypi-publish@v1.4.2 with: user: __token__ password: ${{ secrets.PYPI_TOKEN }} - skip_existing: true verbose: true From b6224626f78af8ea4becc7743394767123c6b980 Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Thu, 6 May 2021 08:23:13 -0600 Subject: [PATCH 19/21] [skip-ci] From 7398dd853e893631d60fcfbf355ecdf97c65bdfe Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Thu, 6 May 2021 08:26:19 -0600 Subject: [PATCH 20/21] [skip-ci] Move TestPyPI steps in `test-built-dist` job --- .github/workflows/pypi-release.yaml | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/.github/workflows/pypi-release.yaml b/.github/workflows/pypi-release.yaml index 1b0f5ce9731..1212a9c4f3d 100644 --- a/.github/workflows/pypi-release.yaml +++ b/.github/workflows/pypi-release.yaml @@ -62,25 +62,6 @@ jobs: run: | ls -ltrh ls -ltrh dist - - - name: Install built artifacts - run: | - python -m pip install dist/*.tar.gz - python -m xarray.util.print_versions - - upload-to-pypi: - needs: test-built-dist - runs-on: ubuntu-latest - steps: - - uses: actions/setup-python@v2 - name: Install Python - with: - python-version: 3.8 - - uses: actions/download-artifact@v2 - with: - name: releases - path: dist - - name: Publish package to TestPyPI if: github.event_name == 'push' || startsWith(github.event.ref, 'refs/tags/v') uses: pypa/gh-action-pypi-publish@v1.4.2 @@ -93,10 +74,19 @@ jobs: - name: Check uploaded package if: github.event_name == 'push' || startsWith(github.event.ref, 'refs/tags/v') run: | + sleep 3 python -m pip install --upgrade pip python -m pip install --index-url https://test.pypi.org/simple --upgrade xarray python -m xarray.util.print_versions + upload-to-pypi: + needs: test-built-dist + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v2 + with: + name: releases + path: dist - name: Publish package to PyPI if: github.event_name == 'release' && startsWith(github.event.ref, 'refs/tags/v') uses: pypa/gh-action-pypi-publish@v1.4.2 From 7cb71e7458ac7982c7e81a3b1dabebc060bcb2d2 Mon Sep 17 00:00:00 2001 From: Anderson Banihirwe Date: Thu, 6 May 2021 08:30:23 -0600 Subject: [PATCH 21/21] [skip-ci] Make `if` condition global --- .github/workflows/pypi-release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pypi-release.yaml b/.github/workflows/pypi-release.yaml index 1212a9c4f3d..297968f693d 100644 --- a/.github/workflows/pypi-release.yaml +++ b/.github/workflows/pypi-release.yaml @@ -81,6 +81,7 @@ jobs: upload-to-pypi: needs: test-built-dist + if: github.event_name == 'release' && startsWith(github.event.ref, 'refs/tags/v') runs-on: ubuntu-latest steps: - uses: actions/download-artifact@v2 @@ -88,7 +89,6 @@ jobs: name: releases path: dist - name: Publish package to PyPI - if: github.event_name == 'release' && startsWith(github.event.ref, 'refs/tags/v') uses: pypa/gh-action-pypi-publish@v1.4.2 with: user: __token__