Repository navigation
79 lines (68 loc) · 2.75 KB
/
Copy pathrelease.yml
File metadata and controls
79 lines (68 loc) · 2.75 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
name: Release
# 打 tag(如 v1.0.0)即触发:构建签名 release APK 并发布到 GitHub Releases
on:
push:
tags: [ 'v*' ]
workflow_dispatch:
permissions:
contents: write # 创建 Release 需要写权限
# Opt the still-Node-20 actions (setup-android, action-gh-release) onto Node 24
# now, ahead of the 2026-06-16 forced migration.
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up JDK 17
uses: actions/setup-java@v5
with:
java-version: '17'
distribution: 'temurin'
cache: gradle
- name: Setup Android SDK
uses: android-actions/setup-android@v3
# 版本号从 tag 自动算出,无需改 build.gradle:
# v1.2.3 -> versionName=1.2.3, versionCode=1*10000+2*100+3=10203
- name: Derive version from tag
run: |
TAG="${GITHUB_REF_NAME}" # 例:v1.2.3
VNAME="${TAG#v}" # 1.2.3
if ! echo "$VNAME" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "::error::tag 必须是 vMAJOR.MINOR.PATCH(如 v1.2.3),当前为 '$TAG'"
exit 1
fi
IFS=. read -r MA MI PA <<< "$VNAME"
VCODE=$((MA*10000 + MI*100 + PA))
echo "VERSION_NAME=$VNAME" >> "$GITHUB_ENV"
echo "VERSION_CODE=$VCODE" >> "$GITHUB_ENV"
echo "versionName=$VNAME versionCode=$VCODE"
- name: Decode keystore
env:
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
run: echo "$KEYSTORE_BASE64" | base64 -d > "$RUNNER_TEMP/release.jks"
- name: Build signed release APK
env:
KEYSTORE_FILE: ${{ runner.temp }}/release.jks
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
run: |
chmod +x gradlew
# APK = GitHub 直装;AAB = 上传 Google Play
./gradlew assembleRelease bundleRelease --no-daemon
- name: Rename artifacts
run: |
cp app/build/outputs/apk/release/app-release.apk "NetPulse-${{ github.ref_name }}.apk"
cp app/build/outputs/bundle/release/app-release.aab "NetPulse-${{ github.ref_name }}.aab"
# 固定名副本:官网可用 /releases/latest/download/NetPulse.apk 直连下载最新版
cp app/build/outputs/apk/release/app-release.apk "NetPulse.apk"
- name: Publish GitHub Release
uses: softprops/action-gh-release@v2
with:
files: |
NetPulse-${{ github.ref_name }}.apk
NetPulse-${{ github.ref_name }}.aab
NetPulse.apk
generate_release_notes: true