浏览代码

Convert pypi publish to github actions (#4539)

/MLA-1734-demo-provider
GitHub 4 年前
当前提交
6aed3c75
共有 5 个文件被更改,包括 59 次插入12 次删除
  1. 12
      .circleci/config.yml
  2. 4
      gym-unity/setup.py
  3. 4
      ml-agents-envs/setup.py
  4. 4
      ml-agents/setup.py
  5. 47
      .github/workflows/publish_pypi.yaml

12
.circleci/config.yml


filters:
tags:
# Matches e.g. "release_123"
only: /^release_[0-9]+$/
only: /^DEPRECATED_release_[0-9]+$/
branches:
ignore: /.*/
- deploy:

tags:
# Matches e.g. "release_123"
only: /^release_[0-9]+$/
only: /^DEPRECATED_release_[0-9]+$/
branches:
ignore: /.*/
- deploy:

tags:
# Matches e.g. "release_123"
only: /^release_[0-9]+$/
only: /^DEPRECATED_release_[0-9]+$/
branches:
ignore: /.*/
# These deploy jobs upload to the pypi test repo. They have different tag triggers than the real ones.

filters:
tags:
# Matches e.g. "release_123_test456
only: /^release_[0-9]+_test[0-9]+$/
only: /^DEPRECATED_release_[0-9]+_test[0-9]+$/
branches:
ignore: /.*/
- deploy:

filters:
tags:
# Matches e.g. "release_123_test456
only: /^release_[0-9]+_test[0-9]+$/
only: /^DEPRECATED_release_[0-9]+_test[0-9]+$/
branches:
ignore: /.*/
- deploy:

filters:
tags:
# Matches e.g. "release_123_test456
only: /^release_[0-9]+_test[0-9]+$/
only: /^DEPRECATED_release_[0-9]+_test[0-9]+$/
branches:
ignore: /.*/

4
gym-unity/setup.py


class VerifyVersionCommand(install):
"""
Custom command to verify that the git tag is the expected one for the release.
Based on https://circleci.com/blog/continuously-deploying-python-packages-to-pypi-with-circleci/
Originally based on https://circleci.com/blog/continuously-deploying-python-packages-to-pypi-with-circleci/
This differs slightly because our tags and versions are different.
"""

tag = os.getenv("CIRCLE_TAG")
tag = os.getenv("GITHUB_REF", "NO GITHUB TAG!").replace("refs/tags/", "")
if tag != EXPECTED_TAG:
info = "Git tag: {} does not match the expected tag of this app: {}".format(

4
ml-agents-envs/setup.py


class VerifyVersionCommand(install):
"""
Custom command to verify that the git tag is the expected one for the release.
Based on https://circleci.com/blog/continuously-deploying-python-packages-to-pypi-with-circleci/
Originally based on https://circleci.com/blog/continuously-deploying-python-packages-to-pypi-with-circleci/
This differs slightly because our tags and versions are different.
"""

tag = os.getenv("CIRCLE_TAG")
tag = os.getenv("GITHUB_REF", "NO GITHUB TAG!").replace("refs/tags/", "")
if tag != EXPECTED_TAG:
info = "Git tag: {} does not match the expected tag of this app: {}".format(

4
ml-agents/setup.py


class VerifyVersionCommand(install):
"""
Custom command to verify that the git tag is the expected one for the release.
Based on https://circleci.com/blog/continuously-deploying-python-packages-to-pypi-with-circleci/
Originally based on https://circleci.com/blog/continuously-deploying-python-packages-to-pypi-with-circleci/
This differs slightly because our tags and versions are different.
"""

tag = os.getenv("CIRCLE_TAG")
tag = os.getenv("GITHUB_REF", "NO GITHUB TAG!").replace("refs/tags/", "")
if tag != EXPECTED_TAG:
info = "Git tag: {} does not match the expected tag of this app: {}".format(

47
.github/workflows/publish_pypi.yaml


# Adapted from https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
name: publish to PyPI (or TestPyPI)
on:
push:
tags:
- "release_[0-9]+_test[0-9]+"
- "release_[0-9]+"
jobs:
build-and-publish:
name: publish to PyPI (or TestPyPI)
runs-on: ubuntu-18.04
strategy:
matrix:
package-path: [ml-agents, ml-agents-envs, gym-unity]
steps:
- uses: actions/checkout@master
- name: Set up Python 3.7
uses: actions/setup-python@v1
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: pypa/gh-action-pypi-publish@master
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: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.pypi_password }}
packages_dir: ${{ matrix.package-path }}/dist/
正在加载...
取消
保存