forked from ppy/osu
-
Notifications
You must be signed in to change notification settings - Fork 0
165 lines (147 loc) · 6.31 KB
/
Copy pathrelease.yml
File metadata and controls
165 lines (147 loc) · 6.31 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
163
164
165
name: Build Android APK
on:
push:
tags:
- '*.*.*'
- '!*-*'
workflow_dispatch:
jobs:
build-android:
name: Build Android APK
runs-on: ubuntu-latest
timeout-minutes: 60
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v6
with:
submodules: recursive
- name: Setup JDK 17
uses: actions/setup-java@v5
with:
distribution: microsoft
java-version: 17
- name: Install .NET 10.0.x
uses: actions/setup-dotnet@v5
with:
dotnet-version: "10.0.x"
- name: Install .NET Android workload
run: dotnet workload install android
- name: Ensure Android NDK and CMake are available
run: |
# The ubuntu-latest runner has $ANDROID_HOME pre-installed.
# sdkmanager is not on PATH; use the full path.
SDKMANAGER="$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager"
# Install latest stable NDK (r29) + CMake.
yes | "$SDKMANAGER" --licenses > /dev/null 2>&1 || true
"$SDKMANAGER" --install "ndk;29.0.14206865" "cmake;3.22.1" > /dev/null 2>&1
- name: Build native library (libosu_native.so)
run: |
NDK_HOME="$ANDROID_HOME/ndk/29.0.14206865"
CMAKE_BIN="$ANDROID_HOME/cmake/3.22.1/bin/cmake"
# Only build arm64 and arm32. x86 removed to reduce APK size —
# modern emulators use x86_64 or ARM translation.
for ABI in arm64-v8a armeabi-v7a; do
echo "::group::Building osu_native for $ABI"
"$CMAKE_BIN" -B "build-native/$ABI" -S osu.Android/Native \
-DCMAKE_TOOLCHAIN_FILE="$NDK_HOME/build/cmake/android.toolchain.cmake" \
-DANDROID_ABI="$ABI" \
-DANDROID_PLATFORM=android-33 \
-DCMAKE_BUILD_TYPE=Release
"$CMAKE_BIN" --build "build-native/$ABI" --config Release -j "$(nproc)"
mkdir -p "osu.Android/libs/$ABI"
cp "build-native/$ABI/libosu_native.so" "osu.Android/libs/$ABI/"
echo "::endgroup::"
done
echo "Native libraries built successfully:"
find osu.Android/libs -name "*.so" -exec ls -lh {} \;
- name: Decode keystore
id: keystore
run: |
if [ -n "$KEYSTORE_BASE64" ]; then
echo "$KEYSTORE_BASE64" | base64 --decode > "${{ github.workspace }}/osu.Android/osu.keystore"
echo "has_keystore=true" >> "$GITHUB_OUTPUT"
else
echo "has_keystore=false" >> "$GITHUB_OUTPUT"
fi
env:
KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
- name: Set version
id: version
run: |
REF="${{ github.ref_name }}"
if [[ "$REF" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "version=$REF" >> "$GITHUB_OUTPUT"
else
echo "version=0.0.0" >> "$GITHUB_OUTPUT"
fi
# Always build Release for full optimization (trimming, AOT, compression).
# When a keystore is available we sign with it; otherwise the SDK produces
# a debug-signed Release APK that can be sideloaded for testing.
- name: Build Android APK (signed)
if: steps.keystore.outputs.has_keystore == 'true'
env:
ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_SIGNING_KEY_ALIAS }}
ANDROID_KEY_PASS: ${{ secrets.ANDROID_SIGNING_KEY_PASSWORD }}
ANDROID_STORE_PASS: ${{ secrets.ANDROID_SIGNING_STORE_PASSWORD }}
run: >
dotnet publish -c Release
osu.Android/osu.Android.csproj
-f net10.0-android
-p:Version="${{ steps.version.outputs.version }}"
-p:ApplicationDisplayVersion="${{ steps.version.outputs.version }}"
-p:ApplicationVersion="${{ github.run_number }}"
-p:AndroidKeyStore=true
-p:AndroidSigningKeyStore="${{ github.workspace }}/osu.Android/osu.keystore"
-p:AndroidSigningKeyAlias="$ANDROID_KEY_ALIAS"
-p:AndroidSigningKeyPass="$ANDROID_KEY_PASS"
-p:AndroidSigningStorePass="$ANDROID_STORE_PASS"
- name: Build Android APK (unsigned Release)
if: steps.keystore.outputs.has_keystore != 'true'
run: >
dotnet publish -c Release
osu.Android/osu.Android.csproj
-f net10.0-android
-p:Version="${{ steps.version.outputs.version }}"
-p:ApplicationDisplayVersion="${{ steps.version.outputs.version }}"
-p:ApplicationVersion="${{ github.run_number }}"
- name: Find APK
id: find_apk
run: |
# Both paths build Release. Signed builds produce *-Signed.apk; unsigned
# builds produce the base APK name. Search publish dir first, then fallback.
if [ "${{ steps.keystore.outputs.has_keystore }}" == "true" ]; then
APK=$(find "osu.Android/bin/Release/net10.0-android/publish" -maxdepth 1 -name "*-Signed.apk" 2>/dev/null | head -1)
if [ -z "$APK" ]; then
APK=$(find "osu.Android/bin/Release" -name "*-Signed.apk" | head -1)
fi
else
APK=$(find "osu.Android/bin/Release/net10.0-android/publish" -maxdepth 1 -name "*.apk" 2>/dev/null | head -1)
if [ -z "$APK" ]; then
APK=$(find "osu.Android/bin/Release" -name "*.apk" | head -1)
fi
fi
if [ -z "$APK" ]; then
echo "::error::Failed to locate APK. Listing bin directory:"
find osu.Android/bin -name "*.apk" -o -name "*.aab" 2>/dev/null || true
exit 1
fi
APK_SIZE=$(stat -c %s "$APK" 2>/dev/null || stat -f %z "$APK" 2>/dev/null || wc -c < "$APK")
APK_SIZE_MB=$((APK_SIZE / 1048576))
echo "Found APK: $APK ($APK_SIZE_MB MB)"
echo "apk_path=$APK" >> "$GITHUB_OUTPUT"
- name: Upload APK artifact
uses: actions/upload-artifact@v7
with:
name: osu-android-${{ github.ref_name }}
path: ${{ steps.find_apk.outputs.apk_path }}
if-no-files-found: error
- name: Create GitHub Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
files: ${{ steps.find_apk.outputs.apk_path }}
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}