Build job #158
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: Build job | |
| on: | |
| # Every day at 17:30 UTC | |
| schedule: | |
| - cron: '30 17 * * *' | |
| # Manual triggers | |
| workflow_dispatch: | |
| inputs: | |
| git-ref: | |
| description: Git Ref (Optional) | |
| required: false | |
| dry-run: | |
| description: Creates a draft release | |
| required: false | |
| type: boolean | |
| env: | |
| MIHON_GITHUB_RELEASE: true | |
| jobs: | |
| check: | |
| name: Check for new commits | |
| runs-on: 'ubuntu-24.04' | |
| outputs: | |
| skip: ${{ steps.check.outputs.skip }} | |
| commit-count: ${{ steps.check.outputs.commit-count }} | |
| current-sha: ${{ steps.check.outputs.current-sha }} | |
| prev-tag: ${{ steps.check.outputs.prev-tag }} | |
| steps: | |
| - name: Clone Repository (Latest) | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| repository: 'mihonapp/mihon' | |
| fetch-depth: 0 | |
| filter: blob:none | |
| if: github.event.inputs.git-ref == '' | |
| - name: Clone Repository (Custom Ref) | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| if: github.event.inputs.git-ref != '' | |
| with: | |
| repository: 'mihonapp/mihon' | |
| fetch-depth: 0 | |
| filter: blob:none | |
| ref: ${{ github.event.inputs.git-ref }} | |
| - name: Compare against latest release | |
| id: check | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| set -e | |
| commit_count=$(git rev-list --count HEAD) | |
| echo "commit-count=$commit_count" >> $GITHUB_OUTPUT | |
| echo "current-sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
| 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 | |
| echo "prev-tag=$tag_name" >> $GITHUB_OUTPUT | |
| prev_commit_count=$(echo "$tag_name" | sed -e "s/^r//") | |
| if [ "$commit_count" -le "$prev_commit_count" ] && [ "${{ github.event_name }}" = 'schedule' ]; then | |
| echo "skip=true" >> $GITHUB_OUTPUT | |
| echo "No new commits since $tag_name, skipping build" | |
| else | |
| echo "skip=false" >> $GITHUB_OUTPUT | |
| fi | |
| build: | |
| name: Build app | |
| needs: check | |
| if: needs.check.outputs.skip != 'true' | |
| runs-on: 'ubuntu-24.04' | |
| env: | |
| COMMIT_COUNT: ${{ needs.check.outputs.commit-count }} | |
| CURRENT_SHA: ${{ needs.check.outputs.current-sha }} | |
| PREV_TAG: ${{ needs.check.outputs.prev-tag }} | |
| steps: | |
| - name: Clone Repository (Latest) | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| repository: 'mihonapp/mihon' | |
| fetch-depth: 0 | |
| if: github.event.inputs.git-ref == '' | |
| - name: Clone Repository (Custom Ref) | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| 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@03ad4de0992f5dab5e18fcb136590ce7c4a0ac95 # v5.6.0 | |
| with: | |
| java-version: 25 | |
| distribution: temurin | |
| - name: Set up gradle | |
| uses: gradle/actions/setup-gradle@3f131e8634966bd73d06cc69884922b02e6faf92 # v6.2.0 | |
| - name: Build APK | |
| run: ./gradlew assembleNightly -Pinclude-telemetry -Penable-updater | |
| env: | |
| storeFileBase64: ${{ secrets.SIGNING_KEY }} | |
| storePassword: ${{ secrets.KEY_STORE_PASSWORD }} | |
| keyAlias: ${{ secrets.ALIAS }} | |
| keyPassword: ${{ secrets.KEY_PASSWORD }} | |
| - name: Prepare changelog | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| set -e | |
| prev_commit_count=$(echo "${{ env.PREV_TAG }}" | sed -e "s/^r//") | |
| commit_count_diff=$(expr ${{ env.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...${{ env.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/nightly/app-universal-nightly.apk mihon-r${{ env.COMMIT_COUNT }}.apk | |
| mv app/build/outputs/apk/nightly/app-arm64-v8a-nightly.apk mihon-arm64-v8a-r${{ env.COMMIT_COUNT }}.apk | |
| mv app/build/outputs/apk/nightly/app-armeabi-v7a-nightly.apk mihon-armeabi-v7a-r${{ env.COMMIT_COUNT }}.apk | |
| mv app/build/outputs/apk/nightly/app-x86-nightly.apk mihon-x86-r${{ env.COMMIT_COUNT }}.apk | |
| mv app/build/outputs/apk/nightly/app-x86_64-nightly.apk mihon-x86_64-r${{ env.COMMIT_COUNT }}.apk | |
| - name: Create release | |
| uses: softprops/action-gh-release@3d0d9888cb7fd7b750713d6e236d1fcb99157228 # v3.0.2 | |
| with: | |
| tag_name: r${{ env.COMMIT_COUNT }} | |
| name: Mihon Nightly 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 | |
| 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: 365 | |
| delete_tags: true |