Skip to content

Commit 3818a21

Browse files
author
Chris Elion
authored
Convert pypi publish to github actions (#4539)
1 parent b7d2b80 commit 3818a21

File tree

5 files changed

+59
-12
lines changed

5 files changed

+59
-12
lines changed

.circleci/config.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ workflows:
7070
filters:
7171
tags:
7272
# Matches e.g. "release_123"
73-
only: /^release_[0-9]+$/
73+
only: /^DEPRECATED_release_[0-9]+$/
7474
branches:
7575
ignore: /.*/
7676
- deploy:
@@ -79,7 +79,7 @@ workflows:
7979
filters:
8080
tags:
8181
# Matches e.g. "release_123"
82-
only: /^release_[0-9]+$/
82+
only: /^DEPRECATED_release_[0-9]+$/
8383
branches:
8484
ignore: /.*/
8585
- deploy:
@@ -88,7 +88,7 @@ workflows:
8888
filters:
8989
tags:
9090
# Matches e.g. "release_123"
91-
only: /^release_[0-9]+$/
91+
only: /^DEPRECATED_release_[0-9]+$/
9292
branches:
9393
ignore: /.*/
9494
# These deploy jobs upload to the pypi test repo. They have different tag triggers than the real ones.
@@ -100,7 +100,7 @@ workflows:
100100
filters:
101101
tags:
102102
# Matches e.g. "release_123_test456
103-
only: /^release_[0-9]+_test[0-9]+$/
103+
only: /^DEPRECATED_release_[0-9]+_test[0-9]+$/
104104
branches:
105105
ignore: /.*/
106106
- deploy:
@@ -111,7 +111,7 @@ workflows:
111111
filters:
112112
tags:
113113
# Matches e.g. "release_123_test456
114-
only: /^release_[0-9]+_test[0-9]+$/
114+
only: /^DEPRECATED_release_[0-9]+_test[0-9]+$/
115115
branches:
116116
ignore: /.*/
117117
- deploy:
@@ -122,6 +122,6 @@ workflows:
122122
filters:
123123
tags:
124124
# Matches e.g. "release_123_test456
125-
only: /^release_[0-9]+_test[0-9]+$/
125+
only: /^DEPRECATED_release_[0-9]+_test[0-9]+$/
126126
branches:
127127
ignore: /.*/
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Adapted from https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
2+
name: publish to PyPI (or TestPyPI)
3+
4+
on:
5+
push:
6+
tags:
7+
- "release_[0-9]+_test[0-9]+"
8+
- "release_[0-9]+"
9+
10+
jobs:
11+
build-and-publish:
12+
name: publish to PyPI (or TestPyPI)
13+
runs-on: ubuntu-18.04
14+
strategy:
15+
matrix:
16+
package-path: [ml-agents, ml-agents-envs, gym-unity]
17+
18+
steps:
19+
- uses: actions/checkout@master
20+
- name: Set up Python 3.7
21+
uses: actions/setup-python@v1
22+
with:
23+
python-version: 3.7
24+
- name: Install dependencies
25+
run: pip install setuptools wheel twine --user
26+
- name: verify git tag vs. version
27+
run: |
28+
cd ${{ matrix.package-path }}
29+
python setup.py verify
30+
- name: Build package
31+
run: |
32+
cd ${{ matrix.package-path }}
33+
python setup.py sdist
34+
python setup.py bdist_wheel
35+
- name: Publish distribution 📦 to Test PyPI
36+
if: startsWith(github.ref, 'refs/tags') && contains(github.ref, 'test')
37+
uses: pypa/gh-action-pypi-publish@master
38+
with:
39+
password: ${{ secrets.test_pypi_password }}
40+
repository_url: https://test.pypi.org/legacy/
41+
packages_dir: ${{ matrix.package-path }}/dist/
42+
- name: Publish distribution 📦 to Production PyPI
43+
if: startsWith(github.ref, 'refs/tags') && !contains(github.ref, 'test')
44+
uses: pypa/gh-action-pypi-publish@master
45+
with:
46+
password: ${{ secrets.pypi_password }}
47+
packages_dir: ${{ matrix.package-path }}/dist/

gym-unity/setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
class VerifyVersionCommand(install):
1414
"""
1515
Custom command to verify that the git tag is the expected one for the release.
16-
Based on https://circleci.com/blog/continuously-deploying-python-packages-to-pypi-with-circleci/
16+
Originally based on https://circleci.com/blog/continuously-deploying-python-packages-to-pypi-with-circleci/
1717
This differs slightly because our tags and versions are different.
1818
"""
1919

2020
description = "verify that the git tag matches our version"
2121

2222
def run(self):
23-
tag = os.getenv("CIRCLE_TAG")
23+
tag = os.getenv("GITHUB_REF", "NO GITHUB TAG!").replace("refs/tags/", "")
2424

2525
if tag != EXPECTED_TAG:
2626
info = "Git tag: {} does not match the expected tag of this app: {}".format(

ml-agents-envs/setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
class VerifyVersionCommand(install):
1414
"""
1515
Custom command to verify that the git tag is the expected one for the release.
16-
Based on https://circleci.com/blog/continuously-deploying-python-packages-to-pypi-with-circleci/
16+
Originally based on https://circleci.com/blog/continuously-deploying-python-packages-to-pypi-with-circleci/
1717
This differs slightly because our tags and versions are different.
1818
"""
1919

2020
description = "verify that the git tag matches our version"
2121

2222
def run(self):
23-
tag = os.getenv("CIRCLE_TAG")
23+
tag = os.getenv("GITHUB_REF", "NO GITHUB TAG!").replace("refs/tags/", "")
2424

2525
if tag != EXPECTED_TAG:
2626
info = "Git tag: {} does not match the expected tag of this app: {}".format(

ml-agents/setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
class VerifyVersionCommand(install):
1515
"""
1616
Custom command to verify that the git tag is the expected one for the release.
17-
Based on https://circleci.com/blog/continuously-deploying-python-packages-to-pypi-with-circleci/
17+
Originally based on https://circleci.com/blog/continuously-deploying-python-packages-to-pypi-with-circleci/
1818
This differs slightly because our tags and versions are different.
1919
"""
2020

2121
description = "verify that the git tag matches our version"
2222

2323
def run(self):
24-
tag = os.getenv("CIRCLE_TAG")
24+
tag = os.getenv("GITHUB_REF", "NO GITHUB TAG!").replace("refs/tags/", "")
2525

2626
if tag != EXPECTED_TAG:
2727
info = "Git tag: {} does not match the expected tag of this app: {}".format(

0 commit comments

Comments
 (0)