Skip to content

[build] Fix branch name in Github action #13

[build] Fix branch name in Github action

[build] Fix branch name in Github action #13

name: Build and Publish cloudprober-serverutils
on:
push:
branches:
- master
pull_request:
paths:
- "probes/external/serverutils/py/**"
- ".github/workflows/py_serverutils.yml"
jobs:
test_and_build:
name: Build serverutils python package
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.x
- name: Test using venv
run: |
python -m venv venv
source venv/bin/activate
pip install -e probes/external/serverutils/py/
pip install pytest
pytest probes/external/serverutils/py/tests
deactivate
rm -rf venv
- name: Build using pypa/build
run: make py_serverutils
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: probes/external/serverutils/py/dist/
publish-to-pypi:
name: Publish to PyPI
needs:
- test_and_build
runs-on: ubuntu-latest
permissions:
id-token: write
if: github.repository == 'cloudprober/cloudprober' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v'))
steps:
- name: Check out repo hosting code
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
py:
- '**/*.py'
- '!**/test_*.py'
- '**/py_serverutils.yml'
- name: Download all the dists
uses: actions/download-artifact@v3
if: steps.filter.outputs.py == 'true'
with:
name: python-package-distributions
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
if: steps.filter.outputs.py == 'true'