diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index de0b809..49c7298 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,7 +9,7 @@ on: jobs: build: name: 構建 - runs-on: windows-latest + runs-on: ubuntu-latest env: CCACHE_COMPILERCHECK: '%compiler% -dumpmachine; %compiler% -dumpversion' CCACHE_NOHASHDIR: 'true' @@ -22,27 +22,26 @@ jobs: with: ref: ${{ github.sha }} submodules: 'recursive' - fetch-depth: 0 + fetch-depth: 0 - name: 設定快取 uses: actions/cache@v4 with: - path: $env:USERPROFILE\.ccache + path: ~/.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 - } + if [ ! -z "${{ secrets.KEY_STORE }}" ]; then + echo androidStorePassword='${{ secrets.KEY_STORE_PASSWORD }}' >> gradle.properties + echo androidKeyAlias='${{ secrets.ALIAS }}' >> gradle.properties + echo androidKeyPassword='${{ secrets.KEY_PASSWORD }}' >> gradle.properties + echo androidStoreFile='key.jks' >> gradle.properties + echo ${{ secrets.KEY_STORE }} | base64 --decode > key.jks + fi - name: 檢出 libxposed/api uses: actions/checkout@main @@ -72,56 +71,53 @@ jobs: - name: 設定 ninja uses: seanmiddleditch/gha-setup-ninja@master with: - version: 1.12.0 + version: 1.12.1 - name: 移除 Android 的 cmake - shell: powershell - run: Remove-Item -Path "$env:ANDROID_HOME\cmake" -Recurse -Force -ErrorAction SilentlyContinue + shell: bash + run: rm -rf "$ANDROID_HOME/cmake" - name: 設定構建環境 - shell: powershell run: | # 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 - "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 + { + echo 'org.gradle.parallel=true' + echo 'org.gradle.jvmargs=-Xmx2048m' + echo 'android.native.buildOutput=verbose' + } >> gradle.properties - # for libxposed dependencies build - "org.gradle.jvmargs=-Xmx2048m" | Out-File -Append -FilePath libxposed/service/gradle.properties + # for libxposed build + echo 'org.gradle.jvmargs=-Xmx2048m' >> libxposed/api/gradle.properties + echo 'org.gradle.jvmargs=-Xmx2048m' >> 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 - + echo 'org.gradle.jvmargs=-Xmx2048m' >> gradle.properties + ./gradlew :api:publishApiPublicationToMavenLocal cd ../service - "org.gradle.jvmargs=-Xmx2048m" | Out-File -Append -FilePath gradle.properties - .\gradlew.bat :interface:publishInterfacePublicationToMavenLocal + echo 'org.gradle.jvmargs=-Xmx2048m' >> gradle.properties + ./gradlew :interface:publishInterfacePublicationToMavenLocal - name: 設定 commit id - shell: powershell - run: | - $commit = "${{ github.sha }}".Substring(0, 7) - echo "commit=$commit" | Out-File -FilePath $env:GITHUB_ENV -Append + run: echo "commit=$(echo ${{ github.sha }} | cut -c-7)" > $GITHUB_ENV - name: 使用 Gradle 構建 - run: .\gradlew.bat buildAll + run: ./gradlew buildAll - name: 上傳 Release Artifact uses: actions/upload-artifact@v4 with: name: npatch-release-${{ env.commit }} path: out/release/* - retention-days: 7 + retention-days: 14 - name: 上傳 Debug Artifact uses: actions/upload-artifact@v4