-
-
Notifications
You must be signed in to change notification settings - Fork 635
215 lines (189 loc) · 7.63 KB
/
Copy pathcli-build.yml
File metadata and controls
215 lines (189 loc) · 7.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
name: CLI Build Smoke Test
on:
workflow_dispatch:
push:
branches: [ 'feature/cli-toolchain' ]
pull_request:
paths:
- 'webview/cli/**'
- 'webview/bundler/**'
- '.github/workflows/cli-build.yml'
- 'pyproject.toml'
jobs:
build:
name: ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: deb
artifact_glob: dist/installers/*.deb
- os: windows-latest
target: msi
artifact_glob: dist/installers/*.msi
- os: macos-latest
target: dmg
artifact_glob: dist/installers/*.dmg
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install pywebview2[cli]
run: |
python -m pip install --upgrade pip
pip install -e ".[cli]"
- name: Install WiX Toolset (Windows)
if: runner.os == 'Windows'
# Pinned to 5.x: WiX v6+ requires accepting the Open Source
# Maintenance Fee EULA before the CLI will run non-interactively.
# v5's CLI still targets the same v4 .wxs schema our template uses.
run: dotnet tool install --global wix --version 5.0.2
- name: Scaffold test app
shell: bash
run: |
pywebview2 init testapp --name "CLI Smoke Test" --identifier com.example.clismoketest --yes
- name: Set bundle target
shell: python
run: |
import json
path = 'testapp/pywebview2.conf.json'
with open(path) as f:
config = json.load(f)
config['bundle']['targets'] = ['${{ matrix.target }}']
with open(path, 'w') as f:
json.dump(config, f, indent=2)
- name: Run doctor
working-directory: testapp
run: pywebview2 doctor
continue-on-error: true
- name: Build
working-directory: testapp
run: pywebview2 build
- name: Verify installer artifact was produced
shell: bash
run: |
shopt -s nullglob
files=(testapp/${{ matrix.artifact_glob }})
if [ ${#files[@]} -eq 0 ]; then
echo "No installer artifact matched testapp/${{ matrix.artifact_glob }}"
find testapp/dist -type f
exit 1
fi
echo "Found installer artifact(s):"
printf '%s\n' "${files[@]}"
- name: Upload installer artifact
uses: actions/upload-artifact@v4
with:
name: installer-${{ matrix.os }}
path: testapp/${{ matrix.artifact_glob }}
android:
name: android
# Pinned to 22.04: python-for-android's libffi recipe uses an old
# configure.ac that fails under 24.04's newer autotools ("configure.ac:
# error: possibly undefined macro: LT_SYS_SYMBOL_USCORE" during
# autoreconf) -- a known python-for-android/Ubuntu-24.04 incompatibility.
runs-on: ubuntu-22.04
# buildozer/python-for-android compiles native recipes from scratch on a
# cold cache -- this routinely takes far longer than the desktop
# installer jobs above, so it's kept as its own decoupled job rather
# than folded into the fast desktop matrix.
timeout-minutes: 45
# python-for-android's own dependency-install step runs an unconditional
# `pip install -U pip` inside a fresh venv it creates. That self-upgrade
# replaces pip's own files while pip is still executing, which corrupts
# the running process's imports -- reproduced with two different target
# versions, each producing a different broken-import error, so the
# hazard is the live self-replace itself, not one bad release.
# PIP_CONSTRAINT forces every pip invocation in this job -- including
# p4a's internal self-upgrade -- to resolve "pip" to the version the
# venv already has, turning that upgrade into a no-op.
env:
PIP_CONSTRAINT: ${{ github.workspace }}/pip-constraints.txt
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
# buildozer/python-for-android tooling is more battle-tested on
# 3.11 than 3.12 at the time of writing.
python-version: '3.11'
- name: Set up Java 17
# The runner ships multiple JDKs; without this, gradlew resolved
# JAVA_HOME to Java 11 and failed: "Android Gradle plugin requires
# Java 17 to run. You are currently using Java 11." Found via a
# live run -- setup-java pins JAVA_HOME reliably instead of relying
# on whichever JDK happens to be selected by default.
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '17'
- name: Write pip constraint
# Pinned to whatever `python -m venv` already bundles via ensurepip
# for this Python version (confirmed via a live run: "Successfully
# installed pip-24.0" right after venv creation), not just "a known
# -good version" -- constraining to a *different* version (26.1.2)
# still triggered a real uninstall/reinstall of the running pip
# (visible as "Attempting uninstall: pip / Found existing
# installation: pip 24.0"), and produced a different broken-import
# failure each time, pointing at pip replacing its own files while
# executing as the actual hazard, not any one bad release. Matching
# the already-installed version makes p4a's `pip install -U pip`
# a no-op instead.
run: echo "pip==24.0" > pip-constraints.txt
- name: Install system build dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
git zip unzip openjdk-17-jdk autoconf libtool pkg-config \
zlib1g-dev libncurses5-dev libncursesw5-dev cmake libffi-dev libssl-dev
- name: Install pywebview2[cli] and buildozer
# No `pip install --upgrade pip` here: PIP_CONSTRAINT is job-scoped
# and pins pip==24.0, so an explicit upgrade would just fight the
# constraint for no benefit -- the pip actions/setup-python ships is
# already sufficient for these installs.
run: |
pip install -e ".[cli]"
pip install buildozer cython
- name: Scaffold test app
run: pywebview2 init testapp --name "CLI Smoke Test" --identifier com.example.clismoketest --yes
- name: Set bundle target
shell: python
run: |
import json
path = 'testapp/pywebview2.conf.json'
with open(path) as f:
config = json.load(f)
config['bundle']['targets'] = ['android']
with open(path, 'w') as f:
json.dump(config, f, indent=2)
- name: Run doctor
working-directory: testapp
run: pywebview2 doctor
continue-on-error: true
- name: Build android
working-directory: testapp
run: pywebview2 build --target android
- name: Verify apk artifact was produced
shell: bash
run: |
shopt -s nullglob
apks=(testapp/bin/*.apk)
if [ ${#apks[@]} -eq 0 ]; then
echo "No .apk found in testapp/bin"
find testapp/bin -type f 2>/dev/null
exit 1
fi
echo "Found .apk artifact(s):"
printf '%s\n' "${apks[@]}"
- name: Upload apk artifact
uses: actions/upload-artifact@v4
with:
name: installer-android
path: testapp/bin/*.apk