From d4e0b3b3ed7f8e3f438656127976ccb36dade99b Mon Sep 17 00:00:00 2001 From: Nate Schmitz Date: Wed, 29 May 2024 12:22:43 -0700 Subject: [PATCH] release: Push to the test PyPi channel on every commit. PiperOrigin-RevId: 638372736 --- .github/workflows/publish-to-pypi.yml | 63 +++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/publish-to-pypi.yml diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml new file mode 100644 index 000000000..e7d1e58c8 --- /dev/null +++ b/.github/workflows/publish-to-pypi.yml @@ -0,0 +1,63 @@ +name: Publish to PyPi + +on: push + +jobs: + build-artifacts: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: 3.11 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install --upgrade build twine + - name: Build package + run: python -m build ./python + - name: Check built artifacts + run: | + python -m twine check dist/* + - uses: actions/upload-artifact@v2 + with: + name: releases + path: dist + + test-pypi-upload: + needs: build-artifacts + runs-on: ubuntu-latest + steps: + - uses: actions/setup-python@v3 + name: Install Python + with: + python-version: 3.11 + - uses: actions/download-artifact@v2 + with: + name: releases + path: dist + - name: Publish package to TestPyPI + if: github.event_name == 'push' + uses: pypa/gh-action-pypi-publish@v1 + with: + user: __token__ + password: ${{ secrets.TEST_PYPI_API_TOKEN }} + repository_url: https://test.pypi.org/legacy/ + verbose: true + + check-test-pypi-package: + needs: test-pypi-upload + runs-on: ubuntu-latest + steps: + - uses: actions/setup-python@v3 + name: Install Python + with: + python-version: 3.11 + - name: Check uploaded package + if: github.event_name == 'push' + run: | + sleep 3 + python -m pip install --upgrade pip + python -m pip install --extra-index-url https://test.pypi.org/simple --upgrade earthengine-api + python -c "import ee; print(ee.__version__)"