-
Notifications
You must be signed in to change notification settings - Fork 13
112 lines (94 loc) · 3.38 KB
/
build.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
109
110
111
112
# build.yml forked from github.com/Fangliding/v2rayNG
# thanks @Fangliding @nagi_ly
name: Build APK
on:
workflow_dispatch:
inputs:
XRAY_VERSION:
description: "Select Xray-core's version: main (latest commit) or latest (release version)."
required: true
type: choice
default: 'main'
options:
- main
- latest
env:
ALIAS: ${{ secrets.ALIAS }}
KEYPASSWORD: ${{ secrets.KEYPASSWORD }}
KEYSTOREPASSWORD: ${{ secrets.KEYSTOREPASSWORD }}
SIGNINGKEYBASE64: ${{ secrets.SIGNINGKEYBASE64 }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout v2rayNG repository
uses: actions/checkout@v4
with:
repository: '2dust/v2rayNG'
- name: Checkout AndroidLibXrayLite repository
uses: actions/checkout@v4
with:
repository: '2dust/AndroidLibXrayLite'
path: 'AndroidLibXrayLite'
- name: Checkout Xray-core repository
if: ${{ inputs.XRAY_VERSION == 'main' }}
uses: actions/checkout@v4
with:
repository: 'xtls/xray-core'
path: 'xray-core'
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Get Go version
run: |
echo "GO_VERSION=$(curl -s https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json | grep -oE '\"version\": \"[0-9]{1}.[0-9]{1,}(.[0-9]{1,})?\"' | head -1 | cut -d':' -f2 | sed 's/ //g; s/\"//g')" >> $GITHUB_ENV
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '${{ env.GO_VERSION }}'
cache: false
- name: Install gomobile
run: |
go install golang.org/x/mobile/cmd/gomobile@latest
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Setup Android
uses: android-actions/setup-android@v3
- name: Get xray short sha
if: ${{ inputs.XRAY_VERSION == 'main' }}
run: |
cd xray-core
echo "XRAY_SHA=@$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Build dependencies
run: |
cd AndroidLibXrayLite
sed -i "s/v2core.Version())/v2core.Version() + \"${{ env.XRAY_SHA }}\")/" libv2ray_main.go
go get github.com/xtls/xray-core@${{ inputs.XRAY_VERSION }}
gomobile init
go mod tidy -v
gomobile bind -v -androidapi 21 -ldflags='-s -w' ./
cp libv2ray.aar ../V2rayNG/app/libs/
- name: Build APK
run: |
cd V2rayNG
chmod 777 *
sed -i 's/org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8/org.gradle.jvmargs=-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8/' gradle.properties
./gradlew assembleRelease
- name: List APK files
run: |
find V2rayNG/app/build/outputs/apk/ -type f -exec du -h {} \;
- name: Sign APK files
uses: ilharp/sign-android-release@v1
with:
releaseDir: V2rayNG/app/build/outputs/apk/release/
keyAlias: ${{ env.ALIAS }}
keyPassword: ${{ env.KEYPASSWORD }}
keyStorePassword: ${{ env.KEYSTOREPASSWORD }}
signingKey: ${{ env.SIGNINGKEYBASE64 }}
buildToolsVersion: 33.0.2
- name: Upload APK files
uses: actions/upload-artifact@v4
with:
name: v2rayNG_arm64-v8a-signed
path: V2rayNG/app/build/outputs/apk/release/v2rayNG_*_arm64-v8a-signed.apk