From 9c728bad5b4c38a3da9cc28ca6b00262727785c4 Mon Sep 17 00:00:00 2001 From: John Agapiou Date: Wed, 12 Jul 2023 11:10:18 +0100 Subject: [PATCH] [dmlab2d/BUILD, workflows] Use version constant, trigger pypi on "release" --- .github/workflows/pypi_upload.yml | 37 +++++++++++++++++++++++-------- dmlab2d/BUILD | 6 +++-- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/.github/workflows/pypi_upload.yml b/.github/workflows/pypi_upload.yml index 5c0d166..cbf2d41 100644 --- a/.github/workflows/pypi_upload.yml +++ b/.github/workflows/pypi_upload.yml @@ -5,9 +5,17 @@ name: pypi_upload on: workflow_dispatch: inputs: + release: + description: 'Release to upload' + type: string + default: '' + upload_to_test_pypi: + description: 'Upload to Test PyPi' + type: boolean + default: true upload_to_pypi: - description: 'Whether to upload to PyPi' - required: false + description: 'Upload to PyPi' + type: boolean default: false release: types: [published] @@ -16,18 +24,29 @@ jobs: upload-wheels-to-pypi: name: Upload wheels to PyPI runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/dmlab2d + permissions: + id-token: write timeout-minutes: 30 env: GH_TOKEN: ${{ github.token }} steps: - - name: Download all wheels - uses: actions/download-artifact@ + - name: Download release assets + run: gh release download ${{ inputs.release || github.ref }} -D dist -R ${{ github.repository }} + + - name: Publish to TestPyPI + if: github.event_name == 'release' || inputs.upload_to_test_pypi + uses: pypa/gh-action-pypi-publish@release/v1 with: - name: wheels-${{ github.ref_name }} + repository-url: https://test.pypi.org/legacy/ + verbose: true - - name: List contents - run: | - gh release download ${{ github.ref }} -D dist -R ${{ github.repository }} - ls -la dist + - name: Publish to PyPI + if: github.event_name == 'release' || inputs.upload_to_pypi + uses: pypa/gh-action-pypi-publish@release/v1 + with: + verbose: true diff --git a/dmlab2d/BUILD b/dmlab2d/BUILD index 407dd03..c07112c 100644 --- a/dmlab2d/BUILD +++ b/dmlab2d/BUILD @@ -113,6 +113,8 @@ py_package( ], ) +VERSION = '1.0.0' # https://semver.org + py_wheel( name = "dmlab2d_wheel", abi = PY_TAGS.abi, @@ -130,7 +132,7 @@ py_wheel( "dm_env", "numpy", ], - version = "1.0", + version = VERSION, deps = [":dmlab2d_pkg"], ) @@ -153,7 +155,7 @@ py_wheel( "dm_env", "numpy", ], - version = "1.0", + version = VERSION, deps = [":dmlab2d_pkg"], )