Skip to content

Commit

Permalink
Add github action to publish python API to PYPI (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
xcao65 authored and GitHub Enterprise committed Mar 7, 2022
1 parent 9ab59f7 commit 521e328
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/publish_pypi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
steps:
- uses: actions/checkout@main
- name: Set up Python 3.7
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Install dependencies
Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/publish_pypi_python_api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Adapted from https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
name: Publish Python APIs to PyPI (or TestPyPI)

on:
push:
tags:
- "api_release_[0-9]+_test[0-9]+"
- "api_release_[0-9]+"
workflow_dispatch:

jobs:
build-and-publish:
# Only run on GitHub Enterprise
if: ${{ github.server_url == 'https://github.cds.internal.unity3d.com' }}
name: publish to PyPI (or TestPyPI)
runs-on: [self-hosted, Linux, X64]
strategy:
matrix:
package-path: [ml-agents-envs]

steps:
- uses: actions/checkout@main
- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Install dependencies
run: pip install setuptools wheel twine --user
- name: verify git tag vs. version
run: |
cd ${{ matrix.package-path }}
python setup.py verify
- name: Build package
run: |
cd ${{ matrix.package-path }}
python setup.py sdist
python setup.py bdist_wheel
- name: Publish distribution 📦 to Test PyPI
if: startsWith(github.ref, 'refs/tags') && contains(github.ref, 'test')
uses: actions/gh-action-pypi-publish@717ba43cfbb0387f6ce311b169a825772f54d295
with:
password: ${{ secrets.TEST_PYPI_PASSWORD }}
repository_url: https://test.pypi.org/legacy/
packages_dir: ${{ matrix.package-path }}/dist/
- name: Publish distribution 📦 to Production PyPI
if: startsWith(github.ref, 'refs/tags') && !contains(github.ref, 'test')
uses: actions/gh-action-pypi-publish@717ba43cfbb0387f6ce311b169a825772f54d295
with:
password: ${{ secrets.PYPI_PASSWORD }}
packages_dir: ${{ matrix.package-path }}/dist/

0 comments on commit 521e328

Please sign in to comment.