don't fail at version mismatch #2756
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 Pipeline | |
on: | |
# Run on all pushed commits, PRs and when a new release is created | |
# Prevents duplicate pipeline runs as a release also pushes a tag | |
workflow_dispatch: | |
pull_request: | |
push: | |
branches: | |
- "**" | |
tags-ignore: | |
- "**" | |
release: | |
types: | |
- created | |
jobs: | |
lint: | |
# Prevent duplicate runs for own PRs | |
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- uses: pre-commit/[email protected] | |
pre-build: | |
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch' || contains(github.event.head_commit.message, '[build]') || contains(github.event.head_commit.message, '[build-cli]') | |
runs-on: windows-2022 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
# pythonnet doesn't have wheels beyond 3.8 | |
python-version: "3.8" | |
architecture: "x64" | |
- name: Setup .NET Core | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 3.1.100 | |
- name: Add msbuild to PATH | |
uses: microsoft/setup-msbuild@v2 | |
- name: Install Python dependencies | |
run: | | |
python -m pip install pythonnet wheel setuptools-rust | |
- name: Install Aspose | |
shell: bash | |
run: | | |
mkdir ./aspose | |
curl -L https://www.nuget.org/api/v2/package/Aspose.Cells/17.12.0 -o ./aspose/aspose.cells.nupkg | |
unzip ./aspose/aspose.cells.nupkg -d ./aspose/ | |
- name: Caching dlls | |
uses: actions/cache@v4 | |
id: cache | |
with: | |
path: | | |
xlwings32.dll | |
xlwings64.dll | |
key: ${{ runner.os }}-${{ hashFiles('xlwingsdll/**') }} | |
- name: Build dlls | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: | | |
msbuild $Env:GITHUB_WORKSPACE\xlwingsdll\xlwings.sln /p:Configuration=Release -maxcpucount | |
msbuild $Env:GITHUB_WORKSPACE\xlwingsdll\xlwings.sln /p:Configuration=Release /p:Platform=x64 -maxcpucount | |
- name: Get Certificate | |
id: write_file | |
uses: timheuer/base64-to-file@604a8926a81a2da120d09b06bb76da9bba5aee6e | |
with: | |
fileName: "cert.p12" | |
encodedString: ${{ secrets.CODESIGN_CERTIFICATE }} | |
- name: Set PATH for signtool | |
shell: bash | |
run: echo "C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\x64" >> $GITHUB_PATH | |
- name: Code Sign dlls | |
run: | | |
signtool sign /f ${{ steps.write_file.outputs.filePath }} /p ${{ secrets.CODESIGN_PASSWORD }} /tr http://timestamp.sectigo.com /td sha256 /fd SHA256 xlwings32.dll xlwings64.dll | |
- name: Build files | |
shell: bash | |
env: | |
ASPOSE_LICENSE: ${{ secrets.ASPOSE_LICENSE }} | |
XLWINGS_LICENSE_KEY_SECRET: ${{ secrets.XLWINGS_LICENSE_KEY_SECRET }} | |
run: | | |
python ./scripts/build_excel_files.py | |
# Code sign Excel add-in (start) | |
- name: Download and unzip Microsoft Office Subject Interface Packages | |
if: github.event_name == 'release' | |
shell: bash | |
run: | | |
# Microsoft Office Subject Interface Packages for Digitally Signing VBA Projects: https://www.microsoft.com/en-us/download/details.aspx?id=56617 | |
# NOTE: see README in officesips.exe: the whole stack needs to be x86, including signtool, regsvr32.exe and C Redistribution Runtime 2010 | |
mkdir ./officesips | |
curl -L https://download.microsoft.com/download/F/B/4/FB46F8CA-6A6F-4CB0-B8F4-06BF3D44DA48/officesips.exe -o ./officesips.exe | |
7z x ./officesips.exe -o./officesips | |
- name: Install Microsoft Visual C Redistributable 2010 | |
if: github.event_name == 'release' | |
run: | | |
# https://vcredist.com | |
# Must be 2010: https://stackoverflow.com/questions/60239192/signtool-exe-error-signersign-failed-2147220492-0x800403f4-when-signing-ex | |
Install-Module -Name VcRedist -Force | |
New-Item -Path .\VcRedist -ItemType Directory | |
$VcRedists = Get-VcList -Export Unsupported | Where-Object { $_.Release -eq "2010" -and $_.Architecture -eq "x86" } | |
Save-VcRedist -VcList $VcRedists -Path .\VcRedist | |
Install-VcRedist -VcList $VcRedists -Path .\VcRedist | |
- name: Register msosipx.dll | |
if: github.event_name == 'release' | |
run: | | |
# Make sure it uses the 32bit version of regsvr32.exe | |
C:\Windows\system32\regsvr32.exe officesips\msosipx.dll | |
- name: Sign Excel add-in | |
if: github.event_name == 'release' | |
run: | | |
# Office 365 supports three different signatures on VBA projects, which is the reason why OffSign.bat signs and verifies the files 3x | |
# Note that signtools is in ...\bin\x86 | |
.\officesips\OffSign.bat "C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\x86\" "sign /f ${{ steps.write_file.outputs.filePath }} /p ${{ secrets.CODESIGN_PASSWORD }} /tr http://timestamp.sectigo.com /td sha256 /fd SHA256" "verify /pa" ".\xlwings\addin\xlwings.xlam" | |
# Code sign Excel add-in (end) | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: pre-build | |
retention-days: 1 | |
path: | | |
./* | |
!./git | |
!./aspose | |
!./xlwingsdll | |
!./resources/mac | |
!./examples | |
!./docs | |
build: | |
needs: pre-build | |
name: Build wheel | |
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch' || contains(github.event.head_commit.message, '[build]') | |
strategy: | |
fail-fast: false | |
matrix: | |
# abi3 wheels aren't supported as DateTime is not part of the ABI spec (PEP 384) | |
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] | |
platform: | |
[ | |
{ os: "windows-latest", target: "x86_64" }, | |
{ os: "macos-13", target: "x86_64" }, | |
{ os: "macos-13", target: "aarch64" }, | |
{ os: "ubuntu-latest", target: "x86_64" }, | |
{ os: "ubuntu-latest", target: "any" }, # HACK: replace with WASM build | |
{ os: "ubuntu-latest", target: "aarch64" }, | |
{ os: "ubuntu-latest", target: "armv7" }, | |
{ | |
os: "ubuntu-latest", | |
target: "x86_64", | |
manylinux: "musllinux_1_1", | |
}, | |
{ | |
os: "ubuntu-latest", | |
target: "aarch64", | |
manylinux: "musllinux_1_1", | |
}, | |
] | |
runs-on: ${{ matrix.platform.os }} | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: pre-build | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
architecture: "x64" | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: stable | |
# Add the arm64 target in addition to the native arch (x86_64) | |
target: aarch64-apple-darwin | |
- name: Install Python dependencies | |
run: python -m pip install wheel setuptools-rust pytest | |
- name: Set up QEMU | |
# Required for Linux cross-compilation | |
if: matrix.platform.os == 'ubuntu-latest' | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: all | |
- name: Build macOS and Linux wheels | |
if: matrix.platform.os != 'windows-latest' && matrix.platform.target != 'any' | |
uses: PyO3/maturin-action@v1 | |
with: | |
target: ${{ matrix.platform.target }} | |
manylinux: ${{ matrix.platform.manylinux || 'auto' }} | |
maturin-version: v1.5.1 | |
command: build | |
args: --release --out dist --interpreter ${{ matrix.python-version }} | |
# TODO: Build with Maturin once the xlwings.dlls aren't data_files anymore | |
- name: Legacy Windows Build | |
if: matrix.platform.os == 'windows-latest' | |
shell: bash | |
env: | |
BUILD_RUST: 1 | |
run: | | |
rm pyproject.toml | |
python setup.py sdist bdist_wheel | |
- name: any wheel (for now used for wasm but without the Reader) | |
if: matrix.platform.target == 'any' && matrix.python-version == '3.12' | |
shell: bash | |
env: | |
BUILD_RUST: 0 | |
run: | | |
rm pyproject.toml | |
python setup.py sdist bdist_wheel | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Package | |
path: ./dist | |
- name: Tests | |
if: matrix.platform.target == 'x86_64' && matrix.platform.manylinux != 'musllinux_1_1' | |
shell: bash | |
env: | |
XLWINGS_LICENSE_KEY: ${{ secrets.XLWINGS_LICENSE_KEY }} | |
run: | | |
python -m pip install xlwings --no-index --find-links dist --force-reinstall --no-deps | |
cd .. | |
python -c "import xlwings;print(xlwings.__version__)" | |
python -c "import xlwings;print(xlwings.__path__)" | |
XLWINGS_ENGINE=remote pytest xlwings/tests/test_engines/test_engines.py | |
XLWINGS_ENGINE=calamine XLWINGS_FILE_EXTENSION=xlsm pytest xlwings/tests/test_engines/test_engines.py | |
XLWINGS_ENGINE=calamine XLWINGS_FILE_EXTENSION=xlsb pytest xlwings/tests/test_engines/test_engines.py | |
XLWINGS_ENGINE=calamine XLWINGS_FILE_EXTENSION=xls pytest xlwings/tests/test_engines/test_engines.py | |
xlwings quickstart testproject1 | |
build-cli: | |
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch' || contains(github.event.head_commit.message, '[build-cli]') | |
needs: pre-build | |
name: Build CLI | |
runs-on: windows-2022 | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: pre-build | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
cache: "pip" | |
- name: Get Certificate | |
id: write_file | |
uses: timheuer/base64-to-file@48657ba25c726c2e3dcf02efa3639fff9b3d587e | |
with: | |
fileName: "cert.p12" | |
encodedString: ${{ secrets.CODESIGN_CERTIFICATE }} | |
- name: Set PATH for signtool | |
shell: bash | |
run: echo "C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\x64" >> $GITHUB_PATH | |
- name: Install Python dependencies | |
run: pip install pyinstaller pywin32 msal watchgod | |
- name: Build executable | |
run: | | |
pyinstaller ./xlwings/cli.py --onefile --name xlwings --icon ./resources/xlwings.ico | |
cp ./dist/xlwings.exe ./xlwings.exe | |
- name: Code Sign exe | |
run: | | |
signtool sign /f ${{ steps.write_file.outputs.filePath }} /p ${{ secrets.CODESIGN_PASSWORD }} /tr http://timestamp.sectigo.com /td sha256 /fd SHA256 xlwings.exe | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: cli | |
retention-days: 1 | |
path: | | |
./xlwings.exe | |
publish: | |
if: github.event_name == 'release' | |
name: Publish | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
architecture: "x64" | |
- name: Install Python dependencies | |
run: | | |
python -m pip install wheel twine | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: Package | |
path: Package | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: cli | |
- name: GH Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: xlwings.exe | |
body: | | |
* Release Notes: https://docs.xlwings.org/en/latest/whatsnew.html | |
* Installation: To install this release, you must use the `pip` or `conda` package manager, you can't install from source directly, see https://docs.xlwings.org/en/stable/installation.html | |
* CLI: `xlwings.exe` is a standalone xlwings command-line client with very limited functionality. It currently works for the `xlwings vba`, `xlwings addin -f`, and `xlwings auth` commands and saves you from having to install a full Python installation if these are your only use cases. | |
- name: Publish package and update homepage with release version | |
shell: bash | |
run: | | |
twine upload Package/*.tar.gz | |
twine upload Package/*.whl | |
curl -X POST -d {} https://api.netlify.com/build_hooks/$NETLIFY_BUILD_HOOK | |
env: | |
NETLIFY_BUILD_HOOK: ${{ secrets.NETLIFY_BUILD_HOOK }} | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} | |
# repository_url: https://test.pypi.org/legacy/ |