-
Notifications
You must be signed in to change notification settings - Fork 476
135 lines (115 loc) · 5.05 KB
/
macos-build.yml
File metadata and controls
135 lines (115 loc) · 5.05 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
name: macOS Build
on:
push:
branches:
- "master"
- "test_workflow*"
pull_request:
branches: [ "master" ]
permissions:
contents: read
jobs:
build:
name: "${{ matrix.os-name }} | NDK-${{ matrix.ndk }} | ${{ matrix.build-system }} | ${{ matrix.ffmpeg }} | ${{ matrix.page-size }}"
runs-on: ${{ matrix.os }}
timeout-minutes: 35
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(github.event_name == 'pull_request' && '[{"os":"macos-latest","os-name":"macOS","ndk":"r29","build-system":"ndk-build","ffmpeg":"no-ffmpeg","page-size":"4kb"}]' || '[{"os":"macos-latest","os-name":"macOS","ndk":"r27c","build-system":"cmake","ffmpeg":"with-ffmpeg","page-size":"4kb"},{"os":"macos-latest","os-name":"macOS","ndk":"r27c","build-system":"cmake","ffmpeg":"with-ffmpeg","page-size":"16kb"},{"os":"macos-latest","os-name":"macOS","ndk":"r27c","build-system":"cmake","ffmpeg":"no-ffmpeg","page-size":"4kb"},{"os":"macos-latest","os-name":"macOS","ndk":"r27c","build-system":"cmake","ffmpeg":"no-ffmpeg","page-size":"16kb"},{"os":"macos-latest","os-name":"macOS","ndk":"r29","build-system":"cmake","ffmpeg":"with-ffmpeg","page-size":"4kb"},{"os":"macos-latest","os-name":"macOS","ndk":"r29","build-system":"cmake","ffmpeg":"with-ffmpeg","page-size":"16kb"},{"os":"macos-latest","os-name":"macOS","ndk":"r29","build-system":"cmake","ffmpeg":"no-ffmpeg","page-size":"4kb"},{"os":"macos-latest","os-name":"macOS","ndk":"r29","build-system":"cmake","ffmpeg":"no-ffmpeg","page-size":"16kb"}]') }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Install NDK
shell: bash
run: |
NDK_FLAVOR="${{ matrix.ndk }}"
NDK_FLAVOR=$(printf "%s" "$NDK_FLAVOR" | tr -d '\r\n')
case "$NDK_FLAVOR" in
r29*) NDK_VERSION="29.0.14206865" ;;
r27c*) NDK_VERSION="27.2.12479018" ;;
*)
echo "Error: Unsupported NDK version $NDK_FLAVOR"
exit 1
;;
esac
set +o pipefail
yes | sdkmanager "ndk;${NDK_VERSION}"
SDKMANAGER_STATUS=${PIPESTATUS[1]}
set -o pipefail
if [ "$SDKMANAGER_STATUS" -ne 0 ]; then
echo "Error: sdkmanager failed with status $SDKMANAGER_STATUS"
exit "$SDKMANAGER_STATUS"
fi
echo "ANDROID_NDK_HOME=$ANDROID_SDK_ROOT/ndk/${NDK_VERSION}" >> "$GITHUB_ENV"
echo "$ANDROID_SDK_ROOT/ndk/${NDK_VERSION}" >> "$GITHUB_PATH"
- name: Install build tools
run: brew install ninja
- name: Setup JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: gradle
- name: Grant execute permission for scripts
run: chmod +x gradlew tasks.sh
- name: Configure build parameters
shell: bash
run: |
# Set build system flag
if [ "${{ matrix.build-system }}" == "cmake" ]; then
echo "BUILD_SYSTEM_FLAG=--enable-cmake" >> $GITHUB_ENV
else
echo "BUILD_SYSTEM_FLAG=" >> $GITHUB_ENV
fi
# Set FFmpeg flag
if [ "${{ matrix.ffmpeg }}" == "with-ffmpeg" ]; then
echo "FFMPEG_FLAG=--enable-video-module" >> $GITHUB_ENV
else
echo "FFMPEG_FLAG=--disable-video-module" >> $GITHUB_ENV
fi
# Set page size flag
if [ "${{ matrix.page-size }}" == "16kb" ]; then
echo "PAGE_SIZE_FLAG=--enable-16kb-page-size" >> $GITHUB_ENV
else
echo "PAGE_SIZE_FLAG=--disable-16kb-page-size" >> $GITHUB_ENV
fi
# Set artifact name
OS_SHORT="${{ runner.os }}"
NDK_SHORT="${{ matrix.ndk }}"
BUILD_SYS="${{ matrix.build-system }}"
if [ "${{ matrix.ffmpeg }}" == "with-ffmpeg" ]; then
FFMPEG_SHORT="ffmpeg"
else
FFMPEG_SHORT="noffmpeg"
fi
PAGE_SHORT="${{ matrix.page-size }}"
echo "ARTIFACT_NAME=apk-${OS_SHORT}-${NDK_SHORT}-${BUILD_SYS}-${FFMPEG_SHORT}-${PAGE_SHORT}" >> $GITHUB_ENV
- name: Setup project (ndk-build mode)
if: matrix.build-system == 'ndk-build'
shell: bash
run: ./tasks.sh --setup-project
- name: Build APK
shell: bash
run: ./tasks.sh --release $BUILD_SYSTEM_FLAG $FFMPEG_FLAG $PAGE_SIZE_FLAG --build
- name: Find and rename APK
shell: bash
run: |
APK_FILE=$(find "cgeDemo/build" -name "*.apk" | grep -i release | head -n 1)
if [ -z "$APK_FILE" ]; then
echo "Error: No release APK found in cgeDemo/build"
exit 1
fi
mkdir -p artifacts
cp "$APK_FILE" "artifacts/cgeDemo-${{ env.ARTIFACT_NAME }}.apk"
echo "APK saved as: artifacts/cgeDemo-${{ env.ARTIFACT_NAME }}.apk"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}
path: artifacts/*.apk
compression-level: 0
retention-days: 15
if-no-files-found: error