name: Build job on: # Every Saturday at 21:00 UTC schedule: - cron: '0 21 * * 6' # Manual triggers workflow_dispatch: inputs: git-ref: description: Git Ref (Optional) required: false dry-run: description: Creates a draft release required: false jobs: build-app: runs-on: ubuntu-latest steps: - name: Clone Repository (Latest) uses: actions/checkout@v2 with: repository: 'tachiyomiorg/tachiyomi' fetch-depth: 0 if: github.event.inputs.git-ref == '' - name: Clone Repository (Custom Ref) uses: actions/checkout@v2 if: github.event.inputs.git-ref != '' with: repository: 'tachiyomiorg/tachiyomi' fetch-depth: 0 ref: ${{ github.event.inputs.git-ref }} - name: Set up JDK 11 uses: actions/setup-java@v1 with: java-version: 11 - name: Get previous release id: last_release uses: InsonusK/get-latest-release@v1.0.1 with: myToken: ${{ github.token }} exclude_types: "draft|prerelease" view_top: 1 - name: Set env variables run: | set -x commit_count=$(git rev-list --count HEAD) echo "COMMIT_COUNT=$commit_count" >> $GITHUB_ENV current_sha=$(git rev-parse --short HEAD) echo "CURRENT_SHA=$current_sha" >> $GITHUB_ENV prev_commit_count=$(echo "${{ steps.last_release.outputs.tag_name }}" | sed -e "s/^r//") commit_count_diff=$(expr $commit_count - $prev_commit_count) prev_release_sha=$(git rev-parse --short HEAD~$commit_count_diff) echo "PREV_RELEASE_SHA=$prev_release_sha" >> $GITHUB_ENV echo "COMMIT_LOGS<<{delimiter} $(curl -H "Accept: application/vnd.github.v3+json" \ "https://api.github.com/repos/tachiyomiorg/tachiyomi/compare/$prev_release_sha...$current_sha" \ | jq '[.commits[]|{message:(.commit.message | split("\n")), username:.author.login}]' \ | jq -r '.[]|"- \(.message | first) (@\(.username))"') {delimiter}" >> $GITHUB_ENV - name: Set up keystore run: mkdir -p ~/.android/ && echo "${{ secrets.DEBUG_KEYSTORE }}" | base64 --decode > ~/.android/debug.keystore - name: Build APK uses: eskatos/gradle-command-action@v1 with: arguments: assembleStandardDebug wrapper-cache-enabled: true dependencies-cache-enabled: true configuration-cache-enabled: true - name: Create GitHub release id: create_release uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: r${{ env.COMMIT_COUNT }} release_name: Tachiyomi Preview r${{ env.COMMIT_COUNT }} body: | Commits: https://github.com/tachiyomiorg/tachiyomi/compare/${{ env.PREV_RELEASE_SHA }}...${{ env.CURRENT_SHA }} ${{ env.COMMIT_LOGS }} draft: ${{ github.event.inputs.dry-run != '' }} prerelease: false - name: Upload APK to release uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} asset_path: app/build/outputs/apk/standard/debug/app-standard-debug.apk asset_name: tachiyomi-r${{ env.COMMIT_COUNT }}.apk asset_content_type: application/vnd.android.package-archive - name: Prune old releases uses: dev-drprasad/delete-older-releases@v0.2.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: keep_latest: 10 delete_tags: true