From 2b63b800b76379d4a7f09992524a6977abd4557a Mon Sep 17 00:00:00 2001 From: Howard Wu <40033067+Howard20181@users.noreply.github.com> Date: Thu, 15 Dec 2022 16:00:11 +0800 Subject: [PATCH] Update ci Grants executable permission in SVC, which does not need to be executed every time --- .github/workflows/crowdin.yml | 54 +++---- .github/workflows/main.yml | 219 ++++++++++++++--------------- .github/workflows/pull_request.yml | 90 ++++++------ gradlew | 0 4 files changed, 179 insertions(+), 184 deletions(-) mode change 100644 => 100755 gradlew diff --git a/.github/workflows/crowdin.yml b/.github/workflows/crowdin.yml index 85fe496..df1c00d 100644 --- a/.github/workflows/crowdin.yml +++ b/.github/workflows/crowdin.yml @@ -1,27 +1,27 @@ -name: Crowdin Action - -on: - workflow_dispatch: - push: - branches: [ master ] - paths: - - app/src/main/res/values/strings.xml - -jobs: - synchronize-with-crowdin: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: crowdin action - uses: crowdin/github-action@master - with: - upload_translations: false - download_translations: false - upload_sources: true - config: 'crowdin.yml' - crowdin_branch_name: master - env: - CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} - CROWDIN_API_TOKEN: ${{ secrets.CROWDIN_API_TOKEN }} +name: Crowdin Action + +on: + workflow_dispatch: + push: + branches: [ master ] + paths: + - app/src/main/res/values/strings.xml + +jobs: + synchronize-with-crowdin: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: crowdin action + uses: crowdin/github-action@master + with: + upload_translations: false + download_translations: false + upload_sources: true + config: 'crowdin.yml' + crowdin_branch_name: master + env: + CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} + CROWDIN_API_TOKEN: ${{ secrets.CROWDIN_API_TOKEN }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 85bcff1..96d8dd5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,111 +1,108 @@ -name: Main - -on: - push: - branches: [ master ] - paths-ignore: - - '.github/ISSUE_TEMPLATE/**' - - '.github/workflows/issue.yml' - - '**.md' - -jobs: - build: - name: Build on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ ubuntu-latest ] - if: ${{ !startsWith(github.event.head_commit.message, '[skip ci]') }} - - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - submodules: 'recursive' - fetch-depth: 0 - - - name: Gradle wrapper validation - uses: gradle/wrapper-validation-action@v1 - - - name: Set up JDK 11 - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: '11' - - - name: Write key - if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master' - run: | - echo officialBuild=true >> local.properties - echo buildWithGitSuffix=true >> local.properties - echo storePassword='${{ secrets.KEY_STORE_PASSWORD }}' >> local.properties - echo keyAlias='${{ secrets.ALIAS }}' >> local.properties - echo keyPassword='${{ secrets.ALIAS_KEY_PASSWORD }}' >> local.properties - echo fileDir=`pwd`/key.jks >> local.properties - echo "${{ secrets.KEY_STORE }}" | base64 --decode > key.jks - echo "${{ secrets.GOOGLE_SERVICES_JSON }}" | base64 --decode > app/google-services.json - - - name: Cache gradle - uses: actions/cache@v3 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} - restore-keys: ${{ runner.os }}-gradle- - - - name: Make gradlew executable - run: chmod +x ./gradlew - - - name: Gradle prebuild - run: | - echo 'org.gradle.jvmargs=-Xmx2048m' >> gradle.properties - ./gradlew prebuild - - - name: Build release - id: buildRelease - run: | - ./gradlew :app:buildRelease - echo "::set-output name=releaseName::`ls app/build/apk/release/HMA*-release.apk | awk -F '(/|.apk)' '{print $5}'`" - - - name: Build debug - id: buildDebug - run: | - ./gradlew :app:buildDebug - echo "::set-output name=debugName::`ls app/build/apk/debug/HMA*-debug.apk | awk -F '(/|.apk)' '{print $5}'`" - - - name: Upload release - if: success() - uses: actions/upload-artifact@v3 - with: - name: ${{ steps.buildRelease.outputs.releaseName }} - path: "app/build/apk/release/HMA*-release.apk" - - - name: Upload debug - if: success() - uses: actions/upload-artifact@v3 - with: - name: ${{ steps.buildDebug.outputs.debugName }} - path: "app/build/apk/debug/HMA*-debug.apk" - - - name: Upload mappings - uses: actions/upload-artifact@v3 - with: - name: mappings - path: "app/build/outputs/mapping/release" - - - name: Post to group - if: ${{ github.event_name != 'pull_request' && success() && github.ref == 'refs/heads/master' }} - env: - CHANNEL_ID: ${{ secrets.TELEGRAM_CHANNEL }} - TOPIC_ID: ${{ secrets.TELEGRAM_TOPIC }} - BOT_TOKEN: ${{ secrets.TELEGRAM_TOKEN }} - COMMIT_URL: ${{ github.event.head_commit.url }} - COMMIT_MESSAGE: ${{ github.event.head_commit.message }} - run: | - OUTPUT="app/build/apk/" - export release=$(find $OUTPUT -name "HMA*-release.apk") - export debug=$(find $OUTPUT -name "HMA*-debug.apk") - ESCAPED=`python3 -c 'import json,os,urllib.parse; msg = json.dumps(os.environ["COMMIT_MESSAGE"]); print(urllib.parse.quote(msg if len(msg) <= 1024 else json.dumps(os.environ["COMMIT_URL"])))'` - curl -v "https://api.telegram.org/bot${BOT_TOKEN}/sendMediaGroup?chat_id=${CHANNEL_ID}&message_thread_id=${TOPIC_ID}&media=%5B%7B%22type%22:%22document%22,%20%22media%22:%22attach://release%22%7D,%7B%22type%22:%22document%22,%20%22media%22:%22attach://debug%22,%22caption%22:${ESCAPED}%7D%5D" -F release="@$release" -F debug="@$debug" +name: Main + +on: + push: + branches: [ master ] + paths-ignore: + - '.github/ISSUE_TEMPLATE/**' + - '.github/workflows/issue.yml' + - '**.md' + +jobs: + build: + name: Build on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest ] + if: ${{ !startsWith(github.event.head_commit.message, '[skip ci]') }} + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: 'recursive' + fetch-depth: 0 + + - name: Gradle wrapper validation + uses: gradle/wrapper-validation-action@v1 + + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '11' + + - name: Write key + if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master' + run: | + echo officialBuild=true >> local.properties + echo buildWithGitSuffix=true >> local.properties + echo storePassword='${{ secrets.KEY_STORE_PASSWORD }}' >> local.properties + echo keyAlias='${{ secrets.ALIAS }}' >> local.properties + echo keyPassword='${{ secrets.ALIAS_KEY_PASSWORD }}' >> local.properties + echo fileDir=`pwd`/key.jks >> local.properties + echo "${{ secrets.KEY_STORE }}" | base64 --decode > key.jks + echo "${{ secrets.GOOGLE_SERVICES_JSON }}" | base64 --decode > app/google-services.json + + - name: Cache gradle + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} + restore-keys: ${{ runner.os }}-gradle- + + - name: Gradle prebuild + run: | + echo 'org.gradle.jvmargs=-Xmx2048m' >> gradle.properties + ./gradlew prebuild + + - name: Build release + id: buildRelease + run: | + ./gradlew :app:buildRelease + echo "releaseName=$(ls app/build/apk/release/HMA*-release.apk | awk -F '(/|.apk)' '{print $5}')" >> $GITHUB_OUTPUT + + - name: Build debug + id: buildDebug + run: | + ./gradlew :app:buildDebug + echo "debugName=$(ls app/build/apk/debug/HMA*-debug.apk | awk -F '(/|.apk)' '{print $5}')" >> $GITHUB_OUTPUT + + - name: Upload release + if: success() + uses: actions/upload-artifact@v3 + with: + name: ${{ steps.buildRelease.outputs.releaseName }} + path: "app/build/apk/release/HMA*-release.apk" + + - name: Upload debug + if: success() + uses: actions/upload-artifact@v3 + with: + name: ${{ steps.buildDebug.outputs.debugName }} + path: "app/build/apk/debug/HMA*-debug.apk" + + - name: Upload mappings + uses: actions/upload-artifact@v3 + with: + name: mappings + path: "app/build/outputs/mapping/release" + + - name: Post to group + if: ${{ github.event_name != 'pull_request' && success() && github.ref == 'refs/heads/master' }} + env: + CHANNEL_ID: ${{ secrets.TELEGRAM_CHANNEL }} + TOPIC_ID: ${{ secrets.TELEGRAM_TOPIC }} + BOT_TOKEN: ${{ secrets.TELEGRAM_TOKEN }} + COMMIT_URL: ${{ github.event.head_commit.url }} + COMMIT_MESSAGE: ${{ github.event.head_commit.message }} + run: | + OUTPUT="app/build/apk/" + export release=$(find $OUTPUT -name "HMA*-release.apk") + export debug=$(find $OUTPUT -name "HMA*-debug.apk") + ESCAPED=`python3 -c 'import json,os,urllib.parse; msg = json.dumps(os.environ["COMMIT_MESSAGE"]); print(urllib.parse.quote(msg if len(msg) <= 1024 else json.dumps(os.environ["COMMIT_URL"])))'` + curl -v "https://api.telegram.org/bot${BOT_TOKEN}/sendMediaGroup?chat_id=${CHANNEL_ID}&message_thread_id=${TOPIC_ID}&media=%5B%7B%22type%22:%22document%22,%20%22media%22:%22attach://release%22%7D,%7B%22type%22:%22document%22,%20%22media%22:%22attach://debug%22,%22caption%22:${ESCAPED}%7D%5D" -F release="@$release" -F debug="@$debug" diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 453ab34..c524036 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -1,46 +1,44 @@ -name: Pull Request - -on: pull_request - -jobs: - build: - name: Build on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ ubuntu-latest ] - if: ${{ !startsWith(github.event.head_commit.message, 'docs:') }} - - steps: - - name: Check out - uses: actions/checkout@v2 - with: - submodules: 'recursive' - fetch-depth: 0 - - - name: Gradle wrapper validation - uses: gradle/wrapper-validation-action@v1 - - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - java-version: '11' - - - name: Write properties - run: | - echo buildWithGitSuffix=true >> local.properties - - - name: Make gradlew executable - run: chmod +x ./gradlew - - - name: Gradle prebuild - run: | - echo 'org.gradle.jvmargs=-Xmx2048m' >> gradle.properties - ./gradlew prebuild - - - name: Build debug - id: buildDebug - run: | - ./gradlew :app:assembleDebug - echo "::set-output name=debugName::`ls app/build/apk/debug/HMA*-debug.apk | awk -F '(/|.apk)' '{print $6}'`" +name: Pull Request + +on: pull_request + +jobs: + build: + name: Build on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest ] + if: ${{ !startsWith(github.event.head_commit.message, 'docs:') }} + + steps: + - name: Check out + uses: actions/checkout@v3 + with: + submodules: 'recursive' + fetch-depth: 0 + + - name: Gradle wrapper validation + uses: gradle/wrapper-validation-action@v1 + + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'temurin' + + - name: Write properties + run: | + echo buildWithGitSuffix=true >> local.properties + + - name: Gradle prebuild + run: | + echo 'org.gradle.jvmargs=-Xmx2048m' >> gradle.properties + ./gradlew prebuild + + - name: Build debug + id: buildDebug + run: | + ./gradlew :app:assembleDebug + echo "debugName=$(ls app/build/apk/debug/HMA*-debug.apk | awk -F '(/|.apk)' '{print $6}')" >> $GITHUB_OUTPUT diff --git a/gradlew b/gradlew old mode 100644 new mode 100755