Skip to content

Fix MANIFEST, declare license properly. #113

Fix MANIFEST, declare license properly.

Fix MANIFEST, declare license properly. #113

# This is a basic workflow to help you get started with Actions
name: Build, Test & Publush
# Controls when the action will run.
on:
# Triggers the workflow on all push or pull request events
push:
pull_request:
release:
types: [created]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
# added using https://github.com/step-security/secure-repo
permissions:
contents: read
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build_and_test_python:
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
compiler: ['gcc', 'clang']
os: [macos, ubuntu]
# include:
# Would be cool, but not yet :(. Someone, please make a PR.
# - python-version: '3.10'
# compiler: microsoft
# os: windows
# - python-version: '3.11'
# compiler: microsoft
# os: windows
# - python-version: '3.12'
# compiler: microsoft
# os: windows
runs-on: ${{ matrix.os }}-latest
env:
COMPILER: ${{ matrix.compiler }}
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade build setuptools wheel
shell: bash
- name: build
run: CC=${COMPILER} LDSHARED="${COMPILER} -shared" python setup.py build sdist
shell: bash
- name: install
run: pip install dist/*.gz
shell: bash
- name: test
run: |
python -m unittest discover -v -s tests -p '*.py'
shell: bash
build_bin_wheels:
needs: build_and_test_python
runs-on: ubuntu-latest
permissions:
packages: write
env:
PY_VER: ${{ matrix.python-version }}
BASE_IMAGE: quay.io/pypa/manylinux_2_28:latest
GHCR_REPO: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.11', '3.12']
steps:
- name: Set up Python ${{ env.PY_VER }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PY_VER }}
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set dynamic environment
id: set-env
run: |
PLATFORMS="`docker manifest inspect ${{ env.BASE_IMAGE }} | \
jq -r '.manifests[] | "\(.platform.os)/\(.platform.architecture)\(if .platform.variant != null then "/\(.platform.variant)" else "" end)"' | \
sort -u | grep -v unknown | paste -sd ','`"
GIT_BRANCH="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
GIT_BRANCH="${GIT_BRANCH#refs/tags/}"
BUILD_IMAGE="${GHCR_REPO}:${GIT_BRANCH}-py${PY_VER}"
echo "Platforms: ${PLATFORMS}"
echo "Build Image: ${BUILD_IMAGE}"
echo "PLATFORMS=${PLATFORMS}" >> $GITHUB_ENV
echo "BUILD_IMAGE=${BUILD_IMAGE}" >> $GITHUB_ENV
- name: Build Docker image
uses: docker/build-push-action@v6
env:
CACHE_SPEC: "type=registry,ref=${{ env.BUILD_IMAGE }}-buildcache"
with:
context: .
file: ./docker/Dockerfile.python_wheels
build-args: |
BASE_IMAGE=${{ env.BASE_IMAGE }}
PY_VER=${{ env.PY_VER }}
platforms: ${{ env.PLATFORMS }}
push: false
outputs: type=local,dest=dist_out
cache-from: ${{ env.CACHE_SPEC }}
cache-to: ${{ env.CACHE_SPEC }},mode=max
- name: Collect Wheels
run: |
mkdir dist
mv `find dist_out -type f -name \*.whl` dist
rm -r dist_out
- name: Upload built wheels
uses: actions/upload-artifact@v4
with:
name: dist-${{ env.PY_VER }}
path: dist
publish_pypi:
needs: build_bin_wheels
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/asyncproxy
permissions:
id-token: write
actions: read
contents: read
steps:
- uses: actions/checkout@v4
- name: Download all wheel artifacts
uses: actions/download-artifact@v4
with:
path: dist
pattern: dist-*
merge-multiple: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade build setuptools wheel
- name: build
run: python setup.py build sdist
- name: Show context tree
run: ls -R dist
- name: Publish package distributions to PyPI
if: github.event_name == 'release' && github.event.action == 'created'
uses: pypa/gh-action-pypi-publish@release/v1