-
Notifications
You must be signed in to change notification settings - Fork 5.9k
101 lines (86 loc) · 3.11 KB
/
android-tv-apk.yml
File metadata and controls
101 lines (86 loc) · 3.11 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
name: Android TV APK
on:
pull_request:
paths:
- "android-tv/**"
- ".github/workflows/android-tv-apk.yml"
push:
paths:
- "android-tv/**"
- ".github/workflows/android-tv-apk.yml"
workflow_dispatch:
inputs:
release_tag:
description: "Optional release tag used to publish the built APK"
required: false
type: string
release_title:
description: "Optional release title"
required: false
type: string
kvideo_url:
description: "Optional default KVideo URL baked into the APK"
required: false
type: string
permissions:
contents: write
jobs:
build_android_tv_apk:
runs-on: ubuntu-latest
env:
KVIDEO_URL: ${{ github.event_name == 'workflow_dispatch' && inputs.kvideo_url || '' }}
defaults:
run:
working-directory: android-tv
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Java 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "17"
cache: gradle
- name: Set up Android SDK
uses: android-actions/setup-android@v3
- name: Install Android SDK packages
run: sdkmanager "platforms;android-34" "build-tools;34.0.0"
- name: Make Gradle wrapper executable
run: chmod +x ./gradlew
- name: Build debug APK
run: ./gradlew --no-daemon assembleDebug -PkvideoUrl="$KVIDEO_URL"
- name: Upload APK artifact
uses: actions/upload-artifact@v4
with:
name: kvideo-android-tv-apk
path: android-tv/app/build/outputs/apk/debug/app-debug.apk
if-no-files-found: error
- name: Publish GitHub release
if: ${{ github.event_name == 'workflow_dispatch' && inputs.release_tag != '' }}
working-directory: .
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: ${{ inputs.release_tag }}
RELEASE_TITLE: ${{ inputs.release_title }}
run: |
release_notes="$(mktemp)"
effective_title="${RELEASE_TITLE:-Android TV APK ${RELEASE_TAG}}"
default_url_text="${KVIDEO_URL:-未预置,首次启动时手动填写}"
cat >"$release_notes" <<EOF
预构建的 Android TV APK。
使用方式:
1. 下载并侧载安装 APK
2. 首次启动时输入你的 KVideo 地址
3. 保存后即可直接进入
构建提交:$GITHUB_SHA
默认地址:$default_url_text
EOF
if gh release view "$RELEASE_TAG" >/dev/null 2>&1; then
gh release upload "$RELEASE_TAG" "android-tv/app/build/outputs/apk/debug/app-debug.apk#KVideo-AndroidTV.apk" --clobber
gh release edit "$RELEASE_TAG" --title "$effective_title" --notes-file "$release_notes"
else
gh release create "$RELEASE_TAG" "android-tv/app/build/outputs/apk/debug/app-debug.apk#KVideo-AndroidTV.apk" \
--title "$effective_title" \
--notes-file "$release_notes" \
--target "$GITHUB_SHA"
fi