Files
mihon-preview/.github/workflows/build.yml

135 lines
5.0 KiB
YAML

name: Build job
on:
# Every Thursday at 17:30 UTC
schedule:
- cron: '30 17 * * 4'
# Manual triggers
workflow_dispatch:
inputs:
git-ref:
description: Git Ref (Optional)
required: false
dry-run:
description: Creates a draft release
required: false
type: boolean
jobs:
build:
name: Build app
runs-on: 'ubuntu-24.04'
steps:
- name: Clone Repository (Latest)
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: 'mihonapp/mihon'
fetch-depth: 0
if: github.event.inputs.git-ref == ''
- name: Clone Repository (Custom Ref)
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
if: github.event.inputs.git-ref != ''
with:
repository: 'mihonapp/mihon'
fetch-depth: 0
ref: ${{ github.event.inputs.git-ref }}
- name: Set up JDK
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
with:
java-version: 17
distribution: temurin
- name: Set up gradle
uses: gradle/actions/setup-gradle@ac638b010cf58a27ee6c972d7336334ccaf61c96 # v4.4.1
- name: Build APK
run: ./gradlew assemblePreview -Pinclude-telemetry -Penable-updater
- name: Sign APK
uses: r0adkll/sign-android-release@f30bdd30588842ac76044ecdbd4b6d0e3e813478
with:
releaseDirectory: app/build/outputs/apk/preview
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
alias: ${{ secrets.ALIAS }}
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
keyPassword: ${{ secrets.KEY_PASSWORD }}
env:
BUILD_TOOLS_VERSION: '35.0.1'
- name: Prepare changelog
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -e
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
tag_name=$(gh release list --repo mihonapp/mihon-preview --exclude-drafts --exclude-pre-releases --json tagName --limit 1 --jq 'select(length > 0) | .[0].tagName')
if [ -n "$tag_name" ]; then
echo "Latest Tag: $tag_name"
else
echo "Failed to get repository information"
exit 1
fi
prev_commit_count=$(echo "$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/mihonapp/mihon/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: Clean up build artifacts
run: |
set -e
mv app/build/outputs/apk/preview/app-universal-preview-signed.apk mihon-r${{ env.COMMIT_COUNT }}.apk
mv app/build/outputs/apk/preview/app-arm64-v8a-preview-signed.apk mihon-arm64-v8a-r${{ env.COMMIT_COUNT }}.apk
mv app/build/outputs/apk/preview/app-armeabi-v7a-preview-signed.apk mihon-armeabi-v7a-r${{ env.COMMIT_COUNT }}.apk
mv app/build/outputs/apk/preview/app-x86-preview-signed.apk mihon-x86-r${{ env.COMMIT_COUNT }}.apk
mv app/build/outputs/apk/preview/app-x86_64-preview-signed.apk mihon-x86_64-r${{ env.COMMIT_COUNT }}.apk
- name: Create release
uses: softprops/action-gh-release@72f2c25fcb47643c292f7107632f7a47c1df5cd8 # v2.3.2
with:
tag_name: r${{ env.COMMIT_COUNT }}
name: Mihon Preview r${{ env.COMMIT_COUNT }}
body: |
### Commits
https://github.com/mihonapp/mihon/compare/${{ env.PREV_RELEASE_SHA }}...${{ env.CURRENT_SHA }}
${{ env.COMMIT_LOGS }}
<!-->
> [!TIP]
>
> ### If you are unsure which version to download then go with `mihon-r${{ env.COMMIT_COUNT }}.apk`
files: |
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 }}
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.MIHON_BOT_TOKEN }}
- name: Prune old releases
uses: dev-drprasad/delete-older-releases@dfbe6be2a006e9475dfcbe5b8d201f1824c2a9fe # v0.3.4
env:
GITHUB_TOKEN: ${{ secrets.MIHON_BOT_TOKEN }}
with:
keep_latest: 28
delete_tags: true