|
| 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