actions: runs on windows
使用 Windows 執行 Workfolws 能比 Linux 節省1倍的 Actions 份額
This commit is contained in:
parent
307660038e
commit
094be621af
|
|
@ -8,8 +8,8 @@ on:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Build
|
name: 構建
|
||||||
runs-on: ubuntu-latest
|
runs-on: windows-latest
|
||||||
env:
|
env:
|
||||||
CCACHE_COMPILERCHECK: '%compiler% -dumpmachine; %compiler% -dumpversion'
|
CCACHE_COMPILERCHECK: '%compiler% -dumpmachine; %compiler% -dumpversion'
|
||||||
CCACHE_NOHASHDIR: 'true'
|
CCACHE_NOHASHDIR: 'true'
|
||||||
|
|
@ -17,114 +17,120 @@ jobs:
|
||||||
CCACHE_BASEDIR: '${{ github.workspace }}'
|
CCACHE_BASEDIR: '${{ github.workspace }}'
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: 檢出程式碼
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v5
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.sha }}
|
ref: ${{ github.sha }}
|
||||||
submodules: 'recursive'
|
submodules: 'recursive'
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Cache CCACHE
|
- name: 設定快取
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: ~/.ccache
|
path: $env:USERPROFILE\.ccache
|
||||||
key: ${{ runner.os }}-ccache-${{ github.sha }}
|
key: ${{ runner.os }}-ccache-${{ github.sha }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-ccache-
|
${{ runner.os }}-ccache-
|
||||||
|
|
||||||
- name: Write signing key if needed
|
- name: 如果需要,則寫入簽名密鑰
|
||||||
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request'
|
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request'
|
||||||
|
shell: powershell
|
||||||
run: |
|
run: |
|
||||||
if [ ! -z "${{ secrets.KEY_STORE }}" ]; then
|
if (-not [string]::IsNullOrEmpty("${{ secrets.KEY_STORE }}")) {
|
||||||
echo androidStorePassword='${{ secrets.KEY_STORE_PASSWORD }}' >> gradle.properties
|
"androidStorePassword='${{ secrets.KEY_STORE_PASSWORD }}'" | Out-File -Append -FilePath gradle.properties
|
||||||
echo androidKeyAlias='${{ secrets.ALIAS }}' >> gradle.properties
|
"androidKeyAlias='${{ secrets.ALIAS }}'" | Out-File -Append -FilePath gradle.properties
|
||||||
echo androidKeyPassword='${{ secrets.KEY_PASSWORD }}' >> gradle.properties
|
"androidKeyPassword='${{ secrets.KEY_PASSWORD }}'" | Out-File -Append -FilePath gradle.properties
|
||||||
echo androidStoreFile='key.jks' >> gradle.properties
|
"androidStoreFile='key.jks'" | Out-File -Append -FilePath gradle.properties
|
||||||
echo ${{ secrets.KEY_STORE }} | base64 --decode > key.jks
|
[System.Convert]::FromBase64String("${{ secrets.KEY_STORE }}") | Set-Content -Path key.jks -Encoding Byte
|
||||||
fi
|
}
|
||||||
|
|
||||||
- name: Checkout libxposed/api
|
- name: 檢出 libxposed/api
|
||||||
uses: actions/checkout@main
|
uses: actions/checkout@main
|
||||||
with:
|
with:
|
||||||
repository: libxposed/api
|
repository: libxposed/api
|
||||||
path: libxposed/api
|
path: libxposed/api
|
||||||
ref: 54582730315ba4a3d7cfaf9baf9d23c419e07006
|
ref: 54582730315ba4a3d7cfaf9baf9d23c419e07006
|
||||||
|
|
||||||
- name: Checkout libxposed/service
|
- name: 檢出 libxposed/service
|
||||||
uses: actions/checkout@main
|
uses: actions/checkout@main
|
||||||
with:
|
with:
|
||||||
repository: libxposed/service
|
repository: libxposed/service
|
||||||
path: libxposed/service
|
path: libxposed/service
|
||||||
|
|
||||||
- name: Setup Java
|
- name: 設定 Java
|
||||||
uses: actions/setup-java@v5
|
uses: actions/setup-java@v5
|
||||||
with:
|
with:
|
||||||
java-version: '21'
|
java-version: '21'
|
||||||
distribution: 'adopt'
|
distribution: 'adopt'
|
||||||
|
|
||||||
- name: Setup Gradle
|
- name: 設定 Gradle
|
||||||
uses: gradle/actions/setup-gradle@v5
|
uses: gradle/actions/setup-gradle@v5
|
||||||
|
|
||||||
- name: Setup Android SDK
|
- name: 設定 Android SDK
|
||||||
uses: android-actions/setup-android@v3
|
uses: android-actions/setup-android@v3
|
||||||
|
|
||||||
- name: Setup ninja
|
- name: 設定 ninja
|
||||||
uses: seanmiddleditch/gha-setup-ninja@master
|
uses: seanmiddleditch/gha-setup-ninja@master
|
||||||
with:
|
with:
|
||||||
version: 1.12.0
|
version: 1.12.0
|
||||||
|
|
||||||
- name: Remove Android's cmake
|
- name: 移除 Android 的 cmake
|
||||||
shell: bash
|
shell: powershell
|
||||||
run: rm -rf "$ANDROID_HOME/cmake"
|
run: Remove-Item -Path "$env:ANDROID_HOME\cmake" -Recurse -Force -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
- name: Setup build environment properties
|
- name: 設定構建環境
|
||||||
|
shell: powershell
|
||||||
run: |
|
run: |
|
||||||
# for libxposed/api build
|
# for libxposed/api build
|
||||||
echo 'org.gradle.jvmargs=-Xmx2048m' >> libxposed/api/gradle.properties
|
"org.gradle.jvmargs=-Xmx2048m" | Out-File -Append -FilePath libxposed/api/gradle.properties
|
||||||
|
|
||||||
# for main project build
|
# for main project build
|
||||||
{
|
"org.gradle.parallel=true" | Out-File -Append -FilePath gradle.properties
|
||||||
echo 'org.gradle.parallel=true'
|
"org.gradle.jvmargs=-Xmx2048m" | Out-File -Append -FilePath gradle.properties
|
||||||
echo 'org.gradle.jvmargs=-Xmx2048m'
|
"android.native.buildOutput=verbose" | Out-File -Append -FilePath gradle.properties
|
||||||
echo 'android.native.buildOutput=verbose'
|
|
||||||
} >> gradle.properties
|
|
||||||
|
|
||||||
# for libxposed dependencies build
|
# for libxposed dependencies build
|
||||||
echo 'org.gradle.jvmargs=-Xmx2048m' >> libxposed/api/gradle.properties
|
"org.gradle.jvmargs=-Xmx2048m" | Out-File -Append -FilePath libxposed/service/gradle.properties
|
||||||
echo 'org.gradle.jvmargs=-Xmx2048m' >> libxposed/service/gradle.properties
|
|
||||||
|
|
||||||
- name: Grant execution permission to gradlew
|
- name: 授予 gradlew 執行權限
|
||||||
run: chmod +x gradlew
|
run: chmod +x gradlew
|
||||||
|
|
||||||
- name: Build dependencies with Gradle
|
- name: 使用 Gradle 構建依賴項
|
||||||
working-directory: libxposed
|
working-directory: libxposed
|
||||||
|
shell: powershell
|
||||||
run: |
|
run: |
|
||||||
cd api
|
cd api
|
||||||
echo 'org.gradle.jvmargs=-Xmx2048m' >> gradle.properties
|
"org.gradle.jvmargs=-Xmx2048m" | Out-File -Append -FilePath gradle.properties
|
||||||
./gradlew :api:publishApiPublicationToMavenLocal
|
.\gradlew.bat :api:publishApiPublicationToMavenLocal
|
||||||
|
|
||||||
cd ../service
|
cd ../service
|
||||||
echo 'org.gradle.jvmargs=-Xmx2048m' >> gradle.properties
|
"org.gradle.jvmargs=-Xmx2048m" | Out-File -Append -FilePath gradle.properties
|
||||||
./gradlew :interface:publishInterfacePublicationToMavenLocal
|
.\gradlew.bat :interface:publishInterfacePublicationToMavenLocal
|
||||||
|
|
||||||
- name: Set short commit id
|
- name: 設定 commit id
|
||||||
run: echo "commit=$(echo ${{ github.sha }} | cut -c-7)" > $GITHUB_ENV
|
shell: powershell
|
||||||
|
run: |
|
||||||
|
$commit = "${{ github.sha }}".Substring(0, 7)
|
||||||
|
echo "commit=$commit" | Out-File -FilePath $env:GITHUB_ENV -Append
|
||||||
|
|
||||||
- name: Build with Gradle
|
- name: 使用 Gradle 構建
|
||||||
run: ./gradlew buildAll
|
run: .\gradlew.bat buildAll
|
||||||
|
|
||||||
- name: Upload Release artifact
|
- name: 上傳 Release Artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: npatch-release-${{ env.commit }}
|
name: npatch-release-${{ env.commit }}
|
||||||
path: out/release/*
|
path: out/release/*
|
||||||
|
retention-days: 7
|
||||||
|
|
||||||
- name: Upload Debug artifact
|
- name: 上傳 Debug Artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: npatch-debug-${{ env.commit }}
|
name: npatch-debug-${{ env.commit }}
|
||||||
path: out/debug/*
|
path: out/debug/*
|
||||||
|
retention-days: 7
|
||||||
|
|
||||||
- name: Upload mappings
|
- name: 上傳 mappings
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: mappings-${{ env.commit }}
|
name: mappings-${{ env.commit }}
|
||||||
|
|
@ -132,9 +138,9 @@ jobs:
|
||||||
patch-loader/build/outputs/mapping
|
patch-loader/build/outputs/mapping
|
||||||
manager/build/outputs/mapping
|
manager/build/outputs/mapping
|
||||||
|
|
||||||
- name: Upload symbols
|
- name: 上傳 symbols
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: symbols-${{ env.commit }}
|
name: symbols-${{ env.commit }}
|
||||||
path: |
|
path: |
|
||||||
patch-loader/build/symbols
|
patch-loader/build/symbols
|
||||||
|
|
@ -5,13 +5,13 @@ on:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
clean:
|
clean:
|
||||||
runs-on: ubuntu-latest
|
runs-on: windows-latest
|
||||||
steps:
|
steps:
|
||||||
- name: 删除 Gradle 缓存
|
- name: 刪除 Gradle 緩存
|
||||||
run: rm -rf ~/.gradle/caches/
|
run: Remove-Item -Path $env:USERPROFILE\.gradle\caches -Recurse -Force -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
- name: 删除 m2 缓存
|
- name: 刪除 m2 緩存
|
||||||
run: rm -rf ~/.m2/repository/
|
run: Remove-Item -Path $env:USERPROFILE\.m2\repository -Recurse -Force -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
- name: 删除 ccache 缓存
|
- name: 刪除 ccache 緩存
|
||||||
run: rm -rf ~/.ccache/
|
run: Remove-Item -Path $env:USERPROFILE\.ccache -Recurse -Force -ErrorAction SilentlyContinue
|
||||||
Loading…
Reference in New Issue