Skip to content

Commit 521e328

Browse files
xcao65GitHub Enterprise
authored and
GitHub Enterprise
committed
Add github action to publish python API to PYPI (Unity-Technologies#28)
1 parent 9ab59f7 commit 521e328

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

.github/workflows/publish_pypi.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
steps:
2222
- uses: actions/checkout@main
2323
- name: Set up Python 3.7
24-
uses: actions/setup-python@v1
24+
uses: actions/setup-python@v2
2525
with:
2626
python-version: 3.7
2727
- name: Install dependencies
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Adapted from https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
2+
name: Publish Python APIs to PyPI (or TestPyPI)
3+
4+
on:
5+
push:
6+
tags:
7+
- "api_release_[0-9]+_test[0-9]+"
8+
- "api_release_[0-9]+"
9+
workflow_dispatch:
10+
11+
jobs:
12+
build-and-publish:
13+
# Only run on GitHub Enterprise
14+
if: ${{ github.server_url == 'https://github.cds.internal.unity3d.com' }}
15+
name: publish to PyPI (or TestPyPI)
16+
runs-on: [self-hosted, Linux, X64]
17+
strategy:
18+
matrix:
19+
package-path: [ml-agents-envs]
20+
21+
steps:
22+
- uses: actions/checkout@main
23+
- name: Set up Python 3.7
24+
uses: actions/setup-python@v2
25+
with:
26+
python-version: 3.7
27+
- name: Install dependencies
28+
run: pip install setuptools wheel twine --user
29+
- name: verify git tag vs. version
30+
run: |
31+
cd ${{ matrix.package-path }}
32+
python setup.py verify
33+
- name: Build package
34+
run: |
35+
cd ${{ matrix.package-path }}
36+
python setup.py sdist
37+
python setup.py bdist_wheel
38+
- name: Publish distribution 📦 to Test PyPI
39+
if: startsWith(github.ref, 'refs/tags') && contains(github.ref, 'test')
40+
uses: actions/gh-action-pypi-publish@717ba43cfbb0387f6ce311b169a825772f54d295
41+
with:
42+
password: ${{ secrets.TEST_PYPI_PASSWORD }}
43+
repository_url: https://test.pypi.org/legacy/
44+
packages_dir: ${{ matrix.package-path }}/dist/
45+
- name: Publish distribution 📦 to Production PyPI
46+
if: startsWith(github.ref, 'refs/tags') && !contains(github.ref, 'test')
47+
uses: actions/gh-action-pypi-publish@717ba43cfbb0387f6ce311b169a825772f54d295
48+
with:
49+
password: ${{ secrets.PYPI_PASSWORD }}
50+
packages_dir: ${{ matrix.package-path }}/dist/

0 commit comments

Comments
 (0)