Skip to content
This repository has been archived by the owner on Oct 12, 2021. It is now read-only.

Commit

Permalink
Split Python CI into PR and release pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
ashleyvega committed Jul 26, 2021
1 parent 836f0bc commit 7fe05d1
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 37 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/python-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---

name: Python

"on":
push:
branches:
- develop
tags:
- "v[0-9]+.[0-9]+.[0-9]+" # release
- "v[0-9]+.[0-9]+.[0-9]+-a[0-9]+" # alpha
- "v[0-9]+.[0-9]+.[0-9]+-pre[0-9]+" # pre-release / rc

jobs:

build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8"]
steps:
- name: Check out code
uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Push release to PyPI
env:
TWINE_USERNAME: __token__
twine_test_password: ${{ secrets.TWINE_TEST_PASSWORD }}
twine_prod_password: ${{ secrets.TWINE_PASSWORD }}
run: |
cd grpc/clients/python
github_tag="${GITHUB_REF#refs/tags/v}"
if [[ "$v" =~ ^v[0-9]+.[0-9]+.[0-9]+-a[0-9]+$ ]] ; then
echo "This is an alpha release."
# Inject the version, rather than requiring it in setup.py.
sed --in-place -e 's#^VERSION.*$#VERSION = "'"$github_tag"'"#' setup.py
make_target=dist_test
export TWINE_PASSWORD="$twine_test_password"
else
echo "This is a (pre)release."
setuppy_tag="$(python -c "$(awk '/^VERSION = /' setup.py); print(VERSION)")"
make_target=dist
export TWINE_PASSWORD="$twine_prod_password"
fi
if [[ "$github_tag" != "$setuppy_tag" ]] ; then
echo "Tags do not match."
echo "Github: $github_tag"
echo "setup.py: $setuppy_tag"
exit 1
fi
command -v twine 1>/dev/null || pip install twine
make "$make_target"
37 changes: 0 additions & 37 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@ name: Python
- "grpc/examples/python/**"
- "proto/**"
- "rest/examples/python/**"
push:
branches:
- develop
tags:
- "v[0-9]+.[0-9]+.[0-9]+" # release
- "v[0-9]+.[0-9]+.[0-9]+-a[0-9]+" # alpha
- "v[0-9]+.[0-9]+.[0-9]+-pre[0-9]+" # pre-release / rc

jobs:

Expand Down Expand Up @@ -104,33 +97,3 @@ jobs:
cd rest/examples/python
make
if: ${{ matrix.python-version == '3.9' }}

- name: Push release to PyPI
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.python-version == '3.8' }}
env:
TWINE_USERNAME: __token__
twine_test_password: ${{ secrets.TWINE_TEST_PASSWORD }}
twine_prod_password: ${{ secrets.TWINE_PASSWORD }}
run: |
cd grpc/clients/python
github_tag="${GITHUB_REF#refs/tags/v}"
if [[ "$v" =~ ^v[0-9]+.[0-9]+.[0-9]+-a[0-9]+$ ]] ; then
echo "This is an alpha release."
# Inject the version, rather than requiring it in setup.py.
sed --in-place -e 's#^VERSION.*$#VERSION = "'"$github_tag"'"#' setup.py
make_target=dist_test
export TWINE_PASSWORD="$twine_test_password"
else
echo "This is a (pre)release."
setuppy_tag="$(python -c "$(awk '/^VERSION = /' setup.py); print(VERSION)")"
make_target=dist
export TWINE_PASSWORD="$twine_prod_password"
fi
if [[ "$github_tag" != "$setuppy_tag" ]] ; then
echo "Tags do not match."
echo "Github: $github_tag"
echo "setup.py: $setuppy_tag"
exit 1
fi
command -v twine 1>/dev/null || pip install twine
make "$make_target"

0 comments on commit 7fe05d1

Please sign in to comment.