| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- name: Android CI
- on:
- push:
- branches: [ master ]
- jobs:
- build:
- runs-on: ubuntu-latest
- env:
- CCACHE_DIR: ${{ github.workspace }}/.ccache
- CCACHE_COMPILERCHECK: "%compiler% -dumpmachine; %compiler% -dumpversion"
- CCACHE_NOHASHDIR: true
- CCACHE_MAXSIZE: 1G
- steps:
- - uses: actions/checkout@v3
- with:
- submodules: 'recursive'
- fetch-depth: 0
- - name: Setup JDK 17
- uses: actions/setup-java@v3
- with:
- distribution: 'temurin'
- java-version: 17
- cache: 'gradle'
- - name: Retrieve version
- run: |
- echo VERSION=$(echo ${{ github.event.head_commit.id }} | head -c 10) >> $GITHUB_ENV
- - name: Set up ccache
- uses: hendrikmuhs/[email protected]
- with:
- key: ${{ runner.os }}-${{ github.sha }}
- restore-keys: ${{ runner.os }}
- - name: Write key
- if: ${{ ( github.event_name != 'pull_request' && github.ref == 'refs/heads/master' ) || github.ref_type == 'tag' }}
- run: |
- if [ ! -z "${{ secrets.SIGNING_KEY }}" ]; then
- echo 'Writing sign key'
- echo releaseStorePassword='${{ secrets.KEY_STORE_PASSWORD }}' >> gradle.properties
- echo releaseKeyAlias='${{ secrets.ALIAS }}' >> gradle.properties
- echo releaseKeyPassword='${{ secrets.KEY_PASSWORD }}' >> gradle.properties
- echo releaseStoreFile='key.jks' >> gradle.properties
- echo '${{ secrets.SIGNING_KEY }}' | base64 --decode > key.jks
- fi
- - name: Build with Gradle
- run: |
- 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' >> gradle.properties
- echo 'android.native.buildOutput=verbose' >> gradle.properties
- ./gradlew -PappVerName=${{ env.VERSION }} assembleRelease assembleDebug
- - name: Upload built apk
- if: success()
- uses: actions/upload-artifact@v4
- with:
- name: snapshot
- path: |
- app/build/outputs/apk
- app/build/outputs/mapping
- app/release
- - name: Post to channel
- if: github.ref == 'refs/heads/master'
- env:
- CHANNEL_ID: ${{ secrets.TELEGRAM_TO }}
- BOT_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
- FILE: app/release/BiliRoaming_${{ env.VERSION }}.apk
- 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 }})
- Snapshot apk is attached \(unsupported by TAICHI\)
- run: |
- ESCAPED=`python3 -c 'import json,os,urllib.parse; print(urllib.parse.quote(json.dumps(os.environ["COMMIT_MESSAGE"])))'`
- curl -v "https://api.telegram.org/bot${BOT_TOKEN}/sendMediaGroup?chat_id=${CHANNEL_ID}&media=%5B%7B%22type%22:%22document%22,%20%22media%22:%22attach://release%22,%22parse_mode%22:%22MarkdownV2%22,%22caption%22:${ESCAPED}%7D%5D" -F release="@$FILE"
|