60 lines
No EOL
1.7 KiB
YAML
60 lines
No EOL
1.7 KiB
YAML
name: Publish to PyPI
|
|
|
|
# Based on: https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
|
|
|
|
on: workflow_dispatch
|
|
|
|
jobs:
|
|
build-n-publish:
|
|
name: Build and publish
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
submodules: "true"
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: "3.8"
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip pytest cmake scikit-build setuptools
|
|
- name: Build source distribution
|
|
run: |
|
|
python setup.py sdist
|
|
- name: Publish distribution to PyPI
|
|
# TODO: move to tag based releases
|
|
# if: startsWith(github.ref, 'refs/tags')
|
|
uses: pypa/gh-action-pypi-publish@release/v1
|
|
with:
|
|
password: ${{ secrets.PYPI_API_TOKEN }}
|
|
|
|
docker:
|
|
name: Build and push Docker image
|
|
runs-on: ubuntu-latest
|
|
needs: build-n-publish
|
|
steps:
|
|
- name: Checkout
|
|
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 GitHub Container Registry
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.repository_owner }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v4
|
|
with:
|
|
push: true # push to registry
|
|
pull: true # always fetch the latest base images
|
|
platforms: linux/amd64,linux/arm64 # build for both amd64 and arm64
|
|
tags: ghcr.io/abetlen/llama-cpp-python:latest |