Skip to content

Commit 9854865

Browse files
Sign khisto binary (#24)
* Sign the binary for windows * fix potential issues - Fix PR paths trigger: pack-pip.yml -> pack-pip.yaml - Add python-version: '3.13' to setup-python step - Move Set up Python and Set up UV before Build wheels - Fix download-artifact v6
1 parent f8b5128 commit 9854865

1 file changed

Lines changed: 60 additions & 14 deletions

File tree

.github/workflows/pack-pip.yaml

Lines changed: 60 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@ on:
88
type: choice
99
default: None # no publishing to any Package Index by default
1010
options: [None, testpypi, pypi]
11+
signature-activation:
12+
type: boolean
13+
default: false
14+
description: Sign khisto binary
1115
push:
1216
tags: ['*']
1317
pull_request:
1418
paths:
15-
- .github/workflows/pack-pip.yml
19+
- .github/workflows/pack-pip.yaml
1620
- pyproject.toml
1721
- CMakeLists.txt
1822

@@ -23,6 +27,8 @@ concurrency:
2327
defaults:
2428
run:
2529
shell: bash
30+
env:
31+
KEYPAIR: KP_Khiops_HSM
2632

2733
jobs:
2834
build-wheel:
@@ -31,35 +37,75 @@ jobs:
3137
strategy:
3238
matrix:
3339
os: [ubuntu-24.04, ubuntu-24.04-arm, windows-2025-vs2026, windows-11-vs2026-arm, macos-15-intel, macos-15]
40+
env:
41+
SIGN_WINDOWS_WHEELS: ${{ github.event_name == 'workflow_dispatch' && inputs.signature-activation }}
3442
steps:
3543
- uses: actions/checkout@v6
36-
37-
- name: Load Visual C++ Environment Variables (Windows)
38-
if: runner.os == 'Windows'
39-
shell: cmd
40-
run: |
41-
call "C:\\Program Files\\Microsoft Visual Studio\\18\\Enterprise\\VC\\Auxiliary\\Build\\vcvars64.bat"
42-
set >> %GITHUB_ENV%
43-
44-
- name: Build wheels
45-
uses: pypa/cibuildwheel@v3.3.1
4644

4745
- name: Set up Python
4846
uses: actions/setup-python@v5
47+
with:
48+
python-version: '3.13'
4949

5050
- name: Set up UV
5151
uses: astral-sh/setup-uv@v6
5252
with:
5353
enable-cache: true
5454

55+
- name: Load Visual C++ Environment Variables (Windows)
56+
if: runner.os == 'Windows'
57+
shell: cmd
58+
run: |
59+
call "C:\\Program Files\\Microsoft Visual Studio\\18\\Enterprise\\VC\\Auxiliary\\Build\\vcvars64.bat"
60+
set >> %GITHUB_ENV%
61+
62+
- name: Build wheels
63+
uses: pypa/cibuildwheel@v3.3.1
64+
5565
- name: Test built wheel
5666
run: |
5767
uv venv .test-env
5868
uv pip install --python .test-env --find-links=wheelhouse "khisto[all]"
5969
uv sync --python .test-env --group dev --no-install-project
6070
uv run --python .test-env pytest tests/ --no-cov
6171
62-
- uses: actions/upload-artifact@v6
72+
# Windows wheels are unpackad, signed and repacked before uploading
73+
- name: Set SIGN_X64_WHEEL flag
74+
if: runner.os == 'Windows' && runner.arch == 'X64'
75+
run: echo "SIGN_X64_WHEEL=${{ env.SIGN_WINDOWS_WHEELS }}" >> "$GITHUB_ENV"
76+
- name: Warn smctl does not support ARM64 yet
77+
if: runner.os == 'Windows' && runner.arch == 'ARM64' && env.SIGN_WINDOWS_WHEELS == 'true'
78+
run: echo "::warning::smctl does not support ARM64 yet; the ARM64 wheel will not be signed"
79+
- name: Install wheel package for signing
80+
if: env.SIGN_X64_WHEEL == 'true'
81+
run: python -m pip install wheel
82+
- name: Unpack khisto wheel
83+
if: env.SIGN_X64_WHEEL == 'true'
84+
run: |
85+
mkdir -p wheelhouse/unpacked
86+
python -m wheel unpack wheelhouse/khisto-*.whl --dest wheelhouse/unpacked
87+
- name: Setup SM_CLIENT_CERT_FILE from base64 secret data
88+
if: env.SIGN_X64_WHEEL == 'true'
89+
run: |
90+
echo "SM_CLIENT_CERT_FILE=D:\\Certificate_pkcs12.p12" >> "$GITHUB_ENV"
91+
echo "${{ secrets.SM_CLIENT_CERT_FILE_B64 }}" | base64 --decode > /d/Certificate_pkcs12.p12
92+
- name: Sign unpacked wheel binaries
93+
if: env.SIGN_X64_WHEEL == 'true'
94+
uses: digicert/code-signing-software-trust-action@v1.2.1
95+
with:
96+
input: wheelhouse/unpacked/
97+
keypair-alias: ${{ env.KEYPAIR }}
98+
simple-signing-mode: true
99+
env:
100+
SM_HOST: ${{ secrets.SM_HOST }}
101+
SM_API_KEY: ${{ secrets.SM_API_KEY }}
102+
SM_CLIENT_CERT_PASSWORD: ${{ secrets.SM_CLIENT_CERT_PASSWORD }}
103+
- name: Repack signed wheels
104+
if: env.SIGN_X64_WHEEL == 'true'
105+
run: |
106+
rm wheelhouse/khisto-*.whl
107+
python -m wheel pack wheelhouse/unpacked/khisto-* --dest-dir wheelhouse
108+
- uses: actions/upload-artifact@v7
63109
with:
64110
name: pkg-wheel-${{ matrix.os }}
65111
path: wheelhouse/*.whl
@@ -76,7 +122,7 @@ jobs:
76122
environment:
77123
name: testpypi
78124
steps:
79-
- uses: actions/download-artifact@v6
125+
- uses: actions/download-artifact@v7
80126
with:
81127
pattern: pkg-*
82128
path: dist
@@ -97,7 +143,7 @@ jobs:
97143
environment:
98144
name: pypi
99145
steps:
100-
- uses: actions/download-artifact@v6
146+
- uses: actions/download-artifact@v7
101147
with:
102148
pattern: pkg-*
103149
path: dist

0 commit comments

Comments
 (0)