chore: 使用路由方法进入模块设置 #226
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build TCQT | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [ main ] | |
| paths-ignore: | |
| - '**.md' | |
| - '**.txt' | |
| - 'renovate.json' | |
| - '.editorconfig' | |
| - '.gitignore' | |
| - '.github/**' | |
| - '.idea/**' | |
| - '!.github/workflows/**' | |
| jobs: | |
| build: | |
| name: Build CI | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| contents: read | |
| if: ${{ github.event_name == 'push' && !startsWith(github.event.head_commit.message, '[skip ci]') && github.ref == 'refs/heads/main' }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| submodules: 'true' | |
| fetch-depth: 0 | |
| - name: Cache Gradle | |
| uses: actions/cache@v5 | |
| with: | |
| path: | | |
| ~/.gradle/caches | |
| ~/.gradle/wrapper | |
| key: gradle-cache-${{ runner.os }}-${{ hashFiles('gradle-wrapper.properties','gradle.properties','gradle/libs.versions.toml') }} | |
| restore-keys: | | |
| gradle-cache-${{ runner.os }}- | |
| - name: set up JDK 21 | |
| uses: actions/setup-java@v5 | |
| with: | |
| java-version: '21' | |
| distribution: 'temurin' | |
| - name: Setup SDK | |
| run: | | |
| echo "ANDROID_HOME=${ANDROID_HOME}" | |
| echo "ANDROID_SDK_ROOT=${ANDROID_SDK_ROOT}" | |
| mkdir -p "$ANDROID_HOME/licenses/" | |
| echo > "$ANDROID_HOME/licenses/android-sdk-license" | |
| echo -n 24333f8a63b6825ea9c5514f83c2829b004d1fee > "$ANDROID_HOME/licenses/android-sdk-license" | |
| yes | "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" --licenses >/dev/null | |
| $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "cmake;3.31.0" | |
| echo "sdk.dir=${ANDROID_HOME}" > local.properties | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v5 | |
| - name: Build with Gradle | |
| run: | | |
| echo 'org.gradle.parallel=true' >> gradle.properties | |
| echo 'org.gradle.vfs.watch=true' >> gradle.properties | |
| sed -i 's/org.gradle.configuration-cache=true//g' gradle.properties | |
| echo ${{ secrets.SIGN_KEYSTORE_BASE64 }} | base64 -d > keystore.jks | |
| chmod +x ./gradlew | |
| ./gradlew :app:assembleRelease :app:assembleDebug | |
| echo "APK_FILE_RELEASE=$(find app/build/outputs/apk/release -name '*.apk')" >> $GITHUB_ENV | |
| echo "APK_FILE_DEBUG=$(find app/build/outputs/apk/debug -name '*.apk')" >> $GITHUB_ENV | |
| env: | |
| KEYSTORE_PATH: "../keystore.jks" | |
| KEYSTORE_PASSWORD: ${{ secrets.SIGN_KEYSTORE_PASSWORD }} | |
| KEY_ALIAS: ${{ secrets.SIGN_ALIAS }} | |
| KEY_PASSWORD: ${{ secrets.SIGN_KEY_PASSWORD }} | |
| - name: Show Artifacts SHA256 | |
| run: | | |
| echo "### Build Success :rocket:" >> $GITHUB_STEP_SUMMARY | |
| echo "|ABI|SHA256|" >> $GITHUB_STEP_SUMMARY | |
| echo "|:--------:|:----------|" >> $GITHUB_STEP_SUMMARY | |
| release=($(sha256sum ${{ env.APK_FILE_RELEASE }})) | |
| echo "|release|$release" >> $GITHUB_STEP_SUMMARY | |
| debug=($(sha256sum ${{ env.APK_FILE_DEBUG }})) | |
| echo "|debug|$debug" >> $GITHUB_STEP_SUMMARY | |
| - name: Upload Artifacts(release) | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| path: ${{ env.APK_FILE_RELEASE }} | |
| name: TCQT-release-${{ github.event.head_commit.id }} | |
| - name: Upload Artifacts(debug) | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| path: ${{ env.APK_FILE_DEBUG }} | |
| name: TCQT-debug-${{ github.event.head_commit.id }} | |
| upload-telegram: | |
| name: Upload Release | |
| if: ${{ success() && github.repository == 'callng/TCQT' }} | |
| runs-on: ubuntu-latest | |
| needs: | |
| - build | |
| steps: | |
| - name: Download Artifacts | |
| uses: actions/download-artifact@v7 | |
| with: | |
| path: artifacts | |
| - name: Release | |
| env: | |
| COMMIT_MESSAGE: |+ | |
| New push to GitHub\! | |
| ``` | |
| ${{ github.event.head_commit.message }} | |
| ```by `${{ github.event.head_commit.author.name }}` | |
| See commit detail [here](${{ github.event.head_commit.url }}) | |
| COMMIT_URL: ${{ github.event.head_commit.url }} | |
| BOT_TOKEN: ${{ secrets.BOT_TOKEN }} | |
| CHANNEL_ID: ${{ secrets.CHANNEL_ID }} | |
| run: | | |
| 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"])))'` | |
| export release=$(find artifacts -type f -name "*-release.apk" | head -n 1) | |
| echo "Release path: $release" | |
| if [ -z "$release" ]; then | |
| echo "❌ 错误:没找到对应的 apk 文件" | |
| exit 1 | |
| fi | |
| curl -v "https://api.telegram.org/bot${BOT_TOKEN}/sendMediaGroup?chat_id=${CHANNEL_ID}&media=%5B%7B%22type%22%3A%22document%22%2C%22media%22%3A%22attach%3A%2F%2Frelease%22%2C%22parse_mode%22%3A%22MarkdownV2%22%2C%22caption%22%3A${ESCAPED}%7D%5D" \ | |
| -F release="@$release" \ |