From 7ebfaaf477281f08b14f8f5df63382d647915cbe Mon Sep 17 00:00:00 2001 From: ardocrat Date: Fri, 23 Jan 2026 11:20:15 +0100 Subject: [PATCH] ci: separate android runner, github release download, telegram notifications and release upload Reviewed-on: https://code.gri.mw/GUI/grim/pulls/33 --- .forgejo/workflows/android.yaml | 28 ---- .forgejo/workflows/build.yaml | 21 ++- .forgejo/workflows/linux.yaml | 2 +- .forgejo/workflows/macos.yaml | 2 +- .forgejo/workflows/pr.yaml | 20 +++ .forgejo/workflows/release.yaml | 145 +++++++++++++++--- .forgejo/workflows/windows.yaml | 2 +- .github/download_release.sh | 23 +++ .github/workflows/release.yml | 32 ++++ android/app/build.gradle | 5 +- android/app/src/main/AndroidManifest.xml | 3 +- .../java/mw/gri/android/MainActivity.java | 4 - android/build.gradle | 4 +- android/gradle.properties | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- scripts/android.sh | 38 +++-- 16 files changed, 253 insertions(+), 80 deletions(-) delete mode 100644 .forgejo/workflows/android.yaml create mode 100644 .forgejo/workflows/pr.yaml create mode 100644 .github/download_release.sh create mode 100644 .github/workflows/release.yml diff --git a/.forgejo/workflows/android.yaml b/.forgejo/workflows/android.yaml deleted file mode 100644 index a9380bf..0000000 --- a/.forgejo/workflows/android.yaml +++ /dev/null @@ -1,28 +0,0 @@ -on: - workflow_call: - inputs: - version: - required: true - type: string - -jobs: - release: - runs-on: ubuntu - steps: - - uses: actions/checkout@v5 - - run: mkdir release - - name: Setup Java build - run: | - chmod +x android/gradlew - echo "${{ secrets.ANDROID_KEYSTORE }}" > release.keystore.txt - base64 -d release.keystore.txt > android/keystore - echo "${{ secrets.ANDROID_KEYSTORE_PROPS }}" > release.keystore.props.txt - base64 -d release.keystore.props.txt > android/keystore.properties - - name: Release APKs - run: | - chmod +x scripts/android.sh && ./scripts/android.sh release ${{ inputs.version }} - mv android/grim* release - - uses: forgejo/upload-artifact@v4 - with: - name: release_android - path: release/* \ No newline at end of file diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml index 7882796..3c39290 100644 --- a/.forgejo/workflows/build.yaml +++ b/.forgejo/workflows/build.yaml @@ -1,10 +1,11 @@ +name: Test build + on: push: tags-ignore: - "*" branches-ignore: - master - - ci jobs: build: @@ -14,4 +15,20 @@ jobs: with: submodules: recursive - name: Build - run: cargo build --release \ No newline at end of file + run: cargo build --release + - name: Telegram Notify Channel + if: always() + uses: actions/telegram-notifier@ardocrat + with: + token: ${{ secrets.TELEGRAM_BOT_TOKEN }} + chat_id: ${{ secrets.TELEGRAM_CHANNEL_ID }} + status: ${{ job.status }} + notify_fields: "actor,repository,workflow,branch,commit" + - name: Telegram Notify Group + if: always() + uses: actions/telegram-notifier@ardocrat + with: + token: ${{ secrets.TELEGRAM_BOT_TOKEN }} + chat_id: ${{ secrets.TELEGRAM_GROUP_ID }} + status: ${{ job.status }} + notify_fields: "actor,repository,workflow,branch,commit" \ No newline at end of file diff --git a/.forgejo/workflows/linux.yaml b/.forgejo/workflows/linux.yaml index 8ce8b94..c877387 100644 --- a/.forgejo/workflows/linux.yaml +++ b/.forgejo/workflows/linux.yaml @@ -33,7 +33,7 @@ jobs: - name: Checksum AppImage ARM working-directory: release run: sha256sum grim-${{ inputs.version }}-linux-arm.AppImage > grim-${{ inputs.version }}-linux-arm-appimage-sha256sum.txt - - uses: forgejo/upload-artifact@v4 + - uses: actions/upload-artifact@v4 with: name: release_linux path: release/* \ No newline at end of file diff --git a/.forgejo/workflows/macos.yaml b/.forgejo/workflows/macos.yaml index 47bb602..e2decb2 100644 --- a/.forgejo/workflows/macos.yaml +++ b/.forgejo/workflows/macos.yaml @@ -51,7 +51,7 @@ jobs: - name: Checksum Release Universal working-directory: release run: sha256sum grim-${{ inputs.version }}-macos-universal.zip > grim-${{ inputs.version }}-macos-universal-sha256sum.txt - - uses: forgejo/upload-artifact@v4 + - uses: actions/upload-artifact@v4 with: name: release_macos path: release/* \ No newline at end of file diff --git a/.forgejo/workflows/pr.yaml b/.forgejo/workflows/pr.yaml new file mode 100644 index 0000000..ba39dc7 --- /dev/null +++ b/.forgejo/workflows/pr.yaml @@ -0,0 +1,20 @@ +name: Pull Request + +on: + pull_request: + types: + - closed + - opened + +jobs: + notify: + runs-on: ubuntu + + steps: + - name: Telegram Notify Channel + uses: actions/telegram-notifier@ardocrat + with: + token: ${{ secrets.TELEGRAM_BOT_TOKEN }} + chat_id: ${{ secrets.TELEGRAM_CHANNEL_ID }} + status: ${{ job.status }} + notify_fields: "actor,repository" \ No newline at end of file diff --git a/.forgejo/workflows/release.yaml b/.forgejo/workflows/release.yaml index 12c1574..445ee81 100644 --- a/.forgejo/workflows/release.yaml +++ b/.forgejo/workflows/release.yaml @@ -2,7 +2,6 @@ on: push: branches: - master - - ci tags-ignore: - "*-dev*" @@ -12,7 +11,9 @@ jobs: outputs: v: ${{ steps.version.outputs.v }} steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 + with: + submodules: recursive - name: Get version id: version run: | @@ -34,7 +35,7 @@ jobs: echo "exists=${exists}" >> "$FORGEJO_OUTPUT" echo ${exists} mkdir release - - uses: actions/forgejo-release@v2.7.3 + - uses: ardocrat/forgejo-release@grim if: ${{ forgejo.ref_type == 'tag' && steps.check.outputs.exists == 'true' }} with: direction: download @@ -45,7 +46,7 @@ jobs: if: ${{ forgejo.ref_type == 'tag' && steps.check.outputs.exists == 'true' }} working-directory: release run: for f in *; do mv "$f" "$(echo "$f" | sed s/-dev-/-/)"; done - - uses: actions/forgejo-release@v2.7.3 + - uses: ardocrat/forgejo-release@grim if: ${{ forgejo.ref_type == 'tag' && steps.check.outputs.exists == 'true' }} with: direction: upload @@ -56,22 +57,92 @@ jobs: release-dir: ./release release-notes: "" - android: + android_libs: if: ${{ forgejo.ref_type == 'branch' || needs.check.outputs.exists == 'false' }} runs-on: ubuntu needs: version - uses: ./.forgejo/workflows/android.yaml - with: - version: ${{ needs.version.outputs.v }} - secrets: - RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }} - ANDROID_KEYSTORE: ${{ secrets.ANDROID_KEYSTORE }} - ANDROID_KEYSTORE_PROPS: ${{ secrets.ANDROID_KEYSTORE_PROPS }} + steps: + - uses: actions/checkout@v6 + with: + submodules: recursive + - name: Build libs + run: | + chmod +x scripts/android.sh && ./scripts/android.sh lib ${{ needs.version.outputs.v }} + - uses: actions/upload-artifact@v4 + with: + name: libs_android + path: android/app/src/main/jniLibs/* + + android_release: + if: ${{ forgejo.ref_type == 'branch' || needs.check.outputs.exists == 'false' }} + runs-on: ubuntu-android + needs: [version, android_libs] + steps: + - uses: actions/checkout@v6 + with: + submodules: recursive + - run: mkdir libs + - name: Download Libs Artifacts + uses: actions/download-artifact@v4 + with: + path: libs + pattern: libs_* + merge-multiple: true + - name: Setup Java build + run: | + chmod +x android/gradlew + echo "${{ secrets.ANDROID_KEYSTORE }}" > release.keystore.txt + base64 -d release.keystore.txt > android/keystore + echo "${{ secrets.ANDROID_KEYSTORE_PROPS }}" > release.keystore.props.txt + base64 -d release.keystore.props.txt > android/keystore.properties + - name: Prepare build + run: | + mkdir release + chmod +x android/gradlew + - name: Release ARMv7+v8 APK + working-directory: android + run: | + jni_path=app/src/main/jniLibs + mkdir ${jni_path} + mv ../libs/armeabi-v7a ${jni_path} + mv ../libs/arm64-v8a ${jni_path} + ./gradlew assembleSignedRelease + apk_path=app/build/outputs/apk/signedRelease/app-signedRelease.apk + name=grim-${{ needs.version.outputs.v }}-android.apk + mv ${apk_path} "${name}" + - name: Checksum ARM APK + working-directory: android + run: | + name=grim-${{ needs.version.outputs.v }}-android.apk + checksum=grim-${{ needs.version.outputs.v }}-android-sha256sum.txt + sha256sum "${name}" > "${checksum}" + - name: Release x86_64 APK + working-directory: android + run: | + ./gradlew clean + jni_path=app/src/main/jniLibs + rm -rf ${jni_path}/* + mv ../libs/x86_64 ${jni_path} + ./gradlew assembleSignedRelease + apk_path=app/build/outputs/apk/signedRelease/app-signedRelease.apk + name=grim-${{ needs.version.outputs.v }}-android-x86_64.apk + mv ${apk_path} "${name}" + - name: Checksum x86_64 APK + working-directory: android + run: | + name=grim-${{ needs.version.outputs.v }}-android.apk + checksum=grim-${{ needs.version.outputs.v }}-android-x86_64-sha256sum.txt + sha256sum "${name}" > "${checksum}" + - run: mv android/grim* release + - uses: actions/upload-artifact@v4 + with: + name: release_android + path: release/* linux: if: ${{ forgejo.ref_type == 'branch' || needs.check.outputs.exists == 'false' }} runs-on: ubuntu - needs: [version, android] + needs: [version, android_libs, android_release] uses: ./.forgejo/workflows/linux.yaml with: version: ${{ needs.version.outputs.v }} @@ -81,7 +152,7 @@ jobs: macos: if: ${{ forgejo.ref_type == 'branch' || needs.check.outputs.exists == 'false' }} runs-on: ubuntu - needs: [version, android, linux] + needs: [version, android_libs, android_release, linux] uses: ./.forgejo/workflows/macos.yaml with: version: ${{ needs.version.outputs.v }} @@ -91,7 +162,7 @@ jobs: windows: if: ${{ forgejo.ref_type == 'branch' || needs.check.outputs.exists == 'false' }} runs-on: ubuntu - needs: [version, android, linux, macos] + needs: [version, android_libs, android_release, linux, macos] uses: ./.forgejo/workflows/windows.yaml with: version: ${{ needs.version.outputs.v }} @@ -101,16 +172,17 @@ jobs: release: if: ${{ forgejo.ref_type == 'branch' || needs.check.outputs.exists == 'false' }} runs-on: ubuntu - needs: [version, android, linux, macos, windows] + needs: [version, android_libs, android_release, linux, macos, windows] steps: - run: mkdir release - name: Download All Artifacts - uses: forgejo/download-artifact@v4 + uses: actions/download-artifact@v4 with: path: release pattern: release_* merge-multiple: true - - uses: actions/forgejo-release@v2.7.3 + - name: Upload release to Forgejo + uses: ardocrat/forgejo-release@grim with: direction: upload token: ${{ secrets.RELEASE_TOKEN }} @@ -118,4 +190,39 @@ jobs: override: true prerelease: ${{ needs.version.outputs.pre }} release-dir: release - release-notes: "" \ No newline at end of file + release-notes: "" + - name: Telegram Notify Channel + if: always() + uses: actions/telegram-notifier@ardocrat + with: + token: ${{ secrets.TELEGRAM_BOT_TOKEN }} + chat_id: ${{ secrets.TELEGRAM_CHANNEL_ID }} + status: ${{ job.status }} + notify_fields: "actor,repository,workflow,branch,commit" + - name: Telegram Notify Group + if: always() + uses: actions/telegram-notifier@ardocrat + with: + token: ${{ secrets.TELEGRAM_BOT_TOKEN }} + chat_id: ${{ secrets.TELEGRAM_GROUP_ID }} + status: ${{ job.status }} + notify_fields: "actor,repository,workflow,branch,commit" + - name: Upload files to Telegram + uses: actions/tg-file@main + with: + api-url: ${{ secrets.TELEGRAM_API_URL }} + chat-id: | + ${{ secrets.TELEGRAM_CHANNEL_ID }} + ${{ secrets.TELEGRAM_GROUP_ID }} + body: "🎁 Release ${{ needs.version.outputs.v }} is ready!" + token: ${{ secrets.TELEGRAM_BOT_TOKEN }} + pin: true + files: | + release/grim-${{ needs.version.outputs.v }}-android.apk + release/grim-${{ needs.version.outputs.v }}-android-x86_64.apk + release/grim-${{ needs.version.outputs.v }}-linux-arm.AppImage + release/grim-${{ needs.version.outputs.v }}-linux-x86_64.AppImage + release/grim-${{ needs.version.outputs.v }}-macos-arm.zip + release/grim-${{ needs.version.outputs.v }}-macos-x86_64.zip + release/grim-${{ needs.version.outputs.v }}-macos-universal.zip + release/grim-${{ needs.version.outputs.v }}-win-x86_64.zip \ No newline at end of file diff --git a/.forgejo/workflows/windows.yaml b/.forgejo/workflows/windows.yaml index 30dc608..1550579 100644 --- a/.forgejo/workflows/windows.yaml +++ b/.forgejo/workflows/windows.yaml @@ -21,7 +21,7 @@ jobs: - name: Checksum Archive x86 working-directory: release run: sha256sum grim-${{ inputs.version }}-win-x86_64.zip > grim-${{ inputs.version }}-win-x86_64-sha256sum.txt - - uses: forgejo/upload-artifact@v4 + - uses: actions/upload-artifact@v4 with: name: release_windows path: release/* \ No newline at end of file diff --git a/.github/download_release.sh b/.github/download_release.sh new file mode 100644 index 0000000..fba7ac8 --- /dev/null +++ b/.github/download_release.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +HOST=https://code.gri.mw +REPO_NAME=$1 +TAG=$2 +DOWNLOAD_URL=${HOST}/${REPO_NAME}/releases/download/${TAG} + +FILES=( "grim-${TAG}-android.apk" "grim-${TAG}-android-x86_64.apk" "grim-${TAG}-linux-arm.AppImage" "grim-${TAG}-linux-x86_64.AppImage" "grim-${TAG}-macos-arm.zip" "grim-${TAG}-macos-x86_64.zip" "grim-${TAG}-macos-universal.zip" "grim-${TAG}-win-x86_64.zip" ) + +# Download release files +for f in "${FILES[@]}"; do + wget -q ${DOWNLOAD_URL}/${f} + echo Downloading ${f}... + while [ ! -f ${f} ]; do + sleep 5 + echo Retry ${f}... + wget -q ${DOWNLOAD_URL}/${f} + done +done + +# Save release notes +INFO_URL=${HOST}/api/v1/repos/${REPO_NAME}/releases/tags/${TAG} +curl -s "${INFO_URL}" | jq -r '.body' > release_notes.txt \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..d6b3fb6 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,32 @@ +name: Release + +on: + push: + tags: + - "v*.*.*" + +jobs: + create_release: + name: Create Release + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Download release + run: chmod +x .github/download_release.sh && .github/download_release.sh ${{ github.repository }} ${{ github.ref_name }} + - name: Release + uses: softprops/action-gh-release@v2 + with: + body_path: release_notes.txt + overwrite_files: true + files: | + grim-${{ github.ref_name }}-android.apk + grim-${{ github.ref_name }}-android-x86_64.apk + grim-${{ github.ref_name }}-linux-arm.AppImage + grim-${{ github.ref_name }}-linux-x86_64.AppImage + grim-${{ github.ref_name }}-macos-arm.zip + grim-${{ github.ref_name }}-macos-x86_64.zip + grim-${{ github.ref_name }}-macos-universal.zip + grim-${{ github.ref_name }}-win-x86_64.zip \ No newline at end of file diff --git a/android/app/build.gradle b/android/app/build.gradle index fe5641a..03f153c 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -3,8 +3,9 @@ plugins { } android { - compileSdk 36 - ndkVersion '26.0.10792818' + compileSdk = 36 + ndkVersion '29.0.14206865' + buildToolsVersion = '36.1.0' defaultConfig { applicationId "mw.gri.android" diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index f04a90c..5af7b7c 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -5,13 +5,12 @@ - + -