diff --git a/.github/workflows/build_pull_request.yml b/.github/workflows/build.yml similarity index 85% rename from .github/workflows/build_pull_request.yml rename to .github/workflows/build.yml index 76c77ee49..2ef2fdc38 100644 --- a/.github/workflows/build_pull_request.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: PR build check +name: Build & Test on: pull_request: paths: @@ -8,9 +8,12 @@ on: - '!i18n/src/commonMain/moko-resources/**/plurals.xml' - 'i18n/src/commonMain/moko-resources/base/strings.xml' - 'i18n/src/commonMain/moko-resources/base/plurals.xml' + push: + branches: + - main concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true permissions: @@ -18,14 +21,15 @@ permissions: jobs: build: - name: Build app + name: Build & Test App runs-on: 'ubuntu-24.04' steps: - - name: Clone repo + - name: Checkout uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Dependency Review + if: github.event_name == 'pull_request' uses: actions/dependency-review-action@da24556b548a50705dd671f47852072ea4c105d9 # v4.7.1 - name: Set up JDK @@ -34,14 +38,14 @@ jobs: java-version: 17 distribution: temurin - - name: Set up gradle + - name: Set up Gradle uses: gradle/actions/setup-gradle@017a9effdb900e5b5b2fddfb590a105619dca3c3 # v4.4.2 - name: Check code format run: ./gradlew spotlessCheck - name: Build app - run: ./gradlew assembleRelease + run: ./gradlew assembleRelease -Pinclude-telemetry -Penable-updater - name: Run unit tests run: ./gradlew testReleaseUnitTest diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml deleted file mode 100644 index af3e4f186..000000000 --- a/.github/workflows/build_push.yml +++ /dev/null @@ -1,109 +0,0 @@ -name: CI -on: - push: - branches: - - main - tags: - - v* - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - build: - name: Build app - runs-on: 'ubuntu-24.04' - - steps: - - name: Clone repo - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - - 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@017a9effdb900e5b5b2fddfb590a105619dca3c3 # v4.4.2 - - - name: Check code format - run: ./gradlew spotlessCheck - - - name: Build app - run: ./gradlew assembleRelease -Pinclude-telemetry -Penable-updater - - - name: Run unit tests - run: ./gradlew testReleaseUnitTest - - - name: Upload APK - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 - with: - name: arm64-v8a-${{ github.sha }} - path: app/build/outputs/apk/release/app-arm64-v8a-release-unsigned.apk - - - name: Upload mapping - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 - with: - name: mapping-${{ github.sha }} - path: app/build/outputs/mapping/release - - # Sign APK and create release for tags - - - name: Get tag name - if: startsWith(github.ref, 'refs/tags/') && github.repository == 'mihonapp/mihon' - run: | - set -x - echo "VERSION_TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV - - - name: Sign APK - if: startsWith(github.ref, 'refs/tags/') && github.repository == 'mihonapp/mihon' - uses: r0adkll/sign-android-release@f30bdd30588842ac76044ecdbd4b6d0e3e813478 - with: - releaseDirectory: app/build/outputs/apk/release - signingKeyBase64: ${{ secrets.SIGNING_KEY }} - alias: ${{ secrets.ALIAS }} - keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }} - keyPassword: ${{ secrets.KEY_PASSWORD }} - env: - BUILD_TOOLS_VERSION: '35.0.1' - - - name: Clean up build artifacts - if: startsWith(github.ref, 'refs/tags/') && github.repository == 'mihonapp/mihon' - run: | - set -e - - mv app/build/outputs/apk/release/app-universal-release-unsigned-signed.apk mihon-${{ env.VERSION_TAG }}.apk - mv app/build/outputs/apk/release/app-arm64-v8a-release-unsigned-signed.apk mihon-arm64-v8a-${{ env.VERSION_TAG }}.apk - mv app/build/outputs/apk/release/app-armeabi-v7a-release-unsigned-signed.apk mihon-armeabi-v7a-${{ env.VERSION_TAG }}.apk - mv app/build/outputs/apk/release/app-x86-release-unsigned-signed.apk mihon-x86-${{ env.VERSION_TAG }}.apk - mv app/build/outputs/apk/release/app-x86_64-release-unsigned-signed.apk mihon-x86_64-${{ env.VERSION_TAG }}.apk - - - name: Create Release - if: startsWith(github.ref, 'refs/tags/') && github.repository == 'mihonapp/mihon' - uses: softprops/action-gh-release@72f2c25fcb47643c292f7107632f7a47c1df5cd8 # v2.3.2 - with: - tag_name: ${{ env.VERSION_TAG }} - name: Mihon ${{ env.VERSION_TAG }} - body: | - Check out the [past release notes](https://github.com/mihonapp/mihon/releases) if you’re upgrading from an earlier version. Consider [donating via Open Collective](https://opencollective.com/mihon/contribute) to help keep Mihon improving! - - --- - - - - - - > [!TIP] - > - > ### If you are unsure which version to download then go with `mihon-${{ env.VERSION_TAG }}.apk` - files: | - mihon-${{ env.VERSION_TAG }}.apk - mihon-arm64-v8a-${{ env.VERSION_TAG }}.apk - mihon-armeabi-v7a-${{ env.VERSION_TAG }}.apk - mihon-x86-${{ env.VERSION_TAG }}.apk - mihon-x86_64-${{ env.VERSION_TAG }}.apk - draft: true - prerelease: false - token: ${{ secrets.MIHON_BOT_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..e78d5ea7a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,171 @@ +name: Release +on: + push: + tags: + - v* + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + get_tag: + if: github.repository == 'mihonapp/mihon' + name: Extract tag name + runs-on: 'ubuntu-24.04' + outputs: + tag: ${{ steps.extract.outputs.tag }} + + steps: + - name: Get tag name + id: extract + run: echo "tag=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT + + build: + if: github.repository == 'mihonapp/mihon' + name: Build + runs-on: 'ubuntu-24.04' + needs: get_tag + + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - 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@017a9effdb900e5b5b2fddfb590a105619dca3c3 # v4.4.2 + + - name: Build + run: ./gradlew assembleRelease -Pinclude-telemetry -Penable-updater + + - name: Sign APK + uses: r0adkll/sign-android-release@f30bdd30588842ac76044ecdbd4b6d0e3e813478 + with: + releaseDirectory: app/build/outputs/apk/release + signingKeyBase64: ${{ secrets.SIGNING_KEY }} + alias: ${{ secrets.ALIAS }} + keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }} + keyPassword: ${{ secrets.KEY_PASSWORD }} + env: + BUILD_TOOLS_VERSION: '35.0.1' + + - name: Rename APK + run: | + set -e + + mv app/build/outputs/apk/release/app-universal-release-unsigned-signed.apk mihon-${{ needs.get_tag.outputs.tag }}.apk + mv app/build/outputs/apk/release/app-arm64-v8a-release-unsigned-signed.apk mihon-arm64-v8a-${{ needs.get_tag.outputs.tag }}.apk + mv app/build/outputs/apk/release/app-armeabi-v7a-release-unsigned-signed.apk mihon-armeabi-v7a-${{ needs.get_tag.outputs.tag }}.apk + mv app/build/outputs/apk/release/app-x86-release-unsigned-signed.apk mihon-x86-${{ needs.get_tag.outputs.tag }}.apk + mv app/build/outputs/apk/release/app-x86_64-release-unsigned-signed.apk mihon-x86_64-${{ needs.get_tag.outputs.tag }}.apk + + - name: Upload APK + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: mihon + path: | + mihon-${{ needs.get_tag.outputs.tag }}.apk + mihon-arm64-v8a-${{ needs.get_tag.outputs.tag }}.apk + mihon-armeabi-v7a-${{ needs.get_tag.outputs.tag }}.apk + mihon-x86-${{ needs.get_tag.outputs.tag }}.apk + mihon-x86_64-${{ needs.get_tag.outputs.tag }}.apk + + build_foss: + if: github.repository == 'mihonapp/mihon' + name: Build (FOSS) + runs-on: ubuntu-24.04 + needs: get_tag + + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - 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@017a9effdb900e5b5b2fddfb590a105619dca3c3 # v4.4.2 + with: + cache-disabled: true + + - name: Build + run: ./gradlew assembleFoss -Penable-updater + + - name: Sign APK + uses: r0adkll/sign-android-release@f30bdd30588842ac76044ecdbd4b6d0e3e813478 + with: + releaseDirectory: app/build/outputs/apk/foss + signingKeyBase64: ${{ secrets.SIGNING_KEY }} + alias: ${{ secrets.ALIAS }} + keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }} + keyPassword: ${{ secrets.KEY_PASSWORD }} + env: + BUILD_TOOLS_VERSION: '35.0.1' + + - name: Rename APK + run: | + set -e + + mv app/build/outputs/apk/foss/app-universal-foss-unsigned-signed.apk mihon-${{ needs.get_tag.outputs.tag }}-foss.apk + + - name: Upload APK + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: mihon-foss + path: mihon-${{ needs.get_tag.outputs.tag }}-foss.apk + + release: + if: github.repository == 'mihonapp/mihon' + name: Create GitHub Release + runs-on: ubuntu-24.04 + needs: [get_tag, build, build_foss] + + steps: + - name: Download all artifacts + uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 + with: + merge-multiple: true + + - name: Delete all artifacts + uses: geekyeggo/delete-artifact@f275313e70c08f6120db482d7a6b98377786765b # v5.1.0 + with: + failOnError: false + name: | + mihon + mihon-foss + + - name: Create GitHub Release + uses: softprops/action-gh-release@72f2c25fcb47643c292f7107632f7a47c1df5cd8 # v2.3.2 + with: + tag_name: ${{ needs.get_tag.outputs.tag }} + name: Mihon ${{ needs.get_tag.outputs.tag }} + body: | + Check out the [past release notes](https://github.com/mihonapp/mihon/releases) if you’re upgrading from an earlier version. Consider [donating via Open Collective](https://opencollective.com/mihon/contribute) to help keep Mihon improving! + + + + + + + + > [!TIP] + > + > ### If you are unsure which version to download then go with `mihon-${{ needs.get_tag.outputs.tag }}.apk` + files: | + mihon-${{ needs.get_tag.outputs.tag }}.apk + mihon-${{ needs.get_tag.outputs.tag }}-foss.apk + mihon-arm64-v8a-${{ needs.get_tag.outputs.tag }}.apk + mihon-armeabi-v7a-${{ needs.get_tag.outputs.tag }}.apk + mihon-x86-${{ needs.get_tag.outputs.tag }}.apk + mihon-x86_64-${{ needs.get_tag.outputs.tag }}.apk + draft: true + prerelease: false + token: ${{ secrets.MIHON_BOT_TOKEN }}