Build wheel #161
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: Build wheel | |
on: | |
release: | |
types: [created] | |
workflow_call: | |
workflow_dispatch: | |
jobs: | |
build_wheel: | |
strategy: | |
fail-fast: false | |
matrix: | |
# macos-14 is arm64 (apple silicon), macos-13 is x86_64 | |
os: [ubuntu-latest, windows-latest, macos-13, macos-14] | |
name: Build [${{ matrix.os }}] | |
runs-on: ${{ matrix.os }} | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- uses: astral-sh/setup-uv@v4 | |
with: | |
enable-cache: true | |
cache-dependency-glob: | | |
**/requirements.txt | |
**/requirements-dev.txt | |
- name: Set up QEMU | |
if: runner.os == 'Linux' && github.event_name != 'pull_request' | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: arm64,ppc64le | |
- name: Install build tools | |
run: uv pip install --system -r requirements-dev.txt | |
- name: Bump new dev version | |
if: github.event_name != 'release' | |
run: | | |
git config user.name "Marcelo Duarte" | |
git config user.email marcelotduarte@users.noreply.github.com | |
SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) | |
VERSION=$(bump-my-version show current_version 2>/dev/null) | |
if ! (echo $VERSION | grep -q "\-dev"); then | |
bump-my-version bump --no-tag patch 2>/dev/null | |
VERSION=$(bump-my-version show current_version 2>/dev/null) | |
fi | |
if [ "${{ github.event_name }}" == "pull_request" ]; then | |
BUILD_NUMBER=${{ github.event.number }} | |
else | |
BUILD_NUMBER=$SOURCE_DATE_EPOCH | |
fi | |
NEWVERSION=$(python -c "print('$VERSION'.rsplit('.',1)[0])").$BUILD_NUMBER | |
bump-my-version bump --no-tag build --new-version=$NEWVERSION 2>/dev/null | |
git log -1 | |
- name: Build sdist and wheels | |
run: | | |
if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then | |
if [ "${{ github.event_name }}" == "pull_request" ]; then | |
./ci/build-wheel.sh "cp3{9,10,11,12}-manylinux*" --archs="x86_64" | |
else | |
./ci/build-wheel.sh --all | |
fi | |
elif [ "${{ matrix.os }}" == "macos-13" ]; then | |
./ci/build-wheel.sh "cp3{9,10}-*" | |
elif [ "${{ matrix.os }}" == "macos-14" ]; then | |
if [ "${{ github.event_name }}" == "pull_request" ]; then | |
./ci/build-wheel.sh "cp3{11,12}-*" --archs="arm64" | |
else | |
./ci/build-wheel.sh "cp3{11,12}-*" | |
fi | |
else | |
if [ "${{ github.event_name }}" == "pull_request" ]; then | |
./ci/build-wheel.sh "cp3{9,10,11,12}-*" --archs="AMD64" | |
else | |
./ci/build-wheel.sh --all | |
fi | |
fi | |
- name: Upload the artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cx-freeze-whl-${{ matrix.os }} | |
path: wheelhouse | |
compression-level: 0 # no compression | |
testpypi: | |
name: Publish package to TestPyPI | |
if: github.event_name == 'workflow_dispatch' | |
needs: | |
- build_wheel | |
runs-on: ubuntu-latest | |
environment: | |
name: ${{ github.event_name }} | |
url: https://test.pypi.org/p/cx-Freeze | |
permissions: | |
id-token: write | |
steps: | |
- name: Download all artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: artifacts | |
- name: Join files to upload | |
run: | | |
mkdir -p wheelhouse | |
mv artifacts/cx-freeze-whl-*/* wheelhouse/ | |
- name: Publish package to TestPyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
packages-dir: wheelhouse/ | |
repository-url: https://test.pypi.org/legacy/ | |
skip-existing: true | |
verbose: true | |
publish: | |
name: Publish package to PyPI | |
if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags') | |
needs: | |
- build_wheel | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/p/cx-Freeze | |
permissions: | |
id-token: write | |
steps: | |
- name: Download all artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: artifacts | |
- name: Join files to upload | |
run: | | |
mkdir -p wheelhouse | |
mv artifacts/cx-freeze-whl-*/* wheelhouse/ | |
- name: Publish package to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
packages-dir: wheelhouse/ | |
skip-existing: true | |
verbose: true | |
update_bases: | |
name: Update cx_Freeze/bases and util module | |
if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags') | |
needs: | |
- build_wheel | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: main | |
repository: marcelotduarte/cx_Freeze | |
token: ${{ secrets.PUSH }} | |
- name: Download all artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: artifacts | |
- name: If changed, extract and update the base executables and util module | |
run: | | |
SHA256SUM1=$(cat source/*.c source/bases/* | sha256sum | awk '{print $1}') | |
SHA256SUM2=$(cat cx_Freeze/bases/__init__.py | awk '{print $2}') | |
if [ $SHA256SUM1 != $SHA256SUM2 ]; then | |
git config user.name "Marcelo Duarte" | |
git config user.email marcelotduarte@users.noreply.github.com | |
git checkout -B update_bases main | |
# Remove any file that match - remove previous versions too | |
git rm --ignore-unmatch 'cx_Freeze/bases/*-win*.exe' 'cx_Freeze/util.*-win*.pyd' | |
# Extract base executables and util module | |
for file in artifacts/cx-freeze-pip-windows-*/*-win*.whl; do | |
unzip -o $file 'cx_Freeze/bases/*-win*.exe' 'cx_Freeze/util.*-win*.pyd' | |
done | |
git add cx_Freeze/bases/*-win*.exe cx_Freeze/util.*-win*.pyd | |
# Save the new SHA256SUM | |
echo "# $SHA256SUM1" > cx_Freeze/bases/__init__.py | |
git add cx_Freeze/bases/__init__.py | |
# Update | |
git commit -m "bases: update base executables and util module [ci skip]" | |
git push origin update_bases | |
fi |