Merge branch 'main' into Dev #698
This file contains 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: Android CI Dev | |
on: | |
push: | |
branches: [Dev, new] | |
paths-ignore: | |
- "README.md" | |
pull_request: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: "recursive" | |
- name: Write key | |
if: ${{ github.event_name != 'pull_request' || github.ref_type == 'tag' }} | |
run: | | |
if [ ! -z "${{ secrets.SIGNING_KEY }}" ]; then | |
echo androidStorePassword='${{ secrets.KEY_STORE_PASSWORD }}' >> local.properties | |
echo androidKeyAlias='xiao_wine' >> local.properties | |
echo androidKeyPassword='${{ secrets.KEY_STORE_PASSWORD }}' >> local.properties | |
echo androidStoreFile=`pwd`/key.jks >> local.properties | |
echo ${{ secrets.SIGNING_KEY }} | base64 --decode > key.jks | |
fi | |
- name: set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: "17" | |
distribution: "microsoft" | |
- name: Setup Gradle | |
uses: gradle/gradle-build-action@v2 | |
with: | |
gradle-home-cache-cleanup: true | |
cache-read-only: ${{ github.ref != 'refs/heads/dev' && github.ref != 'refs/heads/new' }} | |
- name: Build with Gradle | |
run: | | |
echo 'org.gradle.parallel=true' >> gradle.properties | |
echo 'org.gradle.jvmargs=-Xmx4g' >> gradle.properties | |
./gradlew assemble | |
./gradlew bundleRelease | |
- name: Upload Release APK | |
uses: actions/upload-artifact@v3 | |
with: | |
name: StatusBarLyric_release | |
path: ./app/build/outputs/apk/release | |
- name: Upload Release AAB APK | |
uses: actions/upload-artifact@v3 | |
with: | |
name: StatusBarLyric_aab | |
path: ./app/build/outputs/bundle/release | |
- name: Upload Debug APK | |
uses: actions/upload-artifact@v3 | |
with: | |
name: StatusBarLyric_debug | |
path: ./app/build/outputs/apk/debug | |
- name: Upload Release Mapping | |
uses: actions/upload-artifact@v3 | |
with: | |
name: StatusBarLyric_release_mapping | |
path: ./app/build/outputs/mapping/release/mapping.txt | |
- name: Post to channel | |
if: contains(github.event.head_commit.message, '[skip post]') == false && github.event_name != 'pull_request' | |
env: | |
CHANNEL_ID: ${{ secrets.CHANNEL_DEV_ID }} | |
BOT_TOKEN: ${{ secrets.BOT_DEV_TOKEN }} | |
MAPPING: ./app/build/outputs/mapping/release/mapping.txt | |
COMMIT_URL: ${{ github.event.head_commit.url }} | |
COMMIT_MESSAGE: |+ | |
Github CI Build | |
``` | |
${{ github.event.head_commit.message }} | |
``` | |
run: | | |
export RELEASE=$(find ./app/build/outputs/apk/release -name "*.apk") | |
export DEBUG=$(find ./app/build/outputs/apk/debug -name "*.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}&media=%5B%7B%22type%22%3A%22document%22%2C%22media%22%3A%22attach%3A%2F%2Frelease%22%7D%2C%7B%22type%22%3A%22document%22%2C%22media%22%3A%22attach%3A%2F%2Fdebug%22%7D%2C%7B%22type%22%3A%22document%22%2C%22media%22%3A%22attach%3A%2F%2Fmapping%22%2C%22parse_mode%22%3A%22MarkdownV2%22%2C%22caption%22%3A${ESCAPED}%7D%5D" -F release="@$RELEASE" -F debug="@$DEBUG" -F mapping="@$MAPPING" |