Skip to content

Commit

Permalink
[dmlab2d/BUILD, workflows] Use version constant, trigger pypi on "rel…
Browse files Browse the repository at this point in the history
…ease"
  • Loading branch information
jagapiou authored and tkoeppe committed Jul 20, 2023
1 parent d4fe24b commit 9c728ba
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 11 deletions.
37 changes: 28 additions & 9 deletions .github/workflows/pypi_upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
6 changes: 4 additions & 2 deletions dmlab2d/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ py_package(
],
)

VERSION = '1.0.0' # https://semver.org

py_wheel(
name = "dmlab2d_wheel",
abi = PY_TAGS.abi,
Expand All @@ -130,7 +132,7 @@ py_wheel(
"dm_env",
"numpy",
],
version = "1.0",
version = VERSION,
deps = [":dmlab2d_pkg"],
)

Expand All @@ -153,7 +155,7 @@ py_wheel(
"dm_env",
"numpy",
],
version = "1.0",
version = VERSION,
deps = [":dmlab2d_pkg"],
)

Expand Down

0 comments on commit 9c728ba

Please sign in to comment.