Repository navigation
162 lines (141 loc) · 5.38 KB
/
Copy pathbuild.yml
File metadata and controls
162 lines (141 loc) · 5.38 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
name: "Build"
on:
workflow_dispatch:
pull_request:
branches: ["main"]
release:
types:
- published
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 1
submodules: true
- name: Explicit Submodule Update
run: |
git submodule sync --recursive
git submodule update --init --recursive
- name: Set up Java 21
uses: actions/setup-java@v6
with:
distribution: 'temurin'
java-version: '21'
cache: 'gradle'
- name: Set up Android SDK
id: setup_sdk
uses: android-actions/setup-android@v4
with:
packages: 'platform-tools'
- name: Read Versions
run: |
echo "XRAY_VERSION=$(grep 'XRAY_CORE_VERSION' version.properties | cut -d '=' -f 2)" >> $GITHUB_ENV
echo "GO_VERSION=$(grep 'GO_VERSION' version.properties | cut -d '=' -f 2)" >> $GITHUB_ENV
echo "NDK_VERSION=$(grep '^NDK_VERSION=' version.properties | cut -d '=' -f 2 | tr -d '\r')" >> $GITHUB_ENV
- name: Install configured Android NDK
run: |
set -euo pipefail
sdk_root="${ANDROID_HOME:-${ANDROID_SDK_ROOT:-}}"
if [[ -z "$sdk_root" || ! "$NDK_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo '::error::Android SDK root or NDK_VERSION is invalid.'
exit 1
fi
sdkmanager --sdk_root="$sdk_root" --install "ndk;$NDK_VERSION" --channel=0
ndk_dir="$sdk_root/ndk/$NDK_VERSION"
installed_version=$(sed -n 's/^Pkg\.Revision[[:space:]]*=[[:space:]]*//p' "$ndk_dir/source.properties" | tr -d '\r')
if [[ "$installed_version" != "$NDK_VERSION" ]]; then
echo '::error::Installed NDK revision does not match NDK_VERSION.'
exit 1
fi
test -x "$ndk_dir/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang"
printf 'XRAY_NDK_HOME=%s\n' "$ndk_dir" >> "$GITHUB_ENV"
- name: Set up Go
uses: actions/setup-go@v7
with:
go-version: ${{ env.GO_VERSION }}
cache: false
- name: Download Rules Files
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
geodata_repo=XTLS/Xray-rules-dat
geodata_tag=$(gh api "repos/$geodata_repo/releases/latest" --jq '.tag_name')
if [[ -z "$geodata_tag" || "$geodata_tag" == null ]]; then
echo '::error::Could not determine the latest Xray geodata release.'
exit 1
fi
geodata_dir=$(mktemp -d "$RUNNER_TEMP/xray-geodata.XXXXXX")
gh release download "$geodata_tag" --repo "$geodata_repo" \
--pattern geoip-lite.dat --pattern geoip-lite.dat.sha256sum \
--pattern geosite.dat --pattern geosite.dat.sha256sum \
--dir "$geodata_dir"
(
cd "$geodata_dir"
sha256sum --check geoip-lite.dat.sha256sum geosite.dat.sha256sum
)
mkdir -p app/src/main/assets
install -m 644 "$geodata_dir/geoip-lite.dat" app/src/main/assets/geoip.dat
install -m 644 "$geodata_dir/geosite.dat" app/src/main/assets/geosite.dat
echo "Bundled Xray geodata from $geodata_repo@$geodata_tag (GeoIP lite and GeoSite)."
- name: Build Xray-core from Source
run: |
# Clone Xray-core source and checkout tag
git clone https://github.com/XTLS/Xray-core.git
cd Xray-core
git checkout ${{ env.XRAY_VERSION }}
COMMID=$(git rev-parse HEAD | cut -c 1-7)
# Set common environment variables
export GOOS=android
export CGO_ENABLED=1
# Build for arm64-v8a
echo "Building for arm64-v8a..."
export GOARCH=arm64
export CC="$XRAY_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang"
go build -o xray -trimpath -buildvcs=false -ldflags="-X github.com/xtls/xray-core/core.build=${COMMID} -s -w -buildid= -checklinkname=0" -v ./main
mkdir -p ../app/src/main/jniLibs/arm64-v8a
mv xray ../app/src/main/jniLibs/arm64-v8a/libxray.so
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Build Release APK
run: ./gradlew assembleRelease
- name: Find and Copy APKs
run: |
mkdir -p apks
find app/build/outputs/apk/release -name "*.apk" -exec cp {} apks/ \;
- name: Upload Artifacts
uses: actions/upload-artifact@v7
with:
name: simplexray-apks
path: apks/
if-no-files-found: error
retention-days: 1
release:
name: Release
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'release'
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Download artifacts
uses: actions/download-artifact@v8
with:
path: release
pattern: "simplexray-*"
merge-multiple: true
- name: Upload artifacts to Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
for i in release/simplexray-*; do
gh release upload ${{ github.event.release.tag_name }} $i
done