Feat post publish #81
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Python PyPI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
paths: | |
- 'polyglot/python/**' | |
- 'proto/**' | |
jobs: | |
build: | |
name: Build | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v1 | |
with: | |
python-version: 3.9 | |
- name: Set up Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: 1.18 | |
- uses: actions/cache@master | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('python/requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install Protoc | |
uses: arduino/setup-protoc@v1 | |
- name: Install Protoc 3rd party protos | |
run: scripts/install-protoc.sh | |
- name: Install dependencies | |
run: | | |
cd polyglot/python | |
python -m pip install --upgrade pip | |
make install | |
- name: Test | |
run: | | |
cd polyglot/python | |
make generate | |
make test | |
pack: | |
name: Pack | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-python@v1 | |
with: | |
python-version: 3.9 | |
- name: Set up Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: 1.18 | |
- uses: actions/cache@master | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('python/requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install Protoc | |
uses: arduino/setup-protoc@v1 | |
- name: Install Protoc 3rd party protos | |
run: scripts/install-protoc.sh | |
- name: Install dependencies | |
run: | | |
cd polyglot/python | |
python -m pip install --upgrade pip | |
pip install setuptools wheel twine | |
make install | |
- name: Pack Testing | |
run: | | |
cd polyglot/python | |
make generate | |
make dist | |
echo "To be add: pack testing" | |
deploy: | |
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/v')) | |
name: Deploy | |
needs: [build, pack] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v1 | |
with: | |
python-version: '3.9' | |
- name: Set up Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: 1.18 | |
- uses: actions/cache@master | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('python/requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install Protoc | |
uses: arduino/setup-protoc@v1 | |
- name: Install Protoc 3rd party protos | |
run: scripts/install-protoc.sh | |
- name: Install dependencies | |
run: | | |
cd polyglot/python | |
python -m pip install --upgrade pip | |
pip3 install setuptools wheel twine | |
- name: Check Branch | |
id: check-branch | |
run: | | |
if [[ ${{ github.ref }} =~ ^refs/heads/(main|v[0-9]+\.[0-9]+.*)$ ]]; then | |
echo ::set-output name=match::true | |
fi # See: https://stackoverflow.com/a/58869470/1123955 | |
- name: Is A Publish Branch | |
if: steps.check-branch.outputs.match == 'true' | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} | |
run: | | |
cd polyglot/python | |
make install | |
make generate | |
make dist | |
python3 setup.py sdist bdist_wheel | |
twine upload --skip-existing dist/* | |
- name: Is Not A Publish Branch | |
if: steps.check-branch.outputs.match != 'true' | |
run: echo 'Not A Publish Branch' |