mihon-preview/.github/workflows/build_app.yml

134 lines
4.9 KiB
YAML
Raw Normal View History

2020-09-12 17:47:09 +02:00
name: Build job
on:
2021-01-23 23:14:38 +01:00
# Every Saturday at 21:00 UTC
2020-09-12 17:47:09 +02:00
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
2020-09-12 17:47:09 +02:00
jobs:
build-app:
runs-on: ubuntu-latest
steps:
- name: Clone Repository (Latest)
uses: actions/checkout@v2
with:
2020-12-27 20:58:07 +01:00
repository: 'tachiyomiorg/tachiyomi'
2020-09-12 17:47:09 +02:00
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:
2020-12-27 20:58:07 +01:00
repository: 'tachiyomiorg/tachiyomi'
2020-09-12 17:47:09 +02:00
fetch-depth: 0
ref: ${{ github.event.inputs.git-ref }}
2021-01-06 04:21:01 +01:00
- name: Set up JDK 11
2020-09-12 17:47:09 +02:00
uses: actions/setup-java@v1
with:
2021-01-06 04:21:01 +01:00
java-version: 11
2020-09-12 17:47:09 +02:00
2021-01-23 23:14:38 +01:00
- 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
2021-06-14 23:34:54 +02:00
- name: Prepare build metadata
2021-01-23 23:14:38 +01:00
run: |
2021-06-14 23:34:54 +02:00
set -e
2021-01-23 23:14:38 +01:00
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
2021-01-23 23:14:38 +01:00
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
2021-01-23 23:14:38 +01:00
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))"')
2021-01-23 23:14:38 +01:00
{delimiter}" >> $GITHUB_ENV
2020-09-12 17:47:09 +02:00
- 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
2021-06-14 23:34:54 +02:00
- name: Clean up build artifacts
run: |
2021-06-14 23:34:54 +02:00
set -e
cp app/build/outputs/apk/standard/debug/app-standard-universal-debug.apk tachiyomi-r${{ env.COMMIT_COUNT }}.apk
md5=`md5sum tachiyomi-r${{ env.COMMIT_COUNT }}.apk | awk '{ print $1 }'`
echo "APK_UNIVERSAL_MD5=$md5" >> $GITHUB_ENV
cp app/build/outputs/apk/standard/debug/app-standard-arm64-v8a-debug.apk tachiyomi-arm64-v8a-r${{ env.COMMIT_COUNT }}.apk
md5=`md5sum tachiyomi-arm64-v8a-r${{ env.COMMIT_COUNT }}.apk | awk '{ print $1 }'`
echo "APK_ARM64_V8A_MD5=$md5" >> $GITHUB_ENV
cp app/build/outputs/apk/standard/debug/app-standard-armeabi-v7a-debug.apk tachiyomi-armeabi-v7a-r${{ env.COMMIT_COUNT }}.apk
md5=`md5sum tachiyomi-armeabi-v7a-r${{ env.COMMIT_COUNT }}.apk | awk '{ print $1 }'`
echo "APK_ARMEABI_V7A_MD5=$md5" >> $GITHUB_ENV
cp app/build/outputs/apk/standard/debug/app-standard-x86-debug.apk tachiyomi-x86-r${{ env.COMMIT_COUNT }}.apk
md5=`md5sum tachiyomi-x86-r${{ env.COMMIT_COUNT }}.apk | awk '{ print $1 }'`
echo "APK_X86_MD5=$md5" >> $GITHUB_ENV
2020-09-12 17:47:09 +02:00
2021-06-14 23:34:54 +02:00
- name: Create release
uses: softprops/action-gh-release@v1
2020-09-12 17:47:09 +02:00
with:
tag_name: r${{ env.COMMIT_COUNT }}
name: Tachiyomi Preview r${{ env.COMMIT_COUNT }}
2021-01-23 23:14:38 +01:00
body: |
Commits: https://github.com/tachiyomiorg/tachiyomi/compare/${{ env.PREV_RELEASE_SHA }}...${{ env.CURRENT_SHA }}
---
2021-01-23 23:14:38 +01:00
${{ env.COMMIT_LOGS }}
---
MD5 (universal): ${{ env.APK_UNIVERSAL_MD5 }}
MD5 (arm74-v8a): ${{ env.APK_ARM64_V8A_MD5 }}
MD5 (armeabi-v7a): ${{ env.APK_ARMEABI_V7A_MD5 }}
MD5 (x86): ${{ env.APK_X86_MD5 }}
files: |
tachiyomi-r${{ env.COMMIT_COUNT }}.apk
tachiyomi-arm64-v8a-r${{ env.COMMIT_COUNT }}.apk
tachiyomi-armeabi-v7a-r${{ env.COMMIT_COUNT }}.apk
tachiyomi-x86-r${{ env.COMMIT_COUNT }}.apk
draft: ${{ github.event.inputs.dry-run != '' }}
2020-09-12 17:47:09 +02:00
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2021-01-23 23:14:38 +01:00
2020-12-14 03:06:00 +01:00
- name: Prune old releases
uses: dev-drprasad/delete-older-releases@v0.2.0
2020-12-12 22:26:46 +01:00
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
2021-04-22 00:01:18 +02:00
keep_latest: 15
2020-12-12 22:26:46 +01:00
delete_tags: true