-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GitHub action for publishing to PyPI
PiperOrigin-RevId: 544313156 Change-Id: Ibffef7decd5e9f0a040fc7679ee3c614ee615640
- Loading branch information
1 parent
87000d7
commit ba8deb5
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# A workflow to publish releases to PyPi and TestPyPi. | ||
|
||
name: pypi-publish | ||
|
||
on: | ||
release: | ||
types: [published] | ||
workflow_dispatch: | ||
inputs: | ||
upload_to_test_pypi: | ||
description: 'Upload to Test PyPi' | ||
type: boolean | ||
default: true | ||
upload_to_pypi: | ||
description: 'Upload to PyPi' | ||
type: boolean | ||
default: false | ||
|
||
permissions: read-all | ||
|
||
jobs: | ||
pypi-publish: | ||
name: Upload to PyPI | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: pypi | ||
url: https://pypi.org/p/dm-meltingpot | ||
permissions: | ||
id-token: write | ||
timeout-minutes: 10 | ||
|
||
steps: | ||
- name: Checkout Melting Pot | ||
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 | ||
with: | ||
python-version: '3.9' | ||
|
||
- name: Install Python dependencies | ||
run: pip install --upgrade pip build | ||
|
||
- name: Build Melting Pot source distribution | ||
run: python -m build --sdist --outdir dist/ | ||
|
||
- name: Publish to TestPyPI | ||
if: github.event_name == 'release' || inputs.upload_to_test_pypi | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
repository-url: https://test.pypi.org/legacy/ | ||
verbose: true | ||
|
||
- name: Publish to PyPI | ||
if: github.event_name == 'release' || inputs.upload_to_pypi | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
verbose: true |