Skip to content

On push to release branch #63

On push to release branch

On push to release branch #63

name: On push to release branch
on:
push:
branches: [release]
jobs:
release:
runs-on: ubuntu-24.04
outputs:
version: ${{ steps.release.outputs.release }}
steps:
- uses: actions/checkout@v3
- name: Set release
id: semrel
uses: go-semantic-release/action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
allow-initial-development-versions: false
force-bump-patch-version: true
# For whatever reason, this silly tool won't let you do releases from branches
# other than the default branch unless you pass this flag, which doesn't seem
# to actually have anything to do with CI:
# https://github.com/go-semantic-release/semantic-release/blob/master/cmd/semantic-release/main.go#L173-L194
# https://github.com/go-semantic-release/condition-github/blob/4c8af3fc516151423fff2f77eb08bf7082570676/pkg/condition/github.go#L42-L44
custom-arguments: "--no-ci"
- name: Output release
id: release
run: echo "::set-output name=release::${{ steps.semrel.outputs.version }}"
test:
strategy:
matrix:
os: [ubuntu-20.04]
python-version: ["3.9", "3.10", "3.11"]
new-python-protobuf: ["true"]
include:
# 3.7 and 3.8 are no longer available on ubuntu-24.04
# We run on 20.04 which was the last version where this worked.
# If support for 20.04 becomes an issue, we can install 3.7 and 3.8
# with pyenv or manually.
- python-version: "3.7"
new-python-protobuf: "true"
os: ubuntu-20.04
- python-version: "3.7"
new-python-protobuf: "false"
os: ubuntu-20.04
- python-version: "3.8"
new-python-protobuf: "true"
os: ubuntu-20.04
- python-version: "3.8"
new-python-protobuf: "false"
os: ubuntu-20.04
runs-on: ${{ matrix.os }}
env:
TEST_API_KEY: ${{ secrets.ALPHA_TEST_AUTH_TOKEN }}
TEST_CACHE_NAME: python-integration-test-${{ matrix.python-version }}-${{ matrix.new-python-protobuf }}-${{ github.sha }}
steps:
- uses: actions/checkout@v3
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
version: 1.3.1
virtualenvs-in-project: true
- name: Install dependencies
run: poetry install
- name: Install Old Protobuf
# Exercises the wire types generated against the old protobuf library
if: matrix.new-python-protobuf == 'false'
run: poetry add "protobuf<3.20"
- name: Run mypy
# mypy has inconsistencies between 3.7 and the rest; default to lowest common denominator
if: matrix.python-version == '3.7'
run: poetry run mypy src tests
- name: Run ruff analyzer
run: poetry run ruff check --no-fix src tests
- name: Run ruff formatter
run: poetry run ruff format --diff src tests
- name: Run tests
run: poetry run pytest -p no:sugar -q
publish:
runs-on: ubuntu-24.04
needs: [release, test]
steps:
- uses: actions/checkout@v3
- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
version: 1.3.1
virtualenvs-in-project: true
- name: Setup Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Bump version
run: poetry version ${{ needs.release.outputs.version }}
- name: Build package
run: poetry build
- name: Publish package
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYTHON_CUSTOMER_SDK_PYPI_TOKEN }}
run: poetry publish