From 14abb2e1728040df3ee76e25ae0abde8a0f4071a Mon Sep 17 00:00:00 2001 From: Geoff Boeing Date: Sat, 7 Dec 2024 22:08:40 -0800 Subject: [PATCH 1/4] add pypi publish workflow --- .github/workflows/publish-pypi.yml | 41 ++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/publish-pypi.yml diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml new file mode 100644 index 00000000..854eef52 --- /dev/null +++ b/.github/workflows/publish-pypi.yml @@ -0,0 +1,41 @@ +name: Publish Python distribution to PyPI + +on: + push: + tags: + - 'v*' + workflow_dispatch: + +jobs: + build: + name: Build and publish on PyPI + environment: + name: testpypi + permissions: + id-token: write + runs-on: ubuntu-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.x" + + - name: Build and check package + run: | + python -m pip install hatch twine --user + python -m hatch build --clean + python -m twine check --strict ./dist/* + + - name: Publish distribution + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.TEST_PYPI_API_TOKEN }} + repository-url: https://test.pypi.org/legacy/ + print-hash: true + verbose: true + verify-metadata: true From 92d0724b3828ab9cbdf665da6462cd9be1a234c5 Mon Sep 17 00:00:00 2001 From: Geoff Boeing Date: Sat, 7 Dec 2024 22:17:14 -0800 Subject: [PATCH 2/4] update workflow --- .github/workflows/publish-pypi.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index 854eef52..d88f0caf 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -1,4 +1,4 @@ -name: Publish Python distribution to PyPI +name: Publish package to PyPI on: push: @@ -9,11 +9,9 @@ on: jobs: build: name: Build and publish on PyPI - environment: - name: testpypi + runs-on: ubuntu-latest permissions: id-token: write - runs-on: ubuntu-latest steps: - name: Checkout repo @@ -26,11 +24,12 @@ jobs: - name: Build and check package run: | - python -m pip install hatch twine --user + python -m pip install --user hatch twine python -m hatch build --clean python -m twine check --strict ./dist/* - - name: Publish distribution + - name: Publish package to PyPI + if: github.repository == 'gboeing/osmnx' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@release/v1 with: user: __token__ From ea5f2e984a386ec7ff194a8123c2a36639f79589 Mon Sep 17 00:00:00 2001 From: Geoff Boeing Date: Sat, 7 Dec 2024 22:29:43 -0800 Subject: [PATCH 3/4] update workflow --- .github/workflows/publish-pypi.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index d88f0caf..27b519a9 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -7,12 +7,16 @@ on: workflow_dispatch: jobs: - build: + build_publish_pypi: name: Build and publish on PyPI runs-on: ubuntu-latest permissions: id-token: write + defaults: + run: + shell: bash -elo pipefail {0} + steps: - name: Checkout repo uses: actions/checkout@v4 @@ -24,7 +28,8 @@ jobs: - name: Build and check package run: | - python -m pip install --user hatch twine + python -m pip install --user hatch twine validate-pyproject[all] + python -m validate_pyproject ./pyproject.toml python -m hatch build --clean python -m twine check --strict ./dist/* From 2f8b13a0eef40e269c2ce0e7dccf516b9328de43 Mon Sep 17 00:00:00 2001 From: Geoff Boeing Date: Sun, 8 Dec 2024 00:00:27 -0800 Subject: [PATCH 4/4] build but don't publish on cron schedule --- .github/workflows/publish-pypi.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index 27b519a9..2ed12854 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -4,14 +4,15 @@ on: push: tags: - 'v*' + schedule: + - cron: "0 6 * * 1" # every monday at 06:00 UTC workflow_dispatch: jobs: build_publish_pypi: + if: ${{ github.repository == 'gboeing/osmnx' }} name: Build and publish on PyPI runs-on: ubuntu-latest - permissions: - id-token: write defaults: run: @@ -34,11 +35,11 @@ jobs: python -m twine check --strict ./dist/* - name: Publish package to PyPI - if: github.repository == 'gboeing/osmnx' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + if: ${{ github.event_name != 'schedule' }} uses: pypa/gh-action-pypi-publish@release/v1 with: user: __token__ - password: ${{ secrets.TEST_PYPI_API_TOKEN }} + password: ${{ secrets.TEST_PYPI_TOKEN }} repository-url: https://test.pypi.org/legacy/ print-hash: true verbose: true