This repository has been archived by the owner on Oct 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
55 lines (49 loc) · 1.72 KB
/
python-release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
---
name: Python Release
"on":
push:
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"