-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (90 loc) · 3.08 KB
/
S03_debug_console.yml
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
name: S03_debug_console Build APK
on:
workflow_dispatch: {}
push:
tags:
- 'v*.*.*'
permissions:
contents: write
actions: read
jobs:
build:
name: S03_debug_console Build APK
runs-on: ubuntu-latest
env:
dir_name: "S03_调试与控制台_全中文注释"
apk_name: "S03_debug_console"
steps:
# Step 0: 测试环境变量
- name: Use variable from environment
run: |
echo "文件夹名:$dir_name"
echo "apk文件名:$apk_name"
- name: Get branch name
id: branch-name
uses: tj-actions/[email protected]
- name: Print branch
run: |
echo "Running on default: ${{ steps.branch-name.outputs.current_branch }}"
# Step 1: Checkout the repository
- name: Checkout Repository
uses: actions/checkout@v3
# Step 2: Set up JDK 17
- name: set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'dragonwell'
java-version: '17'
# Step 3: Cache Gradle dependencies
- name: Cache Gradle dependencies
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
# Step 4: Grant execute permission for Gradlew
- name: Grant execute permission for gradlew
run: |
cd $dir_name
chmod +x gradlew
# Step 6: Build the APK
- name: Build APK
run: |
cd $dir_name
./gradlew assembleRelease -PkeystorePath=${{ github.workspace }}/keystore.jks
env:
JAVA_HOME: /opt/hostedtoolcache/Java_Dragonwell_jdk/17.0.12-7/x64
NOTIFY_ME_KEYSTORE_PATH: ${{ github.workspace }}/keystore.jks
NOTIFY_ME_KEY_ALIAS: ${{ secrets.NOTIFY_ME_KEY_ALIAS }}
NOTIFY_ME_KEY_PASSWORD: ${{ secrets.NOTIFY_ME_KEY_PASSWORD }}
NOTIFY_ME_KEYSTORE_PASSWORD: ${{ secrets.NOTIFY_ME_KEYSTORE_PASSWORD }}
# Step 7: Find the generated APK and rename it with the tag name
- name: Find and Rename APK
run: |
cd $dir_name
APK_PATH=$(find app/build/outputs/apk/ -name "*.apk" | head -n 1)
if [ -z "$APK_PATH" ]; then
echo "APK not found"
exit 1
fi
mv "$APK_PATH" "app/build/outputs/apk/release/${apk_name}.apk"
# Step 8: Upload APK to GitHub Actions Artifacts (Optional)
- name: Upload APK Artifact
if: success()
uses: actions/upload-artifact@v3
with:
name: ${{env.apk_name}}.apk
path: ${{env.dir_name}}/app/build/outputs/apk/release/${{env.apk_name}}.apk
if-no-files-found: warn
# Step 10: Upload APK to Release
- name: Upload APK to Release
if: success()
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{env.dir_name}}/app/build/outputs/apk/release/${{env.apk_name}}.apk
asset_name: ${{env.apk_name}}.apk
tag: ${{ github.ref }}