Android CI #815
This file contains hidden or 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: | |
| schedule: | |
| - cron: "0 0 * * *" | |
| push: | |
| branches: [ "geolite.clash.dev" ] | |
| pull_request: | |
| branches: [ "geolite.clash.dev" ] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: set up JDK 11 | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: '11' | |
| distribution: 'temurin' | |
| cache: gradle | |
| - name: Set variables | |
| run: | | |
| echo "TAG_NAME=$(date +%s)" >> $GITHUB_ENV | |
| shell: bash | |
| - name: Update local.properties | |
| run: | | |
| sed -i "s/^project.version_code=.*/project.version_code=${TAG_NAME}/" local.properties | |
| sed -i "s/^project.version_name=.*/project.version_name=${TAG_NAME}/" local.properties | |
| cat local.properties | |
| shell: bash | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x gradlew | |
| - name: Gradle clean | |
| run: ./gradlew clean | |
| - name: Build with Gradle | |
| run: ./gradlew build | |
| - name: Upload files to GitHub release | |
| uses: svenstaro/upload-release-action@v2 | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| file_glob: true | |
| file: ./app/build/outputs/apk/release/* | |
| tag: ${{ env.TAG_NAME }} | |
| - name: Git push json to "release_info" branch | |
| run: | | |
| apk_name=$(basename $(ls ./app/build/outputs/apk/release/*.apk)) | |
| apk_name=$(echo "$apk_name" | sed 's/(\([0-9]\+\))/.\1/g') | |
| mkdir -p release_info | |
| cd release_info || exit 1 | |
| echo "{\"newVersion\": ${TAG_NAME}, \"downloadUrl\": \"https://github.com/JohnnySun/ClashForAndroid-Geoip/releases/download/${TAG_NAME}/${apk_name}\"}" | jq '{newVersion, downloadUrl}' > version_info.json | |
| git init | |
| git config --local user.name "github-actions[bot]" | |
| git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git checkout -b release_info | |
| git add -A | |
| git commit -m "${{ env.TAG_NAME }}" | |
| git remote add android_geoip_release_info "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}" | |
| git push -f -u android_geoip_release_info release_info |