146 lines
4.5 KiB
YAML
146 lines
4.5 KiB
YAML
name: CI Build
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
pull_request:
|
|
push:
|
|
merge_group:
|
|
|
|
jobs:
|
|
build:
|
|
name: 構建
|
|
runs-on: windows-latest
|
|
env:
|
|
CCACHE_COMPILERCHECK: '%compiler% -dumpmachine; %compiler% -dumpversion'
|
|
CCACHE_NOHASHDIR: 'true'
|
|
CCACHE_HARDLINK: 'true'
|
|
CCACHE_BASEDIR: '${{ github.workspace }}'
|
|
|
|
steps:
|
|
- name: 檢出程式碼
|
|
uses: actions/checkout@v5
|
|
with:
|
|
ref: ${{ github.sha }}
|
|
submodules: 'recursive'
|
|
fetch-depth: 0
|
|
|
|
- name: 設定快取
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: $env:USERPROFILE\.ccache
|
|
key: ${{ runner.os }}-ccache-${{ github.sha }}
|
|
restore-keys: |
|
|
${{ runner.os }}-ccache-
|
|
|
|
- name: 如果需要,則寫入簽名密鑰
|
|
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request'
|
|
shell: powershell
|
|
run: |
|
|
if (-not [string]::IsNullOrEmpty("${{ secrets.KEY_STORE }}")) {
|
|
"androidStorePassword='${{ secrets.KEY_STORE_PASSWORD }}'" | Out-File -Append -FilePath gradle.properties
|
|
"androidKeyAlias='${{ secrets.ALIAS }}'" | Out-File -Append -FilePath gradle.properties
|
|
"androidKeyPassword='${{ secrets.KEY_PASSWORD }}'" | Out-File -Append -FilePath gradle.properties
|
|
"androidStoreFile='key.jks'" | Out-File -Append -FilePath gradle.properties
|
|
[System.Convert]::FromBase64String("${{ secrets.KEY_STORE }}") | Set-Content -Path key.jks -Encoding Byte
|
|
}
|
|
|
|
- name: 檢出 libxposed/api
|
|
uses: actions/checkout@main
|
|
with:
|
|
repository: libxposed/api
|
|
path: libxposed/api
|
|
ref: 54582730315ba4a3d7cfaf9baf9d23c419e07006
|
|
|
|
- name: 檢出 libxposed/service
|
|
uses: actions/checkout@main
|
|
with:
|
|
repository: libxposed/service
|
|
path: libxposed/service
|
|
|
|
- name: 設定 Java
|
|
uses: actions/setup-java@v5
|
|
with:
|
|
java-version: '21'
|
|
distribution: 'adopt'
|
|
|
|
- name: 設定 Gradle
|
|
uses: gradle/actions/setup-gradle@v5
|
|
|
|
- name: 設定 Android SDK
|
|
uses: android-actions/setup-android@v3
|
|
|
|
- name: 設定 ninja
|
|
uses: seanmiddleditch/gha-setup-ninja@master
|
|
with:
|
|
version: 1.12.0
|
|
|
|
- name: 移除 Android 的 cmake
|
|
shell: powershell
|
|
run: Remove-Item -Path "$env:ANDROID_HOME\cmake" -Recurse -Force -ErrorAction SilentlyContinue
|
|
|
|
- name: 設定構建環境
|
|
shell: powershell
|
|
run: |
|
|
# for libxposed/api build
|
|
"org.gradle.jvmargs=-Xmx2048m" | Out-File -Append -FilePath libxposed/api/gradle.properties
|
|
|
|
# for main project build
|
|
"org.gradle.parallel=true" | Out-File -Append -FilePath gradle.properties
|
|
"org.gradle.jvmargs=-Xmx2048m" | Out-File -Append -FilePath gradle.properties
|
|
"android.native.buildOutput=verbose" | Out-File -Append -FilePath gradle.properties
|
|
|
|
# for libxposed dependencies build
|
|
"org.gradle.jvmargs=-Xmx2048m" | Out-File -Append -FilePath libxposed/service/gradle.properties
|
|
|
|
- name: 授予 gradlew 執行權限
|
|
run: chmod +x gradlew
|
|
|
|
- name: 使用 Gradle 構建依賴項
|
|
working-directory: libxposed
|
|
shell: powershell
|
|
run: |
|
|
cd api
|
|
"org.gradle.jvmargs=-Xmx2048m" | Out-File -Append -FilePath gradle.properties
|
|
.\gradlew.bat :api:publishApiPublicationToMavenLocal
|
|
|
|
cd ../service
|
|
"org.gradle.jvmargs=-Xmx2048m" | Out-File -Append -FilePath gradle.properties
|
|
.\gradlew.bat :interface:publishInterfacePublicationToMavenLocal
|
|
|
|
- name: 設定 commit id
|
|
shell: powershell
|
|
run: |
|
|
$commit = "${{ github.sha }}".Substring(0, 7)
|
|
echo "commit=$commit" | Out-File -FilePath $env:GITHUB_ENV -Append
|
|
|
|
- name: 使用 Gradle 構建
|
|
run: .\gradlew.bat buildAll
|
|
|
|
- name: 上傳 Release Artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: npatch-release-${{ env.commit }}
|
|
path: out/release/*
|
|
retention-days: 7
|
|
|
|
- name: 上傳 Debug Artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: npatch-debug-${{ env.commit }}
|
|
path: out/debug/*
|
|
retention-days: 7
|
|
|
|
- name: 上傳 mappings
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: mappings-${{ env.commit }}
|
|
path: |
|
|
patch-loader/build/outputs/mapping
|
|
manager/build/outputs/mapping
|
|
|
|
- name: 上傳 symbols
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: symbols-${{ env.commit }}
|
|
path: |
|
|
patch-loader/build/symbols |