Merge pull request #2 from quara-dev/fix/build_docker #24
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 package | |
on: [push] | |
jobs: | |
test: | |
name: Run tests | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.8", "3.9", "3.10", "3.11"] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip setuptools wheel | |
pip install -e .[dev,tests] | |
- name: Lint with flake8 | |
run: | | |
# stop the build if there are any error | |
flake8 . | |
- name: Lint with mypy | |
run: | | |
# stop the build if there are any error | |
mypy src/kapla | |
- name: Test with pytest | |
run: | | |
pytest -vvv -s | |
publish_release: | |
name: Publish release | |
runs-on: ubuntu-latest | |
needs: ["test"] | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.8 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip build | |
- name: Build package | |
run: | | |
python -m build | |
- name: Publish a Python distribution to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.PYPI_API_TOKEN }} | |
- name: Upload wheel to release | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: dist/*.whl | |
tag: ${{ github.ref }} | |
overwrite: true | |
file_glob: true | |
- name: Upload sdist to release | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: dist/*.tar.gz | |
tag: ${{ github.ref }} | |
overwrite: true | |
file_glob: true | |
publish_docker: | |
name: Publish docker image | |
runs-on: ubuntu-latest | |
needs: ["test"] | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v3 | |
with: | |
push: true | |
tags: quara/kapla:${{ github.ref_name }} | |
platforms: linux/amd64,linux/arm64 |