Android CI #5690
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: | |
schedule: | |
- cron: '0 */12 * * *' | |
workflow_dispatch: | |
jobs: | |
check_release: | |
if: github.repository_owner == github.actor | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: check latest tag | |
shell: bash | |
env: | |
SECRETS_MINIFY: ${{ secrets.MINIFY }} | |
SECRETS_RENAME: ${{ secrets.RENAME }} | |
run: source $GITHUB_WORKSPACE/action_schedule.sh | |
- name: check if release | |
id: check_release | |
shell: bash | |
run: | | |
function version_gt() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" != "$1"; } | |
if version_gt $APP_LATEST_TAG $APP_LAST_TAG; then | |
git clone $APP_GIT_URL $APP_WORKSPACE | |
cd $APP_WORKSPACE | |
git checkout $LATEST_TAG | |
echo "if_release=true" >>$GITHUB_OUTPUT | |
fi | |
- name: setup JDK 17 | |
if: steps.check_release.outputs.if_release == 'true' | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: 17 | |
- name: setup Gradle | |
if: steps.check_release.outputs.if_release == 'true' | |
uses: gradle/[email protected] | |
- name: build apk | |
id: build_apk | |
if: steps.check_release.outputs.if_release == 'true' | |
shell: bash | |
run: | | |
source $GITHUB_WORKSPACE/action_app_custom.sh | |
source $GITHUB_WORKSPACE/action_app_build.sh | |
app_build | |
- name: release apk | |
if: steps.check_release.outputs.if_release == 'true' | |
id: release_apk | |
shell: bash | |
run: | | |
function set_env() { echo "$1=$2" >> $GITHUB_ENV; } | |
if [ -f $APP_BUILD_APK ]; then | |
echo "if_publish=true" >>$GITHUB_OUTPUT | |
set_env APP_RELEASE_NAME $APP_UPLOAD_NAME.apk | |
set_env APP_RELEASE $APP_BUILD_APK | |
fi | |
- name: create release | |
id: create_release | |
if: steps.release_apk.outputs.if_publish == 'true' | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ env.APP_UPLOAD_NAME }} | |
release_name: ${{ env.APP_UPLOAD_NAME }} | |
body_path: ${{ env.APP_LATEST_BODY }} | |
draft: false | |
prerelease: false | |
- name: upload release asset | |
id: upload-release-asset | |
if: steps.release_apk.outputs.if_publish == 'true' | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps | |
asset_path: ${{ env.APP_RELEASE }} | |
asset_name: ${{ env.APP_RELEASE_NAME }} | |
asset_content_type: application/vnd.android.package-archive | |
- name: update info | |
if: steps.upload-release-asset.outputs.browser_download_url != null | |
shell: bash | |
env: | |
APP_DOWNLOAD: ${{ steps.upload-release-asset.outputs.browser_download_url }} | |
run: | | |
source $GITHUB_WORKSPACE/action_util.sh | |
update_info | |