Skip to content

Python-package

Python-package #30

Workflow file for this run

---
name: Python Build Package
on:
pull_request:
branches:
- main
push:
branches:
- main
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-22.04
container:
image: quay.io/pypa/manylinux2014_x86_64
strategy:
fail-fast: false
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13']
env:
GOEXPERIMENT: cgocheck2
steps:
- name: Set up OS deps
shell: bash
run: |
yum -y update
yum -y install git gcc make wget
wget https://go.dev/dl/go1.21.6.linux-amd64.tar.gz
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.21.6.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
go version
- name: Set up Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Clone the repository
run: |
git clone https://github.com/${{ github.repository }} repo
cd repo
- name: Setup Environment (PR)
if: ${{ github.event_name == 'pull_request' }}
shell: bash
run: |
echo "LAST_COMMIT_SHA=${{ github.event.pull_request.head.sha }}" >> ${GITHUB_ENV}
- name: Setup Environment (Push)
if: ${{ github.event_name == 'push' }}
shell: bash
run: |
echo "LAST_COMMIT_SHA=${GITHUB_SHA}" >> ${GITHUB_ENV}
- name: Verify Checkout
run: |
echo $LAST_COMMIT_SHA
cd repo
git checkout $LAST_COMMIT_SHA
git log -1
- name: Run module tests
run: |
cd repo
export PKG_CONFIG_PATH=/opt/_internal/cpython-${{ matrix.python-version }}.*/lib/pkgconfig/
export PKG_CONFIG_PATH=$(echo $PKG_CONFIG_PATH | awk '{gsub(" ",ORS)} 1')
pkg-config --libs python3-embed
export PATH=$PATH:/usr/local/go/bin
go test -race -v ./...
- name: Build the CLI
shell: bash
run: |
export PATH=$PATH:/usr/local/go/bin
cd repo
cd cmd/cli
export PKG_CONFIG_PATH=/opt/_internal/cpython-${{ matrix.python-version }}.*/lib/pkgconfig/
export PKG_CONFIG_PATH=$(echo $PKG_CONFIG_PATH | awk '{gsub(" ",ORS)} 1')
CGO_ENABLED=1 go build -o caddysnake-cli main.go
touch dummy.c
python -m pip install cibuildwheel
export CIBW_BUILD=cp$(echo ${{ matrix.python-version }} | tr -d .)-manylinux_x86_64
echo $CIBW_BUILD
CIBW_BUILD_VERBOSITY=1 python -m cibuildwheel
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: repo/cmd/cli/dist
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}