blob: f1f43d2571262d03377c9dad2b2c21689a19d4df [file] [log] [blame]
name: Python
on:
workflow_dispatch:
inputs:
build:
required: true
type: number
jobs:
bdist_wheel-linux:
name: Linux ${{ matrix.os }}, ${{ matrix.arch.name }}, Python ${{ matrix.ver }}
runs-on: ${{ matrix.arch.runs-on }}
container:
image: quay.io/pypa/${{ matrix.os }}_${{ matrix.arch.python-name }}
options: --init
strategy:
fail-fast: false
matrix:
arch:
- { name: X64, python-name: x86_64, runs-on: [ubuntu-latest] }
- { name: ARM64, python-name: aarch64, runs-on: [self-hosted, linux, arm64] }
os: [manylinux2014, manylinux_2_28]
ver: ['3.8', '3.9', '3.10', '3.11']
env:
BAZELISK_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
# TODO(junyer): Use `v2` whenever a new release is tagged.
- uses: bazelbuild/setup-bazelisk@6244971d4f7ba9aca943c2f3ede2bbd813fcca51
- name: Prepare Python ${{ matrix.ver }} environment
run: |
ln -sf /usr/local/bin/python${{ matrix.ver }} /usr/local/bin/python
ln -sf /usr/local/bin/python${{ matrix.ver }} /usr/local/bin/python3
python -m pip install --upgrade pip
python -m pip install --upgrade wheel auditwheel
python -m pip install --upgrade absl-py
shell: bash
- name: Build wheel
run: |
python setup.py bdist_wheel
python -m auditwheel repair --wheel-dir=. dist/*
shell: bash
working-directory: python
- name: Test wheel
run: |
python -m pip install google_re2-*.whl
python re2_test.py
shell: bash
working-directory: python
- uses: actions/upload-artifact@v3
with:
name: ${{ hashFiles('python/google_re2-*.whl') }}
path: python/google_re2-*.whl
retention-days: 1
bdist_wheel-macos:
name: macOS ${{ matrix.os }}, ${{ matrix.arch.name }}, Python ${{ matrix.ver }}
runs-on: macos-${{ matrix.os }}
strategy:
fail-fast: false
matrix:
arch:
- { name: X64, bazel-name: x86_64, python-name: x86_64 }
- { name: ARM64, bazel-name: arm64, python-name: arm64 }
os: [11, 12, 13]
ver: ['3.8', '3.9', '3.10', '3.11']
env:
BAZELISK_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BAZEL_CPU: darwin_${{ matrix.arch.bazel-name }}
# Stop macOS from reporting the system version as 10.x.
# Otherwise, Python refuses to install the built wheel!
SYSTEM_VERSION_COMPAT: 0
steps:
- uses: actions/checkout@v3
# TODO(junyer): Use `v2` whenever a new release is tagged.
- uses: bazelbuild/setup-bazelisk@6244971d4f7ba9aca943c2f3ede2bbd813fcca51
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.ver }}
- name: Prepare Python ${{ matrix.ver }} environment
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade wheel delocate
python -m pip install --upgrade absl-py
shell: bash
- name: Build wheel
run: |
python setup.py bdist_wheel \
--plat-name=macosx-${{ matrix.os }}.0-${{ matrix.arch.python-name }}
python -m delocate.cmd.delocate_wheel --wheel-dir=. dist/*
shell: bash
working-directory: python
- if: matrix.arch.name == runner.arch
name: Test wheel
run: |
python -m pip install google_re2-*.whl
python re2_test.py
shell: bash
working-directory: python
- uses: actions/upload-artifact@v3
with:
name: ${{ hashFiles('python/google_re2-*.whl') }}
path: python/google_re2-*.whl
retention-days: 1
bdist_wheel-windows:
name: Windows, ${{ matrix.arch.name }}, Python ${{ matrix.ver }}
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
arch:
- { name: X86, bazel-name: x64_x86, python-name: win32 }
- { name: X64, bazel-name: x64, python-name: win_amd64 }
ver: ['3.8', '3.9', '3.10', '3.11']
env:
BAZELISK_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BAZEL_CPU: ${{ matrix.arch.bazel-name }}_windows
steps:
- uses: actions/checkout@v3
# Avoid the Chocolatey install of Bazel getting in the way;
# `bazelbuild/setup-bazelisk` doesn't work for some reason.
- run: |
choco uninstall -y bazel
choco install -y bazelisk
shell: bash
# Lowercase the architecture name for `actions/setup-python`.
- run: |
ARCHITECTURE=${{ matrix.arch.name }}
echo "architecture=${ARCHITECTURE,,}" >> "${GITHUB_ENV}"
shell: bash
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.ver }}
architecture: ${{ env.architecture }}
- name: Prepare Python ${{ matrix.ver }} environment
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade wheel delvewheel
python -m pip install --upgrade absl-py
shell: bash
- name: Build wheel
run: |
python setup.py bdist_wheel \
--plat-name=${{ matrix.arch.python-name }}
python -m delvewheel repair --wheel-dir=. dist/*
shell: bash
working-directory: python
- name: Test wheel
run: |
python -m pip install google_re2-*.whl
python re2_test.py
shell: bash
working-directory: python
- uses: actions/upload-artifact@v3
with:
name: ${{ hashFiles('python/google_re2-*.whl') }}
path: python/google_re2-*.whl
retention-days: 1
publish:
needs:
- bdist_wheel-linux
- bdist_wheel-macos
- bdist_wheel-windows
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Prepare Python 3.x environment
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade wheel
shell: bash
- if: inputs.build == 1
name: Build source
run: |
python setup.py sdist
shell: bash
working-directory: python
- uses: actions/download-artifact@v3
with:
path: python
- name: Set build number to ${{ inputs.build }}
run: |
mkdir -p dist
for WHL in */google_re2-*.whl; do
python -m wheel unpack "${WHL}"
python -m wheel pack --dest-dir=dist --build-number=${{ inputs.build }} google_re2-*
rm -rf google_re2-*
done
shell: bash
working-directory: python
- uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
packages_dir: python/dist