Skip to content

Commit 4c35557

Browse files
LeeGoDamnwysaidCopilot
committed
Refine CI workflows and fix macOS matrix gap (#557)
* Refactor CI/CD workflow: multi-platform, multi-NDK, multi-config builds - Rename workflow file from android.yml to build.yml (best practice) - Support 3 OS platforms: Windows, macOS, Ubuntu - Support 2 NDK versions: r26d (stable), r27c (latest) - Support 2 build systems: CMake and ndk-build - Support 4 product variants: ±FFmpeg × ±16KB page size - Total 48 build configurations (3×2×2×2×2) Trigger strategy: - Master branch: Full build (48 jobs) - Pull requests: Simplified build (18 jobs) - Windows: 1 job (r26d, CMake, FFmpeg, 16KB) - macOS: 1 job (r27c, ndk-build, no-FFmpeg, 4KB) - Ubuntu: 16 jobs (full matrix) - Other branches: No build (save resources) Features: - Structured artifact naming: apk-{OS}-{NDK}-{BuildSystem}-{FFmpeg}-{PageSize} - Conditional job execution based on branch - Cross-platform build tool installation - Separate lint job for code quality (master only) - Added comprehensive workflow documentation * Initial plan * Initial plan * Split workflows and add release automation Co-authored-by: wysaid <1430725+wysaid@users.noreply.github.com> * Add explicit workflow permissions Co-authored-by: wysaid <1430725+wysaid@users.noreply.github.com> * Fix CI triggers for better_workflow and simplify OS-specific steps * Trigger CI for better_workflow PRs * Fix workflow triggers and macOS matrix * Fix matrix gating in workflows * Reduce PR matrix and fix macOS NDK arch * Address PR review comments * Use macos-latest runner for macOS CI * Update lint job to setup-java v4 * Install NDK via sdkmanager on macOS * Normalize NDK flavor parsing on macOS * Handle sdkmanager pipefail on macOS * Run full workflows on workflow branches and add test release mode --------- Co-authored-by: wangyang (wysaid) <wysaid@gmail.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: wysaid <1430725+wysaid@users.noreply.github.com>
1 parent 35792b5 commit 4c35557

5 files changed

Lines changed: 619 additions & 51 deletions

File tree

.github/workflows/android.yml

Lines changed: 0 additions & 51 deletions
This file was deleted.

.github/workflows/macos-build.yml

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
name: macOS Build
2+
3+
on:
4+
push:
5+
branches:
6+
- "master"
7+
- "*workflow*"
8+
pull_request:
9+
branches: [ "master" ]
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
build:
16+
name: "${{ matrix.os-name }} | NDK-${{ matrix.ndk }} | ${{ matrix.build-system }} | ${{ matrix.ffmpeg }} | ${{ matrix.page-size }}"
17+
runs-on: ${{ matrix.os }}
18+
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
include: ${{ fromJson(github.event_name == 'pull_request' && '[{"os":"macos-latest","os-name":"macOS","ndk":"r27c","build-system":"ndk-build","ffmpeg":"no-ffmpeg","page-size":"4kb"}]' || '[{"os":"macos-latest","os-name":"macOS","ndk":"r26d","build-system":"cmake","ffmpeg":"with-ffmpeg","page-size":"16kb"},{"os":"macos-latest","os-name":"macOS","ndk":"r27c","build-system":"cmake","ffmpeg":"with-ffmpeg","page-size":"16kb"},{"os":"macos-latest","os-name":"macOS","ndk":"r26d","build-system":"ndk-build","ffmpeg":"with-ffmpeg","page-size":"16kb"},{"os":"macos-latest","os-name":"macOS","ndk":"r27c","build-system":"ndk-build","ffmpeg":"with-ffmpeg","page-size":"16kb"},{"os":"macos-latest","os-name":"macOS","ndk":"r26d","build-system":"cmake","ffmpeg":"no-ffmpeg","page-size":"16kb"},{"os":"macos-latest","os-name":"macOS","ndk":"r27c","build-system":"cmake","ffmpeg":"no-ffmpeg","page-size":"16kb"},{"os":"macos-latest","os-name":"macOS","ndk":"r26d","build-system":"ndk-build","ffmpeg":"no-ffmpeg","page-size":"16kb"},{"os":"macos-latest","os-name":"macOS","ndk":"r27c","build-system":"ndk-build","ffmpeg":"no-ffmpeg","page-size":"16kb"},{"os":"macos-latest","os-name":"macOS","ndk":"r26d","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":"4kb"},{"os":"macos-latest","os-name":"macOS","ndk":"r26d","build-system":"ndk-build","ffmpeg":"with-ffmpeg","page-size":"4kb"},{"os":"macos-latest","os-name":"macOS","ndk":"r27c","build-system":"ndk-build","ffmpeg":"with-ffmpeg","page-size":"4kb"},{"os":"macos-latest","os-name":"macOS","ndk":"r26d","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":"4kb"},{"os":"macos-latest","os-name":"macOS","ndk":"r26d","build-system":"ndk-build","ffmpeg":"no-ffmpeg","page-size":"4kb"},{"os":"macos-latest","os-name":"macOS","ndk":"r27c","build-system":"ndk-build","ffmpeg":"no-ffmpeg","page-size":"4kb"}]') }}
23+
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
28+
- name: Setup Android SDK
29+
uses: android-actions/setup-android@v3
30+
31+
- name: Install NDK
32+
shell: bash
33+
run: |
34+
NDK_FLAVOR="${{ matrix.ndk }}"
35+
NDK_FLAVOR=$(printf "%s" "$NDK_FLAVOR" | tr -d '\r\n')
36+
case "$NDK_FLAVOR" in
37+
r26d*) NDK_VERSION="26.2.11394342" ;;
38+
r27c*) NDK_VERSION="27.2.12479018" ;;
39+
*)
40+
echo "Error: Unsupported NDK version $NDK_FLAVOR"
41+
exit 1
42+
;;
43+
esac
44+
set +o pipefail
45+
yes | sdkmanager "ndk;${NDK_VERSION}"
46+
SDKMANAGER_STATUS=${PIPESTATUS[1]}
47+
set -o pipefail
48+
if [ "$SDKMANAGER_STATUS" -ne 0 ]; then
49+
echo "Error: sdkmanager failed with status $SDKMANAGER_STATUS"
50+
exit "$SDKMANAGER_STATUS"
51+
fi
52+
echo "ANDROID_NDK_HOME=$ANDROID_SDK_ROOT/ndk/${NDK_VERSION}" >> "$GITHUB_ENV"
53+
echo "$ANDROID_SDK_ROOT/ndk/${NDK_VERSION}" >> "$GITHUB_PATH"
54+
55+
- name: Install build tools
56+
run: brew install ninja
57+
58+
- name: Setup JDK 17
59+
uses: actions/setup-java@v4
60+
with:
61+
java-version: '17'
62+
distribution: 'temurin'
63+
cache: gradle
64+
65+
- name: Grant execute permission for scripts
66+
run: chmod +x gradlew tasks.sh
67+
68+
- name: Configure build parameters
69+
shell: bash
70+
run: |
71+
# Set build system flag
72+
if [ "${{ matrix.build-system }}" == "cmake" ]; then
73+
echo "BUILD_SYSTEM_FLAG=--enable-cmake" >> $GITHUB_ENV
74+
else
75+
echo "BUILD_SYSTEM_FLAG=" >> $GITHUB_ENV
76+
fi
77+
78+
# Set FFmpeg flag
79+
if [ "${{ matrix.ffmpeg }}" == "with-ffmpeg" ]; then
80+
echo "FFMPEG_FLAG=--enable-video-module" >> $GITHUB_ENV
81+
else
82+
echo "FFMPEG_FLAG=--disable-video-module" >> $GITHUB_ENV
83+
fi
84+
85+
# Set page size flag
86+
if [ "${{ matrix.page-size }}" == "16kb" ]; then
87+
echo "PAGE_SIZE_FLAG=--enable-16kb-page-size" >> $GITHUB_ENV
88+
else
89+
echo "PAGE_SIZE_FLAG=--disable-16kb-page-size" >> $GITHUB_ENV
90+
fi
91+
92+
# Set artifact name
93+
OS_SHORT="${{ runner.os }}"
94+
NDK_SHORT="${{ matrix.ndk }}"
95+
BUILD_SYS="${{ matrix.build-system }}"
96+
if [ "${{ matrix.ffmpeg }}" == "with-ffmpeg" ]; then
97+
FFMPEG_SHORT="ffmpeg"
98+
else
99+
FFMPEG_SHORT="noffmpeg"
100+
fi
101+
PAGE_SHORT="${{ matrix.page-size }}"
102+
103+
echo "ARTIFACT_NAME=apk-${OS_SHORT}-${NDK_SHORT}-${BUILD_SYS}-${FFMPEG_SHORT}-${PAGE_SHORT}" >> $GITHUB_ENV
104+
105+
- name: Setup project (ndk-build mode)
106+
if: matrix.build-system == 'ndk-build'
107+
shell: bash
108+
run: ./tasks.sh --setup-project
109+
110+
- name: Build APK
111+
shell: bash
112+
run: ./tasks.sh --release $BUILD_SYSTEM_FLAG $FFMPEG_FLAG $PAGE_SIZE_FLAG --build
113+
114+
- name: Find and rename APK
115+
shell: bash
116+
run: |
117+
APK_FILE=$(find "cgeDemo/build" -name "*.apk" | grep -i release | head -n 1)
118+
if [ -z "$APK_FILE" ]; then
119+
echo "Error: No release APK found in cgeDemo/build"
120+
exit 1
121+
fi
122+
mkdir -p artifacts
123+
cp "$APK_FILE" "artifacts/cgeDemo-${{ env.ARTIFACT_NAME }}.apk"
124+
echo "APK saved as: artifacts/cgeDemo-${{ env.ARTIFACT_NAME }}.apk"
125+
126+
- name: Upload artifacts
127+
uses: actions/upload-artifact@v4
128+
with:
129+
name: ${{ env.ARTIFACT_NAME }}
130+
path: artifacts/*.apk
131+
compression-level: 0
132+
retention-days: 15
133+
if-no-files-found: error
134+

.github/workflows/release.yml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: Release APKs
2+
3+
on:
4+
push:
5+
branches:
6+
- "*workflow*"
7+
tags:
8+
- 'v*.*.*'
9+
- 'v*.*.*-beta*'
10+
- 'v*.*.*-alpha*'
11+
- 'v*.*.*-rc*'
12+
workflow_dispatch:
13+
inputs:
14+
version:
15+
description: 'Version tag (e.g. v1.0.0-test)'
16+
required: true
17+
default: 'v0.1.0-test'
18+
create_release:
19+
description: 'Whether to create GitHub Release'
20+
type: boolean
21+
default: false
22+
23+
permissions:
24+
contents: write
25+
26+
jobs:
27+
build:
28+
name: "Release | ${{ matrix.artifact_name }}"
29+
runs-on: ubuntu-latest
30+
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
include:
35+
- artifact_name: gpuimage-plus
36+
ffmpeg_flag: --enable-video-module
37+
page_flag: --disable-16kb-page-size
38+
- artifact_name: gpuimage-plus-16k
39+
ffmpeg_flag: --enable-video-module
40+
page_flag: --enable-16kb-page-size
41+
- artifact_name: gpuimage-plus-min
42+
ffmpeg_flag: --disable-video-module
43+
page_flag: --disable-16kb-page-size
44+
- artifact_name: gpuimage-plus-16k-min
45+
ffmpeg_flag: --disable-video-module
46+
page_flag: --enable-16kb-page-size
47+
48+
steps:
49+
- name: Checkout code
50+
uses: actions/checkout@v4
51+
52+
- name: Resolve release tag
53+
shell: bash
54+
run: |
55+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
56+
echo "RELEASE_TAG=${{ inputs.version }}" >> $GITHUB_ENV
57+
echo "SHOULD_RELEASE=${{ inputs.create_release }}" >> $GITHUB_ENV
58+
elif [ "${{ github.ref_type }}" = "branch" ]; then
59+
VERSION=$(grep -E 'versionName' build.gradle | head -n 1 | sed -E 's/.*versionName[^\"]*\"([^\"]+)\".*/\1/')
60+
if [ -z "$VERSION" ]; then
61+
echo "Error: Failed to parse versionName from build.gradle"
62+
exit 1
63+
fi
64+
echo "RELEASE_TAG=v${VERSION}-test" >> $GITHUB_ENV
65+
echo "SHOULD_RELEASE=false" >> $GITHUB_ENV
66+
else
67+
echo "RELEASE_TAG=${{ github.ref_name }}" >> $GITHUB_ENV
68+
echo "SHOULD_RELEASE=true" >> $GITHUB_ENV
69+
fi
70+
echo "APK_NAME=cgeDemo-${{ matrix.artifact_name }}.apk" >> $GITHUB_ENV
71+
72+
- name: Setup NDK
73+
uses: nttld/setup-ndk@v1.4.2
74+
id: setup-ndk
75+
with:
76+
ndk-version: r26d
77+
link-to-sdk: true
78+
add-to-path: true
79+
80+
- name: Install build tools (Ubuntu)
81+
run: sudo apt-get update && sudo apt-get install -y ninja-build
82+
83+
- name: Setup JDK 17
84+
uses: actions/setup-java@v4
85+
with:
86+
java-version: '17'
87+
distribution: 'temurin'
88+
cache: gradle
89+
90+
- name: Grant execute permission for scripts
91+
run: chmod +x gradlew tasks.sh
92+
93+
- name: Build APK
94+
shell: bash
95+
run: |
96+
./tasks.sh --release --enable-cmake ${{ matrix.ffmpeg_flag }} ${{ matrix.page_flag }} --build
97+
98+
- name: Collect APK
99+
shell: bash
100+
run: |
101+
APK_FILE=$(find "cgeDemo/build" -name "*.apk" | grep -i release | head -n 1)
102+
mkdir -p artifacts
103+
cp "$APK_FILE" "artifacts/${{ env.APK_NAME }}"
104+
echo "APK saved as: artifacts/${{ env.APK_NAME }}"
105+
106+
- name: Upload artifacts
107+
uses: actions/upload-artifact@v4
108+
with:
109+
name: ${{ matrix.artifact_name }}
110+
path: artifacts/*.apk
111+
compression-level: 0
112+
retention-days: 15
113+
if-no-files-found: error
114+
115+
- name: Upload to GitHub Release
116+
if: env.SHOULD_RELEASE == 'true'
117+
uses: softprops/action-gh-release@v2
118+
with:
119+
tag_name: ${{ env.RELEASE_TAG }}
120+
name: ${{ env.RELEASE_TAG }}
121+
files: artifacts/*.apk

0 commit comments

Comments
 (0)