Skip to content

Merge pull request #18 from elastic/renovate/pypa-gh-action-pypi-publ… #48

Merge pull request #18 from elastic/renovate/pypa-gh-action-pypi-publ…

Merge pull request #18 from elastic/renovate/pypa-gh-action-pypi-publ… #48

Workflow file for this run

name: Main
on:
push:
tags: "v[0-9]+.[0-9]+.[0-9]+"
branches: "main"
pull_request:
branches: "*"
env:
HOME_REPO: "elastic/faker-datasets"
jobs:
unit-tests:
name: Unit tests (${{ matrix.os }}/py${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
os: ["ubuntu-latest", "macos-latest"]
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Setup Python
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: make prereq
- name: Lint code
run: make lint
- name: Run tests
run: make test V=2
package-build:
name: Package build (${{ matrix.os }}/py${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
os: ["ubuntu-latest", "macos-latest"]
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Setup Python
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: make prereq
- name: Build package
run: make pkg-build
- name: Upload artifacts
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4
with:
name: python-package-${{ matrix.python-version }}-${{ matrix.os }}
path: dist/*
package-tests:
name: Package tests (${{ matrix.os }}/py${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
needs: package-build
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
os: ["ubuntu-latest", "macos-latest"]
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
path: code
- name: Setup Python
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5
with:
python-version: ${{ matrix.python-version }}
- name: Download artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
name: python-package-${{ matrix.python-version }}-${{ matrix.os }}
path: dist
- name: Install package
run: make -f code/Makefile pkg-install
publish:
name: Publish
runs-on: ubuntu-latest
needs:
- unit-tests
- package-tests
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- name: Setup Python
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5
with:
python-version: "3.8"
- name: Download artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
name: python-package-3.8-ubuntu-latest
path: dist
- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@0ab0b79471669eb3a4d647e625009c62f9f3b241 # v1.10.1
if: github.repository != env.HOME_REPO
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
print_hash: true
repository_url: https://test.pypi.org/legacy/
skip_existing: true
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@0ab0b79471669eb3a4d647e625009c62f9f3b241 # v1.10.1
if: github.repository == env.HOME_REPO
with:
password: ${{ secrets.PYPI_API_TOKEN }}
print_hash: true