actions: use ubuntu runs

我記錯了,是 Windows 才兩倍份額,而且還沒 Ubuntu 快(
This commit is contained in:
NkBe 2025-11-19 20:51:16 +08:00
parent 0fa8ef2b89
commit a89856c4b4
No known key found for this signature in database
GPG Key ID: 525137026FF031DF
1 changed files with 29 additions and 33 deletions

View File

@ -9,7 +9,7 @@ on:
jobs: jobs:
build: build:
name: 構建 name: 構建
runs-on: windows-latest runs-on: ubuntu-latest
env: env:
CCACHE_COMPILERCHECK: '%compiler% -dumpmachine; %compiler% -dumpversion' CCACHE_COMPILERCHECK: '%compiler% -dumpmachine; %compiler% -dumpversion'
CCACHE_NOHASHDIR: 'true' CCACHE_NOHASHDIR: 'true'
@ -27,22 +27,21 @@ jobs:
- name: 設定快取 - name: 設定快取
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
path: $env:USERPROFILE\.ccache path: ~/.ccache
key: ${{ runner.os }}-ccache-${{ github.sha }} key: ${{ runner.os }}-ccache-${{ github.sha }}
restore-keys: | restore-keys: |
${{ runner.os }}-ccache- ${{ runner.os }}-ccache-
- name: 如果需要,則寫入簽名密鑰 - 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 (-not [string]::IsNullOrEmpty("${{ secrets.KEY_STORE }}")) { if [ ! -z "${{ secrets.KEY_STORE }}" ]; then
"androidStorePassword='${{ secrets.KEY_STORE_PASSWORD }}'" | Out-File -Append -FilePath gradle.properties echo androidStorePassword='${{ secrets.KEY_STORE_PASSWORD }}' >> gradle.properties
"androidKeyAlias='${{ secrets.ALIAS }}'" | Out-File -Append -FilePath gradle.properties echo androidKeyAlias='${{ secrets.ALIAS }}' >> gradle.properties
"androidKeyPassword='${{ secrets.KEY_PASSWORD }}'" | Out-File -Append -FilePath gradle.properties echo androidKeyPassword='${{ secrets.KEY_PASSWORD }}' >> gradle.properties
"androidStoreFile='key.jks'" | Out-File -Append -FilePath gradle.properties echo androidStoreFile='key.jks' >> gradle.properties
[System.Convert]::FromBase64String("${{ secrets.KEY_STORE }}") | Set-Content -Path key.jks -Encoding Byte echo ${{ secrets.KEY_STORE }} | base64 --decode > key.jks
} fi
- name: 檢出 libxposed/api - name: 檢出 libxposed/api
uses: actions/checkout@main uses: actions/checkout@main
@ -72,56 +71,53 @@ jobs:
- name: 設定 ninja - name: 設定 ninja
uses: seanmiddleditch/gha-setup-ninja@master uses: seanmiddleditch/gha-setup-ninja@master
with: with:
version: 1.12.0 version: 1.12.1
- name: 移除 Android 的 cmake - name: 移除 Android 的 cmake
shell: powershell shell: bash
run: Remove-Item -Path "$env:ANDROID_HOME\cmake" -Recurse -Force -ErrorAction SilentlyContinue run: rm -rf "$ANDROID_HOME/cmake"
- name: 設定構建環境 - name: 設定構建環境
shell: powershell
run: | run: |
# for libxposed/api build # for libxposed/api build
"org.gradle.jvmargs=-Xmx2048m" | Out-File -Append -FilePath libxposed/api/gradle.properties echo 'org.gradle.jvmargs=-Xmx2048m' >> libxposed/api/gradle.properties
# for main project build # for main project build
"org.gradle.parallel=true" | Out-File -Append -FilePath gradle.properties {
"org.gradle.jvmargs=-Xmx2048m" | Out-File -Append -FilePath gradle.properties echo 'org.gradle.parallel=true'
"android.native.buildOutput=verbose" | Out-File -Append -FilePath gradle.properties echo 'org.gradle.jvmargs=-Xmx2048m'
echo 'android.native.buildOutput=verbose'
} >> gradle.properties
# for libxposed dependencies build # for libxposed build
"org.gradle.jvmargs=-Xmx2048m" | Out-File -Append -FilePath libxposed/service/gradle.properties echo 'org.gradle.jvmargs=-Xmx2048m' >> libxposed/api/gradle.properties
echo 'org.gradle.jvmargs=-Xmx2048m' >> libxposed/service/gradle.properties
- name: 授予 gradlew 執行權限 - name: 授予 gradlew 執行權限
run: chmod +x gradlew run: chmod +x gradlew
- name: 使用 Gradle 構建依賴項 - name: 使用 Gradle 構建依賴項
working-directory: libxposed working-directory: libxposed
shell: powershell
run: | run: |
cd api cd api
"org.gradle.jvmargs=-Xmx2048m" | Out-File -Append -FilePath gradle.properties echo 'org.gradle.jvmargs=-Xmx2048m' >> gradle.properties
.\gradlew.bat :api:publishApiPublicationToMavenLocal ./gradlew :api:publishApiPublicationToMavenLocal
cd ../service cd ../service
"org.gradle.jvmargs=-Xmx2048m" | Out-File -Append -FilePath gradle.properties echo 'org.gradle.jvmargs=-Xmx2048m' >> gradle.properties
.\gradlew.bat :interface:publishInterfacePublicationToMavenLocal ./gradlew :interface:publishInterfacePublicationToMavenLocal
- name: 設定 commit id - name: 設定 commit id
shell: powershell run: echo "commit=$(echo ${{ github.sha }} | cut -c-7)" > $GITHUB_ENV
run: |
$commit = "${{ github.sha }}".Substring(0, 7)
echo "commit=$commit" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: 使用 Gradle 構建 - name: 使用 Gradle 構建
run: .\gradlew.bat buildAll run: ./gradlew buildAll
- name: 上傳 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 retention-days: 14
- name: 上傳 Debug Artifact - name: 上傳 Debug Artifact
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4