From f06f4e15e8b02f3ab19937369428d1882064d597 Mon Sep 17 00:00:00 2001 From: Draff Date: Tue, 9 Jan 2024 03:14:00 +0000 Subject: [PATCH] fix actions --- .github/scripts/commit-repo.sh | 9 ++---- .github/scripts/create-repo.sh | 3 +- .github/workflows/build_pull_request.yml | 18 +++-------- .github/workflows/build_push.yml | 32 ++++++------------- settings.gradle.kts | 40 +++++++++--------------- 5 files changed, 34 insertions(+), 68 deletions(-) diff --git a/.github/scripts/commit-repo.sh b/.github/scripts/commit-repo.sh index 9c603e7bc..a02a97519 100755 --- a/.github/scripts/commit-repo.sh +++ b/.github/scripts/commit-repo.sh @@ -2,16 +2,13 @@ set -e rsync -a --delete --exclude .git --exclude .gitignore ../master/repo/ . -git config --global user.email "github-actions[bot]@users.noreply.github.com" -git config --global user.name "github-actions[bot]" +git config --global user.email "gitea@catgirlsneed.homes" +git config --global user.name "Homeless Catgirl" git status if [ -n "$(git status --porcelain)" ]; then git add . - git commit -m "Update extensions repo" + git commit -m "Upload APKs" git push - - # Purge cached index on jsDelivr - curl https://purge.jsdelivr.net/gh/ItsLogic/ext@repo/index.min.json else echo "No changes to commit" fi diff --git a/.github/scripts/create-repo.sh b/.github/scripts/create-repo.sh index 9bb13b340..aeb48f825 100755 --- a/.github/scripts/create-repo.sh +++ b/.github/scripts/create-repo.sh @@ -6,13 +6,12 @@ TOOLS="$(ls -d ${ANDROID_HOME}/build-tools/* | tail -1)" mkdir -p repo/apk mkdir -p repo/icon -cp -f apk/* repo/apk - cd repo APKS=( ../apk/*".apk" ) for APK in ${APKS[@]}; do + cp $APK apk/ FILENAME=$(basename ${APK}) BADGING="$(${TOOLS}/aapt dump --include-meta-data badging $APK)" diff --git a/.github/workflows/build_pull_request.yml b/.github/workflows/build_pull_request.yml index d310bcdc4..5ffb361e7 100644 --- a/.github/workflows/build_pull_request.yml +++ b/.github/workflows/build_pull_request.yml @@ -16,10 +16,8 @@ env: jobs: prepare: name: Prepare job - runs-on: ubuntu-latest + runs-on: arch outputs: - individualMatrix: ${{ steps.generate-matrices.outputs.individualMatrix }} - multisrcMatrix: ${{ steps.generate-matrices.outputs.multisrcMatrix }} isIndividualChanged: ${{ steps.parse-changed-files.outputs.isIndividualChanged }} isMultisrcChanged: ${{ steps.parse-changed-files.outputs.isMultisrcChanged }} env: @@ -100,9 +98,7 @@ jobs: name: Build multisrc modules needs: prepare if: ${{ needs.prepare.outputs.isMultisrcChanged == '1' }} - runs-on: ubuntu-latest - strategy: - matrix: ${{ fromJSON(needs.prepare.outputs.multisrcMatrix) }} + runs-on: arch steps: - name: Checkout PR uses: actions/checkout@v4 @@ -121,11 +117,10 @@ jobs: arguments: :multisrc:generateExtensions cache-read-only: true - - name: Build extensions (chunk ${{ matrix.chunk }}) + - name: Build extensions) uses: gradle/gradle-build-action@v2 env: CI_MULTISRC: "true" - CI_CHUNK_NUM: ${{ matrix.chunk }} with: arguments: assembleDebug cache-read-only: true @@ -134,9 +129,7 @@ jobs: name: Build individual modules needs: prepare if: ${{ needs.prepare.outputs.isIndividualChanged == '1' }} - runs-on: ubuntu-latest - strategy: - matrix: ${{ fromJSON(needs.prepare.outputs.individualMatrix) }} + runs-on: arch steps: - name: Checkout PR uses: actions/checkout@v4 @@ -147,11 +140,10 @@ jobs: java-version: 11 distribution: adopt - - name: Build extensions (chunk ${{ matrix.chunk }}) + - name: Build extensions uses: gradle/gradle-build-action@v2 env: CI_MULTISRC: "false" - CI_CHUNK_NUM: ${{ matrix.chunk }} with: arguments: assembleDebug cache-read-only: true diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml index 32cdaf056..f1d7bcc97 100644 --- a/.github/workflows/build_push.yml +++ b/.github/workflows/build_push.yml @@ -19,7 +19,7 @@ env: jobs: prepare: name: Prepare job - runs-on: self-hosted + runs-on: arch outputs: individualMatrix: ${{ steps.generate-matrices.outputs.individualMatrix }} multisrcMatrix: ${{ steps.generate-matrices.outputs.multisrcMatrix }} @@ -66,15 +66,10 @@ jobs: console.log(`Individual modules: ${numIndividualModules} (${numIndividualChunks} chunks of ${chunkSize})`); console.log(`Multi-source modules: ${numMultisrcModules} (${numMultisrcChunks} chunks of ${chunkSize})`); - core.setOutput('individualMatrix', { 'chunk': [...Array(numIndividualChunks).keys()] }); - core.setOutput('multisrcMatrix', { 'chunk': [...Array(numMultisrcChunks).keys()] }); - build_multisrc: name: Build multisrc modules needs: prepare - runs-on: self-hosted - strategy: - matrix: ${{ fromJSON(needs.prepare.outputs.multisrcMatrix) }} + runs-on: arch steps: - name: Checkout master branch uses: actions/checkout@v4 @@ -96,22 +91,20 @@ jobs: with: arguments: :multisrc:generateExtensions - - name: Build extensions (chunk ${{ matrix.chunk }}) + - name: Build extensions uses: gradle/gradle-build-action@v2 env: CI_MULTISRC: "true" - CI_CHUNK_NUM: ${{ matrix.chunk }} ALIAS: ${{ secrets.ALIAS }} KEY_STORE_PASSWORD: ${{ secrets.KEY_STORE_PASSWORD }} KEY_PASSWORD: ${{ secrets.KEY_STORE_PASSWORD }} with: arguments: assembleRelease - - name: Upload APKs (chunk ${{ matrix.chunk }}) + - name: Upload APKs uses: actions/upload-artifact@v3 - if: "github.repository == 'ItsLogic/ext'" with: - name: "multisrc-apks-${{ matrix.chunk }}" + name: "multisrc-apks" path: "**/*.apk" retention-days: 1 @@ -121,9 +114,7 @@ jobs: build_individual: name: Build individual modules needs: prepare - runs-on: self-hosted - strategy: - matrix: ${{ fromJSON(needs.prepare.outputs.individualMatrix) }} + runs-on: arch steps: - name: Checkout master branch uses: actions/checkout@v4 @@ -138,22 +129,20 @@ jobs: run: | echo ${{ secrets.SIGNING_KEY }} | base64 -d > signingkey.jks - - name: Build extensions (chunk ${{ matrix.chunk }}) + - name: Build extensions uses: gradle/gradle-build-action@v2 env: CI_MULTISRC: "false" - CI_CHUNK_NUM: ${{ matrix.chunk }} ALIAS: ${{ secrets.ALIAS }} KEY_STORE_PASSWORD: ${{ secrets.KEY_STORE_PASSWORD }} KEY_PASSWORD: ${{ secrets.KEY_STORE_PASSWORD }} with: arguments: assembleRelease - - name: Upload APKs (chunk ${{ matrix.chunk }}) + - name: Upload APKs uses: actions/upload-artifact@v3 - if: "github.repository == 'ItsLogic/ext'" with: - name: "individual-apks-${{ matrix.chunk }}" + name: "individual-apks" path: "**/*.apk" retention-days: 1 @@ -165,8 +154,7 @@ jobs: needs: - build_multisrc - build_individual - if: "github.repository == 'ItsLogic/ext'" - runs-on: ubuntu-latest + runs-on: arch steps: - name: Download APK artifacts uses: actions/download-artifact@v3 diff --git a/settings.gradle.kts b/settings.gradle.kts index 3e0631f9e..1ce18b85d 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -25,27 +25,29 @@ if (System.getenv("CI") == null || System.getenv("CI_MODULE_GEN") == "true") { // Running in CI (GitHub Actions) val isMultisrc = System.getenv("CI_MULTISRC") == "true" - val chunkSize = System.getenv("CI_CHUNK_SIZE").toInt() - val chunk = System.getenv("CI_CHUNK_NUM").toInt() if (isMultisrc) { include(":multisrc") project(":multisrc").projectDir = File("multisrc") // Loads generated extensions from multisrc - File(rootDir, "generated-src").getChunk(chunk, chunkSize)?.forEach { - val name = ":extensions:multisrc:${it.parentFile.name}:${it.name}" - println(name) - include(name) - project(name).projectDir = File("generated-src/${it.parentFile.name}/${it.name}") + File(rootDir, "generated-src").eachDir { dir -> + dir.eachDir { subdir -> + val name = ":extensions:multisrc:${dir.name}:${subdir.name}" + println(name) + include(name) + project(name).projectDir = File("generated-src/${dir.name}/${subdir.name}") + } } } else { // Loads individual extensions - File(rootDir, "src").getChunk(chunk, chunkSize)?.forEach { - val name = ":extensions:individual:${it.parentFile.name}:${it.name}" - println(name) - include(name) - project(name).projectDir = File("src/${it.parentFile.name}/${it.name}") + File(rootDir, "src").eachDir { dir -> + dir.eachDir { subdir -> + val name = ":extensions:individual:${dir.name}:${subdir.name}" + println(name) + include(name) + project(name).projectDir = File("src/${dir.name}/${subdir.name}") + } } } } @@ -79,18 +81,6 @@ fun loadGeneratedMultisrcExtension(lang: String, name: String) { project(projectName).projectDir = File("generated-src/${lang}/${name}") } -fun File.getChunk(chunk: Int, chunkSize: Int): List? { - return listFiles() - // Lang folder - ?.filter { it.isDirectory } - // Extension subfolders - ?.mapNotNull { dir -> dir.listFiles()?.filter { it.isDirectory } } - ?.flatten() - ?.sortedBy { it.name } - ?.chunked(chunkSize) - ?.get(chunk) -} - fun File.eachDir(block: (File) -> Unit) { listFiles()?.filter { it.isDirectory }?.forEach { block(it) } -} +} \ No newline at end of file