Skip to content

chore: optimize build process #131

chore: optimize build process

chore: optimize build process #131

Workflow file for this run

name: Android CI
on:
workflow_dispatch:
push:
branches: ["master"]
tags:
- 'v*'
paths-ignore:
- 'README.md'
- 'doc/*'
- 'app/gradle.properties'
- '.github/workflows/android.yml'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: true
- name: Set up JDK 20
uses: actions/setup-java@v4
with:
java-version: "20"
distribution: "temurin"
cache: gradle
- name: Cache Gradle Dependencies
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
!~/.gradle/caches/build-cache-*
key: gradle-deps-core-${{ hashFiles('**/build.gradle.kts') }}
restore-keys: |
gradle-deps
- name: Build with Gradle and Sign
run: |
echo ${{ secrets.SIGNING_KEY }} | base64 -d > keystore.jks
if [[ ${{ github.ref }} == refs/tags/v* ]]; then
bash ./gradlew :app:assembleAppRelease
bash ./gradlew :app:assembleAppRelease
echo "APK_FILE=$(find app/build/outputs/apk/app/release/ -name '*.apk' | head -n 1)" >> $GITHUB_ENV
echo "Building Type: Release Version" >> $GITHUB_STEP_SUMMARY
else
bash ./gradlew :app:assembleCIRelease
bash ./gradlew :app:assembleCIRelease
echo "APK_FILE=$(find app/build/outputs/apk/CI/release/ -name '*.apk' | head -n 1)" >> $GITHUB_ENV
echo "Building Type: CI Build Version" >> $GITHUB_STEP_SUMMARY
fi
env:
KEYSTORE_PATH: "../keystore.jks"
KEYSTORE_PASS: ${{ secrets.KEY_STORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
- name: Upload CI Artifact
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
uses: actions/upload-artifact@v4
with:
name: RestoreSplashScreen_CI_Release
path: ${{ env.APK_FILE }}
- name: Post Artifacts to Telegram
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
env:
TG_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
TG_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
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 }})
See build detail [here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
\#启动遮罩进化
COMMIT_URL: ${{ github.event.head_commit.url }}
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"])))'`
curl -v "https://api.telegram.org/bot${TG_BOT_TOKEN}/sendMediaGroup?chat_id=${TG_CHAT_ID}&media=%5B%7B%22type%22%3A%22document%22%2C%20%22media%22%3A%22attach%3A%2F%2Fci%22%2C%22parse_mode%22%3A%22MarkdownV2%22%2C%22caption%22%3A${ESCAPED}%7D%5D" \
-F ci="@${{ env.APK_FILE }}"
- name: Get Release Tag Name
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: |
echo "RELEASE_TAG_NAME=$(bash ./gradlew -q getVersionCode 2>&1 | tail -n 1)" >> "$GITHUB_ENV"
- name: Create LSPosed Repository Release
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: softprops/action-gh-release@v1
with:
prerelease: true
name: ${{ github.ref_name }}
tag_name: ${{ env.RELEASE_TAG_NAME }}
body: "This is a pre-release version automatically created by GitHub Actions, awaiting developer's addition of the changelog."
repository: Xposed-Modules-Repo/com.gswxxn.restoresplashscreen
token: ${{ secrets.GH_TOKEN }}
files: ${{ env.APK_FILE }}
- name: Display APK Hashes
run: |
apk=${{ env.APK_FILE }}
echo "### APK Hashes" >> $GITHUB_STEP_SUMMARY
echo "| Hash Type | Hash Value |" >> $GITHUB_STEP_SUMMARY
echo "| --- | --- |" >> $GITHUB_STEP_SUMMARY
echo "| SHA256 | \`$(sha256sum $apk | awk '{ print $1 }')\` |" >> $GITHUB_STEP_SUMMARY
echo "| SHA1 | \`$(sha1sum $apk | awk '{ print $1 }')\` |" >> $GITHUB_STEP_SUMMARY
echo "| MD5 | \`$(md5sum $apk | awk '{ print $1 }')\` |" >> $GITHUB_STEP_SUMMARY