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

156 lines
6.0 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)
2024-03-17 12:53:18 +01:00
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
2020-09-12 17:47:09 +02:00
with:
2024-01-15 22:11:31 +01:00
repository: 'mihonapp/mihon'
2020-09-12 17:47:09 +02:00
fetch-depth: 0
if: github.event.inputs.git-ref == ''
- name: Clone Repository (Custom Ref)
2024-03-17 12:53:18 +01:00
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
2020-09-12 17:47:09 +02:00
if: github.event.inputs.git-ref != ''
with:
2024-01-15 22:11:31 +01:00
repository: 'mihonapp/mihon'
2020-09-12 17:47:09 +02:00
fetch-depth: 0
ref: ${{ github.event.inputs.git-ref }}
- name: Set up JDK
2024-03-17 12:53:18 +01:00
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
2020-09-12 17:47:09 +02:00
with:
2023-04-16 23:58:27 +02:00
java-version: 17
2022-05-15 18:11:30 +02:00
distribution: adopt
2020-09-12 17:47:09 +02:00
2024-01-13 20:03:26 +01:00
- name: Setup Android SDK
run: |
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager "build-tools;29.0.3"
2021-01-23 23:14:38 +01:00
- name: Get previous release
id: last_release
2024-03-17 12:53:18 +01:00
uses: InsonusK/get-latest-release@7a9ff16c8c6b7ead5d71c0f1cc61f2703170eade # v1.1.0
2021-01-23 23:14:38 +01:00
with:
myToken: ${{ github.token }}
exclude_types: "draft|prerelease"
view_top: 1
- name: Prepare build
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" \
2024-01-15 22:11:31 +01:00
"https://api.github.com/repos/mihonapp/mihon/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
- name: Set up gradle
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
2020-09-12 17:47:09 +02:00
- name: Build APK
run: ./gradlew assembleStandardPreview
2021-06-14 23:34:54 +02:00
2023-08-16 04:16:36 +02:00
- name: Sign APK
uses: r0adkll/sign-android-release@349ebdef58775b1e0d8099458af0816dc79b6407 # v1
2023-08-16 04:16:36 +02:00
with:
releaseDirectory: app/build/outputs/apk/standard/preview
2024-01-15 22:40:09 +01:00
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
alias: ${{ secrets.ALIAS }}
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
keyPassword: ${{ secrets.KEY_PASSWORD }}
2023-08-16 04:16:36 +02:00
- name: Clean up build artifacts
run: |
2021-06-14 23:34:54 +02:00
set -e
2024-01-15 22:11:31 +01:00
cp app/build/outputs/apk/standard/preview/app-standard-universal-preview-signed.apk mihon-r${{ env.COMMIT_COUNT }}.apk
sha=`sha256sum mihon-r${{ env.COMMIT_COUNT }}.apk | awk '{ print $1 }'`
2021-08-22 17:34:02 +02:00
echo "APK_UNIVERSAL_SHA=$sha" >> $GITHUB_ENV
2024-01-15 22:11:31 +01:00
cp app/build/outputs/apk/standard/preview/app-standard-arm64-v8a-preview-signed.apk mihon-arm64-v8a-r${{ env.COMMIT_COUNT }}.apk
sha=`sha256sum mihon-arm64-v8a-r${{ env.COMMIT_COUNT }}.apk | awk '{ print $1 }'`
2021-08-22 17:34:02 +02:00
echo "APK_ARM64_V8A_SHA=$sha" >> $GITHUB_ENV
2024-01-15 22:11:31 +01:00
cp app/build/outputs/apk/standard/preview/app-standard-armeabi-v7a-preview-signed.apk mihon-armeabi-v7a-r${{ env.COMMIT_COUNT }}.apk
sha=`sha256sum mihon-armeabi-v7a-r${{ env.COMMIT_COUNT }}.apk | awk '{ print $1 }'`
2021-08-22 17:34:02 +02:00
echo "APK_ARMEABI_V7A_SHA=$sha" >> $GITHUB_ENV
2024-01-15 22:11:31 +01:00
cp app/build/outputs/apk/standard/preview/app-standard-x86-preview-signed.apk mihon-x86-r${{ env.COMMIT_COUNT }}.apk
sha=`sha256sum mihon-x86-r${{ env.COMMIT_COUNT }}.apk | awk '{ print $1 }'`
2021-08-22 17:34:02 +02:00
echo "APK_X86_SHA=$sha" >> $GITHUB_ENV
2020-09-12 17:47:09 +02:00
2024-01-15 22:11:31 +01:00
cp app/build/outputs/apk/standard/preview/app-standard-x86_64-preview-signed.apk mihon-x86_64-r${{ env.COMMIT_COUNT }}.apk
sha=`sha256sum mihon-x86_64-r${{ env.COMMIT_COUNT }}.apk | awk '{ print $1 }'`
2022-08-28 15:45:59 +02:00
echo "APK_X86_64_SHA=$sha" >> $GITHUB_ENV
2021-06-14 23:34:54 +02:00
- name: Create release
uses: softprops/action-gh-release@9d7c94cfd0a1f3ed45544c887983e9fa900f0564 # v2.0.4
2020-09-12 17:47:09 +02:00
with:
tag_name: r${{ env.COMMIT_COUNT }}
2024-01-15 22:11:31 +01:00
name: Mihon Preview r${{ env.COMMIT_COUNT }}
2021-01-23 23:14:38 +01:00
body: |
2021-08-22 17:34:02 +02:00
### Commits
2024-01-15 22:11:31 +01:00
https://github.com/mihonapp/mihon/compare/${{ env.PREV_RELEASE_SHA }}...${{ env.CURRENT_SHA }}
2021-01-23 23:14:38 +01:00
${{ env.COMMIT_LOGS }}
---
2021-08-28 23:16:09 +02:00
### Checksums
2021-08-22 17:34:02 +02:00
2021-08-28 23:16:09 +02:00
| Variant | SHA-256 |
| ------- | ------- |
2021-08-22 17:34:02 +02:00
| Universal | ${{ env.APK_UNIVERSAL_SHA }}
| arm64-v8a | ${{ env.APK_ARM64_V8A_SHA }}
| armeabi-v7a | ${{ env.APK_ARMEABI_V7A_SHA }}
| x86 | ${{ env.APK_X86_SHA }} |
2022-08-28 15:45:59 +02:00
| x86_64 | ${{ env.APK_X86_64_SHA }} |
2024-01-15 22:11:31 +01:00
2024-01-29 20:48:58 +01:00
## If you are unsure which apk to download then go with mihon-r${{ env.COMMIT_COUNT }}.apk
files: |
2024-01-15 22:11:31 +01:00
mihon-r${{ env.COMMIT_COUNT }}.apk
mihon-arm64-v8a-r${{ env.COMMIT_COUNT }}.apk
mihon-armeabi-v7a-r${{ env.COMMIT_COUNT }}.apk
mihon-x86-r${{ env.COMMIT_COUNT }}.apk
mihon-x86_64-r${{ env.COMMIT_COUNT }}.apk
draft: ${{ github.event.inputs.dry-run != '' }}
2020-09-12 17:47:09 +02:00
prerelease: false
2024-01-15 23:02:54 +01:00
env:
2024-03-17 12:43:56 +01:00
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
2024-03-17 12:53:18 +01:00
uses: dev-drprasad/delete-older-releases@0bf4e6748f08135170c2294f877ba7d9b633b028 # v0.3.3
2020-12-12 22:26:46 +01:00
env:
2024-03-17 12:43:56 +01:00
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2020-12-12 22:26:46 +01:00
with:
keep_latest: 28
2020-12-12 22:26:46 +01:00
delete_tags: true