Repository navigation
248 lines (243 loc) · 10.4 KB
/
Copy pathandroid-release.yml
File metadata and controls
248 lines (243 loc) · 10.4 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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
name: Android Preview release package
on:
workflow_dispatch:
inputs:
version:
description: Package version already present in the selected source
required: true
type: string
source_commit:
description: Exact 40-character source commit to rebuild without moving its release tag
required: true
type: string
workflow_call:
inputs:
version:
required: true
type: string
permissions:
contents: read
env:
PYTHONUTF8: "1"
RUST_TOOLCHAIN: "1.97.1"
CARGO_TERM_COLOR: always
SOURCE_COMMIT: ${{ inputs.source_commit || github.sha }}
jobs:
relay:
name: Embedded relay (${{ matrix.arch }})
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-24.04
arch: x86_64
target: x86_64-unknown-linux-musl
- runner: ubuntu-24.04-arm
arch: aarch64
target: aarch64-unknown-linux-musl
runs-on: ${{ matrix.runner }}
timeout-minutes: 45
env:
CARGO_BUILD_TARGET: ${{ matrix.target }}
CC: musl-gcc
RUSTFLAGS: -C linker=musl-gcc
steps:
- uses: actions/checkout@v4
with:
ref: ${{ env.SOURCE_COMMIT }}
- name: Verify the selected source commit
run: |
[[ "$SOURCE_COMMIT" =~ ^[0-9a-f]{40}$ ]]
test "$(git rev-parse HEAD)" = "$SOURCE_COMMIT"
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install native static-link tools
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends musl-tools
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
targets: ${{ matrix.target }}
- uses: ./.github/actions/rust-cache
id: rust-cache
with:
key: android-relay
target: target/${{ matrix.target }}/release
- name: Build and package same-source relay
env:
RELAY_ARCH: ${{ matrix.arch }}
RELAY_TARGET: ${{ matrix.target }}
run: |
cargo build --locked --release -p pebrel-mobile-link --features relay --bin pebrel-relay
python3 mobile/tools/package_native_relay.py \
--binary "target/$RELAY_TARGET/release/pebrel-relay" \
--output relay-assets --arch "$RELAY_ARCH" --commit "$SOURCE_COMMIT"
- name: Save compiled relay
if: ${{ steps.rust-cache.outputs.cache-hit != 'true' }}
uses: actions/cache/save@v4
with:
path: target/${{ matrix.target }}/release
key: ${{ steps.rust-cache.outputs.cache-key }}
- uses: actions/upload-artifact@v4
with:
name: android-relay-${{ matrix.arch }}
path: relay-assets
if-no-files-found: error
retention-days: 7
apk:
name: Android universal Preview APK
needs: relay
runs-on: ubuntu-24.04
timeout-minutes: 120
env:
PACKAGE_VERSION: ${{ inputs.version }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ env.SOURCE_COMMIT }}
- name: Verify the selected source commit
run: |
[[ "$SOURCE_COMMIT" =~ ^[0-9a-f]{40}$ ]]
test "$(git rev-parse HEAD)" = "$SOURCE_COMMIT"
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "17"
- uses: android-actions/setup-android@v3
with:
packages: 'platform-tools platforms;android-35 build-tools;35.0.0 ndk;27.2.12479018 cmake;3.22.1'
- uses: gradle/actions/setup-gradle@v4
with:
gradle-version: "8.11.1"
cache-read-only: false
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
targets: aarch64-linux-android,x86_64-linux-android
- name: Select the pinned NDK
run: echo "ANDROID_NDK_HOME=$ANDROID_HOME/ndk/27.2.12479018" >> "$GITHUB_ENV"
- uses: ./.github/actions/rust-cache
id: rust-cache
with:
key: android-ssh
target: |
mobile/ssh/target/aarch64-linux-android/release
mobile/ssh/target/x86_64-linux-android/release
extra-key: ndk-27.2.12479018
- uses: actions/cache@v4
with:
path: 'mobile/android/ghostty/build/upstream'
key: android-vt-linux-${{ hashFiles('mobile/android/ghostty/UPSTREAM.json', 'mobile/tools/build_ghostty.py') }}
- name: Build both Android native ABIs
env:
# 恢复旧标签时也隔离父仓库;旧版构建脚本会继承此环境。
GIT_CEILING_DIRECTORIES: ${{ github.workspace }}/mobile/android
run: |
python3 mobile/tools/build_ghostty.py
python3 mobile/tools/build_russh.py
- name: Save compiled Android transport
if: ${{ steps.rust-cache.outputs.cache-hit != 'true' }}
uses: actions/cache/save@v4
with:
path: |
mobile/ssh/target/aarch64-linux-android/release
mobile/ssh/target/x86_64-linux-android/release
key: ${{ steps.rust-cache.outputs.cache-key }}
- uses: actions/download-artifact@v4
with:
pattern: android-relay-*
merge-multiple: true
path: mobile/android/app/build/generated/nativeRelayAssets/native-relay
- name: Run unit tests and build the optimized Preview variant
run: |
gradle --no-daemon -p mobile/android \
:app:testDebugUnitTest :app:lintPreview \
:app:assemblePreview :app:assemblePreviewAndroidTest
- name: Prepare the isolated OpenSSH fixture
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends openssh-server
sudo useradd --create-home --shell /bin/bash pebreltest
echo 'pebreltest:pebrel-test-only' | sudo chpasswd
mkdir -p "$RUNNER_TEMP/android-ssh"
ssh-keygen -t ed25519 -N '' -f "$RUNNER_TEMP/android-ssh/host_key"
sudo mkdir -p /run/sshd
cat > "$RUNNER_TEMP/android-ssh/sshd_config" <<EOF
Port 2222
ListenAddress 127.0.0.1
HostKey $RUNNER_TEMP/android-ssh/host_key
PidFile $RUNNER_TEMP/android-ssh/sshd.pid
PasswordAuthentication yes
KbdInteractiveAuthentication no
UsePAM no
PermitRootLogin no
AllowUsers pebreltest
Subsystem sftp internal-sftp
EOF
sudo /usr/sbin/sshd -f "$RUNNER_TEMP/android-ssh/sshd_config" -E "$RUNNER_TEMP/android-ssh/sshd.log"
sudo -u pebreltest mkdir /home/pebreltest/paging
sudo -u pebreltest bash -c 'for n in $(seq 1 300); do touch "/home/pebreltest/paging/file-$n"; done'
echo "SSH_FINGERPRINT=$(ssh-keygen -lf "$RUNNER_TEMP/android-ssh/host_key.pub" -E sha256 | awk '{print $2}')" >> "$GITHUB_ENV"
- name: Enable emulator acceleration
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Test native terminal, SSH and SFTP in the Preview APK
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 35
target: google_apis
arch: x86_64
disable-animations: true
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
script: |
gradle --no-daemon -p mobile/android :app:installPreview
# 触摸验收从已授权的本地终端开始;全新模拟器的权限弹窗不应截获选词和复制手势。
adb shell appops set --uid io.github.kuddev.pebrel.mobile.preview MANAGE_EXTERNAL_STORAGE allow
adb shell pm grant io.github.kuddev.pebrel.mobile.preview android.permission.POST_NOTIFICATIONS
gradle --no-daemon -p mobile/android :app:connectedPreviewAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=io.github.kuddev.pebrel.mobile.GhosttyEngineTest,io.github.kuddev.pebrel.mobile.SshIntegrationTest#privateKeysAuthenticateWithPassphrasesAndNeverFallBackToPassword,io.github.kuddev.pebrel.mobile.SshIntegrationTest#sftpRoundTripPagingAndCancellationKeepTheRealShellUsable,io.github.kuddev.pebrel.mobile.SshIntegrationTest#realPasswordShellStreamsOutputThroughGhostty,io.github.kuddev.pebrel.mobile.SshIntegrationTest#wrongPasswordReportsAuthenticationAndWipesSecret,io.github.kuddev.pebrel.mobile.SshIntegrationTest#changedHostKeyNeverReachesAuthentication,io.github.kuddev.pebrel.mobile.SshIntegrationTest#declinedTrustNeverAuthenticates,io.github.kuddev.pebrel.mobile.SshIntegrationTest#execKeepsStderrOutOfRpcStdoutAndPreservesExitCode -Pandroid.testInstrumentationRunnerArguments.sshFingerprint="$SSH_FINGERPRINT" -Pandroid.testInstrumentationRunnerArguments.sftpFixtureDirectory=paging
- name: Verify signing, identity, native payload and test results
run: |
python3 scripts/android_release.py --version "$PACKAGE_VERSION" --commit "$SOURCE_COMMIT" \
--sdk "$ANDROID_HOME" --output dist --report android-evidence/android-report.json
- name: Upload Android Preview asset
uses: actions/upload-artifact@v4
with:
compression-level: 0
name: stable-package-android
path: |
dist/*.apk
dist/*-relay-manual.tar.gz
if-no-files-found: error
retention-days: 14
- name: Upload Android release evidence
if: always()
uses: actions/upload-artifact@v4
with:
name: stable-evidence-android
path: android-evidence/android-report.json
if-no-files-found: warn
retention-days: 14
- name: Upload Android diagnostic reports
if: always()
uses: actions/upload-artifact@v4
with:
name: android-test-reports
path: |
mobile/android/app/build/reports
mobile/android/app/build/test-results
mobile/android/app/build/outputs/androidTest-results
if-no-files-found: warn
retention-days: 14
- name: Stop the test SSH service
if: always()
run: |
if [[ -f "$RUNNER_TEMP/android-ssh/sshd.pid" ]]; then
sudo kill "$(cat "$RUNNER_TEMP/android-ssh/sshd.pid")"
fi