Merge pull request #120 from xihan123/release-please--branches--maste… #53
Workflow file for this run
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 | |
on: | |
workflow_dispatch: | |
push: | |
tags: | |
- "v*" | |
jobs: | |
build: | |
name: Build on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ ubuntu-latest ] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: 'recursive' | |
fetch-depth: 0 | |
- name: base64-to-file | |
id: write_file | |
uses: timheuer/base64-to-file@v1.2 | |
if: ${{ ( github.event_name != 'pull_request' && github.ref == 'refs/heads/master' ) || github.ref_type == 'tag' }} | |
with: | |
fileName: 'key.jks' | |
encodedString: ${{ secrets.SIGNING_KEY }} | |
- name: Write key | |
if: ${{ ( github.event_name != 'pull_request' && github.ref == 'refs/heads/master' ) || github.ref_type == 'tag' }} | |
run: | | |
touch keystore.properties | |
echo storePassword='${{ secrets.KEY_STORE_PASSWORD }}' >> keystore.properties | |
echo keyAlias='${{ secrets.ALIAS }}' >> keystore.properties | |
echo keyPassword='${{ secrets.KEY_PASSWORD }}' >> keystore.properties | |
echo storeFile='${{ steps.write_file.outputs.filePath }}' >> keystore.properties | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: 'gradle' | |
- name: Build with Gradle | |
run: | | |
[ $(du -s ~/.gradle/wrapper | awk '{ print $1 }') -gt 250000 ] && rm -rf ~/.gradle/wrapper/* || true | |
echo 'org.gradle.caching=true' >> gradle.properties | |
echo 'org.gradle.parallel=true' >> gradle.properties | |
echo 'org.gradle.vfs.watch=true' >> gradle.properties | |
echo 'org.gradle.jvmargs=-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g' >> gradle.properties | |
echo 'android.native.buildOutput=verbose' >> gradle.properties | |
chmod +x gradlew | |
./gradlew assembleRelease -Pkotlin.experimental.tryK2=true | |
- name: Upload assets to a Release | |
uses: meeDamian/github-release@v2.0.3 | |
with: | |
files: app/build/outputs/apk/release/*.apk | |
token: ${{ secrets.RELEASE_TOKEN }} | |
allow_override: true | |
gzip: false | |
- name: Get Latest Release | |
id: get_latest_release | |
uses: pozetroninc/github-action-get-latest-release@v0.7.0 | |
with: | |
repository: ${{ github.repository }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
excludes: prerelease, draft | |
- name: Telegram Notify | |
env: | |
CHANNEL_ID: ${{ secrets.CHANGELOG_CHANNEL_ID }} | |
BOT_TOKEN: ${{ secrets.BOT_TOKEN }} | |
description: ${{ steps.get_latest_release.outputs.description }} | |
run: | | |
if [ ! -z "${{ secrets.BOT_TOKEN }}" ]; then | |
OUTPUT="app/build/outputs/apk/release/" | |
export apkRelease=$(find $OUTPUT -name "*.apk") | |
ESCAPED=`python3 -c '''import requests,os;body = os.environ["description"]; r = requests.get("https://api.github.com/repos/${{github.repository}}/releases/latest"); tag_name = r.json()["tag_name"]; html_url = r.json()["html_url"]; change_log = "# 完整更新日志 " + "[" + tag_name + "](" + html_url + ")"; print(body + "\n\n" + change_log if len(body) <= 1024 else change_log)'''` | |
curl -v "https://api.telegram.org/bot${BOT_TOKEN}/sendDocument?chat_id=${CHANNEL_ID}" -F document="@$apkRelease" -F caption="${ESCAPED}" | |
fi |