Skip to content

Commit 4054038

Browse files
committed
Use released libzim 8.2.0
Split wheels workflow into: - wheels workflow ran on PRs to ensure we can build properly - release workflow with release environment that builds and uploads to PyPI
1 parent 98a4e7e commit 4054038

5 files changed

Lines changed: 128 additions & 81 deletions

File tree

.github/workflows/release.yaml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: Build and upload to PyPI
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
8+
env:
9+
LIBZIM_DL_VERSION: "8.2.0"
10+
MACOSX_DEPLOYMENT_TARGET: "11.0"
11+
CIBW_ENVIRONMENT_PASS_LINUX: "LIBZIM_DL_VERSION"
12+
# APPLE_SIGNING_KEYCHAIN_PATH set in prepare keychain step
13+
APPLE_SIGNING_KEYCHAIN_PROFILE: "build-profile"
14+
APPLE_SIGNING_IDENTITY: "${{ secrets.APPLE_SIGNING_IDENTITY }}"
15+
SIGN_APPLE: "yes"
16+
17+
18+
jobs:
19+
build_wheels:
20+
environment: release
21+
name: Build wheels on ${{ matrix.os }}
22+
runs-on: ${{ matrix.os }}
23+
strategy:
24+
matrix:
25+
os: [ubuntu-20.04, macos-12] # macos-11, windows-2019
26+
27+
steps:
28+
- uses: actions/checkout@v3
29+
30+
- name: Set up QEMU
31+
if: runner.os == 'Linux'
32+
uses: docker/setup-qemu-action@v2
33+
with:
34+
platforms: all
35+
36+
- name: Prepare Apple Keychain for Signing
37+
if: matrix.os == 'macos-12'
38+
shell: bash
39+
run: |
40+
# store certificate on filesystem
41+
export CERTIFICATE="$(mktemp -d)/wmch-devid.p12"
42+
echo "${{ secrets.APPLE_SIGNING_CERTIFICATE }}" | base64 --decode -o $CERTIFICATE
43+
44+
# create a dedicated keychain
45+
export APPLE_SIGNING_KEYCHAIN_PATH="$(mktemp -d)/build.keychain"
46+
echo "APPLE_SIGNING_KEYCHAIN_PATH=${APPLE_SIGNING_KEYCHAIN_PATH}" >> "$GITHUB_ENV"
47+
security create-keychain -p mysecretpassword ${APPLE_SIGNING_KEYCHAIN_PATH}
48+
security default-keychain -s ${APPLE_SIGNING_KEYCHAIN_PATH}
49+
security unlock-keychain -p mysecretpassword ${APPLE_SIGNING_KEYCHAIN_PATH}
50+
51+
# import certificate into keychain then remove from filesystem
52+
security import ${CERTIFICATE} -k ${APPLE_SIGNING_KEYCHAIN_PATH} -P "${{ secrets.APPLE_SIGNING_P12_PASSWORD }}" -A
53+
rm $CERTIFICATE
54+
55+
# store signing credentials into the keychain
56+
security set-key-partition-list -S "apple-tool:,apple:" -s -k mysecretpassword ${APPLE_SIGNING_KEYCHAIN_PATH}
57+
security find-identity -v
58+
xcrun notarytool store-credentials \
59+
--apple-id "${{ secrets.APPLE_SIGNING_ALTOOL_USERNAME }}" \
60+
--password "${{ secrets.APPLE_SIGNING_ALTOOL_PASSWORD }}" \
61+
--team-id "${{ secrets.APPLE_SIGNING_TEAM }}" \
62+
--validate \
63+
--keychain ${APPLE_SIGNING_KEYCHAIN_PATH} \
64+
${APPLE_SIGNING_KEYCHAIN_PROFILE}
65+
66+
# disable auto-locking of keychain
67+
security set-keychain-settings ${APPLE_SIGNING_KEYCHAIN_PATH}
68+
security unlock-keychain -p mysecretpassword ${APPLE_SIGNING_KEYCHAIN_PATH}
69+
70+
- name: Build wheels
71+
uses: pypa/cibuildwheel@v2.12.1
72+
73+
- name: Cleanup Apple Keychain
74+
if: matrix.os == 'macos-12'
75+
shell: bash
76+
run: |
77+
security lock-keychain ${APPLE_SIGNING_KEYCHAIN_PATH}
78+
security delete-keychain ${APPLE_SIGNING_KEYCHAIN_PATH}
79+
rm -f ${APPLE_SIGNING_KEYCHAIN_PATH}
80+
81+
- uses: actions/upload-artifact@v3
82+
with:
83+
path: ./wheelhouse/*.whl
84+
85+
build_sdist:
86+
name: Build source distribution
87+
runs-on: ubuntu-latest
88+
steps:
89+
- uses: actions/checkout@v3
90+
91+
- name: Build sdist
92+
run: pipx run build --sdist
93+
94+
- uses: actions/upload-artifact@v3
95+
with:
96+
path: dist/*.tar.gz
97+
98+
upload_pypi:
99+
needs: [build_wheels, build_sdist]
100+
runs-on: ubuntu-latest
101+
environment: release
102+
steps:
103+
- uses: actions/download-artifact@v3
104+
with:
105+
# unpacks default artifact into dist/
106+
# if `name: artifact` is omitted, the action will create extra parent dir
107+
name: artifact
108+
path: dist
109+
110+
- uses: pypa/gh-action-pypi-publish@v1.5.0
111+
with:
112+
user: __token__
113+
# password: ${{ secrets.PYPI_TEST_API_TOKEN }}
114+
password: ${{ secrets.PYPI_API_TOKEN }}
115+
# uncomment for test
116+
# repository_url: https://test.pypi.org/legacy/

.github/workflows/test.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ name: test
22
on: [push]
33

44
env:
5-
# TODO: use a release (once available)
6-
LIBZIM_DL_VERSION: "2023-04-26"
5+
LIBZIM_DL_VERSION: "8.2.0"
76

87
jobs:
98
lint:

.github/workflows/wheels.yml

Lines changed: 5 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,19 @@
1-
name: Build and maybe upload to PyPI
1+
name: Build sdist and wheels
22

33
on:
4-
push:
54
pull_request:
6-
release:
7-
types:
8-
- published
5+
push:
6+
branches:
7+
- main
98

109
env:
11-
# LIBZIM_DL_VERSION: "8.2.0"
12-
LIBZIM_DL_VERSION: "2023-04-26"
10+
LIBZIM_DL_VERSION: "8.2.0"
1311
MACOSX_DEPLOYMENT_TARGET: "11.0"
1412
CIBW_ENVIRONMENT_PASS_LINUX: "LIBZIM_DL_VERSION"
15-
# APPLE_SIGNING_KEYCHAIN_PATH set in prepare keychain step
16-
APPLE_SIGNING_KEYCHAIN_PROFILE: "build-profile"
17-
APPLE_SIGNING_IDENTITY: "${{ secrets.APPLE_SIGNING_IDENTITY }}"
18-
SIGN_APPLE: "yes"
1913

2014

2115
jobs:
2216
build_wheels:
23-
environment: release
2417
name: Build wheels on ${{ matrix.os }}
2518
runs-on: ${{ matrix.os }}
2619
strategy:
@@ -36,51 +29,9 @@ jobs:
3629
with:
3730
platforms: all
3831

39-
- name: Prepare Apple Keychain for Signing
40-
if: matrix.os == 'macos-12'
41-
shell: bash
42-
run: |
43-
# store certificate on filesystem
44-
export CERTIFICATE="$(mktemp -d)/wmch-devid.p12"
45-
echo "${{ secrets.APPLE_SIGNING_CERTIFICATE }}" | base64 --decode -o $CERTIFICATE
46-
47-
# create a dedicated keychain
48-
export APPLE_SIGNING_KEYCHAIN_PATH="$(mktemp -d)/build.keychain"
49-
echo "APPLE_SIGNING_KEYCHAIN_PATH=${APPLE_SIGNING_KEYCHAIN_PATH}" >> "$GITHUB_ENV"
50-
security create-keychain -p mysecretpassword ${APPLE_SIGNING_KEYCHAIN_PATH}
51-
security default-keychain -s ${APPLE_SIGNING_KEYCHAIN_PATH}
52-
security unlock-keychain -p mysecretpassword ${APPLE_SIGNING_KEYCHAIN_PATH}
53-
54-
# import certificate into keychain then remove from filesystem
55-
security import ${CERTIFICATE} -k ${APPLE_SIGNING_KEYCHAIN_PATH} -P "${{ secrets.APPLE_SIGNING_P12_PASSWORD }}" -A
56-
rm $CERTIFICATE
57-
58-
# store signing credentials into the keychain
59-
security set-key-partition-list -S "apple-tool:,apple:" -s -k mysecretpassword ${APPLE_SIGNING_KEYCHAIN_PATH}
60-
security find-identity -v
61-
xcrun notarytool store-credentials \
62-
--apple-id "${{ secrets.APPLE_SIGNING_ALTOOL_USERNAME }}" \
63-
--password "${{ secrets.APPLE_SIGNING_ALTOOL_PASSWORD }}" \
64-
--team-id "${{ secrets.APPLE_SIGNING_TEAM }}" \
65-
--validate \
66-
--keychain ${APPLE_SIGNING_KEYCHAIN_PATH} \
67-
${APPLE_SIGNING_KEYCHAIN_PROFILE}
68-
69-
# disable auto-locking of keychain
70-
security set-keychain-settings ${APPLE_SIGNING_KEYCHAIN_PATH}
71-
security unlock-keychain -p mysecretpassword ${APPLE_SIGNING_KEYCHAIN_PATH}
72-
7332
- name: Build wheels
7433
uses: pypa/cibuildwheel@v2.12.1
7534

76-
- name: Cleanup Apple Keychain
77-
if: matrix.os == 'macos-12'
78-
shell: bash
79-
run: |
80-
security lock-keychain ${APPLE_SIGNING_KEYCHAIN_PATH}
81-
security delete-keychain ${APPLE_SIGNING_KEYCHAIN_PATH}
82-
rm -f ${APPLE_SIGNING_KEYCHAIN_PATH}
83-
8435
- uses: actions/upload-artifact@v3
8536
with:
8637
path: ./wheelhouse/*.whl
@@ -97,23 +48,3 @@ jobs:
9748
- uses: actions/upload-artifact@v3
9849
with:
9950
path: dist/*.tar.gz
100-
101-
upload_pypi:
102-
needs: [build_wheels, build_sdist]
103-
runs-on: ubuntu-latest
104-
if: github.event_name == 'release' && github.event.action == 'published'
105-
steps:
106-
- uses: actions/download-artifact@v3
107-
with:
108-
# unpacks default artifact into dist/
109-
# if `name: artifact` is omitted, the action will create extra parent dir
110-
name: artifact
111-
path: dist
112-
113-
- uses: pypa/gh-action-pypi-publish@v1.5.0
114-
with:
115-
user: __token__
116-
# password: ${{ secrets.PYPI_API_TOKEN }}
117-
password: ${{ secrets.PYPI_TEST_API_TOKEN }}
118-
# uncomment for test
119-
repository_url: https://test.pypi.org/legacy/

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Changed
1111

12-
- Revamped setup to create proper wheel and sdist out-of-the-box (`python3 -m build`)
12+
- Revamped setup to create proper wheels and sdist out-of-the-box (`python3 -m build`)
13+
- Build can now sign + notarize for macOS
14+
- Build can now create macOS universal wheels
15+
- Added cibuildwheel config
16+
- Build with (and target) libzim 8.2.0
1317

1418
## [3.0.0] - 2023-03-16
1519

setup.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929

3030
class Config:
31-
libzim_dl_version: str = os.getenv("LIBZIM_DL_VERSION", "8.1.1")
31+
libzim_dl_version: str = os.getenv("LIBZIM_DL_VERSION", "8.2.0")
3232
use_system_libzim: bool = bool(os.getenv("USE_SYSTEM_LIBZIM", False))
3333
download_libzim: bool = not bool(os.getenv("DONT_DOWNLOAD_LIBZIM", False))
3434

@@ -197,9 +197,6 @@ def _download_and_extract(self, filename: str) -> pathlib.Path:
197197
source_url = "http://download.openzim.org/release/libzim"
198198
if self.is_nightly:
199199
source_url = f"http://download.openzim.org/nightly/{self.libzim_dl_version}"
200-
# TODO: remove once merged
201-
if "bionic" in fpath.name:
202-
source_url = "https://tmp.kiwix.org/ci/libzim_bionic"
203200
url = f"{source_url}/{fpath.name}"
204201

205202
# download a local copy if none present

0 commit comments

Comments
 (0)