forked from ppy/osu
-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (124 loc) · 5.08 KB
/
Copy pathrelease.yml
File metadata and controls
141 lines (124 loc) · 5.08 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
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: Update .NET workloads
run: dotnet workload update
- 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"
for ABI in arm64-v8a armeabi-v7a x86; 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
- name: Build Android APK (signed)
if: steps.keystore.outputs.has_keystore == 'true'
run: >
dotnet publish -c Release -p:AndroidKeyStore=false -p:PublishTrimmed=false -p:AndroidLinkMode=None
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=${{ secrets.ANDROID_SIGNING_KEY_ALIAS }}
-p:AndroidSigningKeyPass=${{ secrets.ANDROID_SIGNING_KEY_PASSWORD }}
-p:AndroidSigningStorePass=${{ secrets.ANDROID_SIGNING_STORE_PASSWORD }}
- name: Build Android APK (signed with default debug key)
if: steps.keystore.outputs.has_keystore != 'true'
run: >
dotnet publish -c Release -p:AndroidKeyStore=false -p:PublishTrimmed=false -p:AndroidLinkMode=None
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: |
PUBLISH_DIR="osu.Android/bin/Release/net10.0-android"
APK=$(find "$PUBLISH_DIR" -maxdepth 1 -name "*.apk" 2>/dev/null | head -1)
if [ -z "$APK" ]; then
APK=$(find osu.Android/bin/Release -name "*.apk" | head -1)
fi
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 }}