-
Notifications
You must be signed in to change notification settings - Fork 80
129 lines (113 loc) · 4.67 KB
/
Copy pathbuild.yml
File metadata and controls
129 lines (113 loc) · 4.67 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
name: Build Selene-TV
# 推送形如 v1.0.0 的 tag 时触发:拉取私有源码仓库 → 构建 release APK
# (arm64-v8a / armeabi-v7a 分包)→ 上传到本仓库的 Release。
on:
push:
tags:
- 'v*'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
jobs:
build:
name: Build & Release
runs-on: ubuntu-latest
env:
# 源码仓库(私有),通过 PULL_TOKEN 拉取
SOURCE_REPO: github.com/MoonTechLab/Selene-TV-source
steps:
- name: Clone source repository
run: |
git clone "https://${{ secrets.PULL_TOKEN }}@${SOURCE_REPO}.git" .
echo "Cloned $(git rev-parse --short HEAD) from ${SOURCE_REPO}"
- name: Resolve version
id: ver
run: |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
VERSION="${GITHUB_REF#refs/tags/}"
else
VERSION="$(grep -m1 'versionName' app/build.gradle.kts | sed -E 's/.*"([^"]+)".*/\1/')"
fi
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
echo "Building version: ${VERSION}"
- name: Set up JDK 17
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: '17'
- name: Set up Android SDK
uses: android-actions/setup-android@v3
- name: Cache Gradle
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Write signing configuration
run: |
# key.jks 已随源码仓库提交 → 默认即用它(稳定签名)。
# 若设置了 SIGNING_KEY(base64 的 keystore),则覆盖仓库内的 key.jks。
if [ -n "${{ secrets.SIGNING_KEY }}" ]; then
echo "${{ secrets.SIGNING_KEY }}" | base64 --decode > key.jks
echo "Overrode key.jks from SIGNING_KEY secret"
fi
cat > key.properties <<EOF
storeFile=key.jks
storePassword=${{ secrets.KEY_STORE_PASSWORD }}
keyAlias=${{ secrets.ALIAS }}
keyPassword=${{ secrets.KEY_PASSWORD }}
EOF
- name: Build release APKs
run: |
chmod +x gradlew
./gradlew assembleRelease --no-daemon --stacktrace
- name: Collect & rename APKs
run: |
VERSION="${{ steps.ver.outputs.version }}"
OUT="app/build/outputs/apk/release"
mkdir -p dist
# armv8 = arm64-v8a,armv7a = armeabi-v7a
cp "${OUT}/app-arm64-v8a-release.apk" "dist/SeleneTV-${VERSION}-arm64-v8a.apk"
cp "${OUT}/app-armeabi-v7a-release.apk" "dist/SeleneTV-${VERSION}-armeabi-v7a.apk"
ls -lh dist
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: selene-tv-apks
path: dist/*.apk
if-no-files-found: error
- name: Create or update GitHub Release
if: startsWith(github.ref, 'refs/tags/')
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# 上一步把源码仓库 clone 到了当前目录,gh 会据此把 release 误判到 Selene-TV-source;
# 显式锁定到本工作流所在仓库(MoonTechLab/Selene-TV)。
GH_REPO: ${{ github.repository }}
VERSION: ${{ steps.ver.outputs.version }}
run: |
# 该 tag 已存在 release → 仅更新附件(--clobber 覆盖同名包),保留原有标题与说明,不新建、不改 log;
# 不存在 → 新建 release 并写入架构说明表。
if gh release view "${VERSION}" >/dev/null 2>&1; then
echo "Release ${VERSION} exists — updating assets only (title/notes untouched)"
gh release upload "${VERSION}" dist/*.apk --clobber
else
echo "Release ${VERSION} not found — creating"
cat > notes.md <<'NOTES'
## Selene-TV __VERSION__
| 安装包 | 架构 | 适用设备 |
|--------|------|----------|
| `SeleneTV-__VERSION__-arm64-v8a.apk` | armv8 (arm64-v8a) | 64 位 ARM,主流 Android TV / 电视盒子 |
| `SeleneTV-__VERSION__-armeabi-v7a.apk` | armv7a (armeabi-v7a) | 32 位 ARM,较老设备 |
不确定架构时优先选 **arm64-v8a**。
NOTES
sed -i "s/__VERSION__/${VERSION}/g" notes.md
gh release create "${VERSION}" dist/*.apk \
--title "Selene-TV ${VERSION}" \
--notes-file notes.md
fi