Build and Upload Python Package #36
Workflow file for this run
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
# This workflow will upload a Python Package to PyPI when a release is created | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries | |
# This workflow uses actions that are not certified by GitHub. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation. | |
name: Build and Upload Python Package | |
on: | |
release: | |
types: [published] | |
push: | |
tags: | |
- "v*.*.*" | |
permissions: | |
contents: read | |
jobs: | |
linux-build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Build on manylinux | |
run: | | |
docker run --rm \ | |
-v ${{ github.workspace }}:/project \ | |
-w /project \ | |
quay.io/pypa/manylinux_2_28_x86_64 \ | |
bash -c " | |
yum install -y patchelf | |
curl -L -o premake5.tar.gz https://github.com/premake/premake-core/releases/download/v5.0.0-alpha16/premake-5.0.0-alpha16-linux.tar.gz | |
tar -xvf premake5.tar.gz | |
mv premake5 /usr/local/bin/ | |
cd PrjBarlib | |
premake5 gmake2 --python-include-path=/opt/python/cp313-cp313/include/python3.13 \ | |
--python-version=3.13 | |
cd build | |
make config=python Barlib | |
echo --DONE-- | |
bash ../modules/python/make_package.sh Python /opt/python/cp313-cp313/bin/python3 | |
mkdir -p /project/dist | |
/opt/python/cp313-cp313/bin/python3 -m pip install --upgrade auditwheel | |
auditwheel repair --plat manylinux_2_28_x86_64 ./Python/BarcodeProject/dist/*.whl -w /project/dist | |
# cp -rf ./Python/BarcodeProject/dist/* /project/dist/ | |
" | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.13" | |
# - name: Repair and validate wheel | |
# run: | | |
# python -m pip install --upgrade auditwheel | |
# auditwheel repair --plat manylinux_2_28_x86_64 -w dist dist/*.whl | |
# ls dist | |
- name: Upload distributions | |
uses: actions/upload-artifact@v4 | |
with: | |
name: linux-dist | |
path: dist | |
windows-build: | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- uses: actions/setup-python@v5 | |
id: cp313 | |
with: | |
python-version: "3.13" | |
- name: Test Python vars | |
run: | | |
echo pythonLocation: ${{ env.pythonLocation }} | |
echo pythonLocation: ${{ steps.cp313.pythonLocation }} | |
# Cache the premmake5 binary | |
- uses: actions/cache@v3 | |
with: | |
path: | | |
${{ github.workspace }}\.premake-build | |
key: ${{ runner.os }}-premake5 | |
- name: setup-msbuild | |
uses: microsoft/setup-msbuild@v2 | |
# install premmake5 | |
- uses: Jarod42/install-premake5@v1 | |
- name: Build library | |
run: | | |
cd PrjBarlib | |
premake5 vs2022 --python-include-path=${{ env.pythonLocation }}/include --python-lib-path=${{ env.pythonLocation }}/libs --python-version=3.13 | |
cd build | |
msbuild /p:Configuration=python /p:Platform=x64 Barlib.vcxproj | |
- name: Make package | |
run: | | |
cd PrjBarlib/build | |
../modules/python/make_package.bat Python ${{ steps.cp313.outputs.python-path }} | |
xcopy Python\BarcodeProject\dist ..\..\dist /Q /E /Y /I | |
- name: Upload distributions | |
uses: actions/upload-artifact@v4 | |
with: | |
name: windows-dist | |
path: ${{ github.workspace }}/dist | |
pypi-publish: | |
runs-on: ubuntu-latest | |
needs: | |
- linux-build | |
- windows-build | |
permissions: | |
id-token: write | |
environment: | |
name: pypi | |
url: https://pypi.org/project/ImageTopoDec | |
steps: | |
- name: Retrieve Linux distributions | |
uses: actions/download-artifact@v4 | |
with: | |
name: linux-dist | |
path: dist | |
- name: Retrieve Windows distributions | |
uses: actions/download-artifact@v4 | |
with: | |
name: windows-dist | |
path: dist | |
- name: Validate wheels | |
run: | | |
python -m pip install twine | |
twine check dist/* | |
- name: Publish release distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
packages-dir: dist |