From 0be23abc475e12719215b740f32ff6c55375a4f5 Mon Sep 17 00:00:00 2001 From: Stadnik Andrii Date: Sun, 18 May 2025 10:28:56 +0300 Subject: [PATCH 1/6] Update a thing --- .github/workflows/CD.yml | 2 +- .github/workflows/CI_CD.yml | 205 +++++++++++++++++++++++ .github/workflows/build_and_test_bot.yml | 2 +- .github/workflows/build_flutter_apk.yml | 2 +- 4 files changed, 208 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/CI_CD.yml diff --git a/.github/workflows/CD.yml b/.github/workflows/CD.yml index af0ab8c0..9de36ed3 100644 --- a/.github/workflows/CD.yml +++ b/.github/workflows/CD.yml @@ -21,7 +21,7 @@ jobs: if: github.base_ref == 'main' run: curl -L "docs.google.com/spreadsheets/d/${{ secrets.SHEET_ID }}/gviz/tq?tqx=out:csv&sheet=Ukrainian" -o table.csv - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 if: inputs.upload-artifact with: name: table diff --git a/.github/workflows/CI_CD.yml b/.github/workflows/CI_CD.yml new file mode 100644 index 00000000..5916229f --- /dev/null +++ b/.github/workflows/CI_CD.yml @@ -0,0 +1,205 @@ +name: Build, test and deploy + +on: + push: + branches: + - "dev" + # - "main" + pull_request: + branches: + # - "dev" + - "main" + +concurrency: + group: ${{ github.event_name }} + +env: + CARGO_TERM_COLOR: always + +jobs: + build_and_test_bot: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + # - name: Install Rust + # run: rustup update stable + - uses: Swatinem/rust-cache@v2 + - name: Download the table + if: ${{ github.event_name == 'pull_request' }} + run: curl -L "docs.google.com/spreadsheets/d/${{ secrets.SHEET_ID }}/gviz/tq?tqx=out:csv&sheet=Ukrainian" -o table.csv + + - run: cargo test + env: + SHEET_ID: ${{ secrets.SHEET_ID }} + + - name: Build release + if: ${{ github.event_name == 'pull_request' }} + env: + SHEET_ID: ${{ secrets.SHEET_ID }} + run: cargo build --release + + - name: Build debug + if: ${{ github.event_name == 'pull_request' }} + env: + SHEET_ID: ${{ secrets.SHEET_ID }} + run: cargo build + + - name: Move binary + run: mv target/*/bot target + + - uses: actions/upload-artifact@v4 + with: + name: executable + path: target/bot + + - uses: actions/upload-artifact@v4 + if: ${{ github.event_name == 'pull_request' }} + with: + name: table + path: table.csv + + build_flutter_apk: + runs-on: ubuntu-latest + defaults: + run: + working-directory: app + steps: + - uses: actions/checkout@v3 + - uses: extractions/setup-just@v1 + - uses: subosito/flutter-action@v2 + with: + channel: "stable" + cache: true + - uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: '11' + cache: 'gradle' + - uses: dtolnay/rust-toolchain@stable + with: + targets: aarch64-linux-android, armv7-linux-androideabi, x86_64-linux-android, i686-linux-android + - uses: Swatinem/rust-cache@v2 + - uses: baptiste0928/cargo-install@v2 + with: + crate: flutter_rust_bridge_codegen + - uses: baptiste0928/cargo-install@v2 + with: + crate: cargo-ndk + - run: just + # - run: cargo build + # env: + # SHEET_ID: ${{ secrets.SHEET_ID }} + # - run: flutter test + - run: flutter build apk --release + env: + SHEET_ID: ${{ secrets.SHEET_ID }} + # https://github.com/actions/upload-artifact/issues/294 + - uses: actions/upload-artifact@v4 + with: + name: apk + if-no-files-found: error + path: app/build/app/outputs/flutter-apk/app-release.apk + + deploy: + runs-on: [self-hosted] + needs: [build_and_test_bot,build_flutter_apk] + environment: ${{ github.event_name == 'pull_request' && 'main' || 'dev '}} + + steps: + - uses: actions/checkout@v3 + - uses: actions/download-artifact@v3 + with: + name: executable + path: bin/bot + + - uses: actions/download-artifact@v3 + if: ${{ github.event_name == 'pull_request' }} + with: + name: table + + - name: Restart bot + env: + TELOXIDE_TOKEN: ${{ secrets.TELOXIDE_TOKEN }} + run: | + docker build -t first_aid_bot:${{ github.event_name == 'pull_request' && 'main' || 'dev '}} . + docker compose -f docker-compose_${{ github.event_name == 'pull_request' && 'main' || 'dev '}}.yml -p ${{ github.event_name == 'pull_request' && 'main' || 'dev '}}_bot up -d + + release: + runs-on: ubuntu-latest + needs: [build_and_test_bot,build_flutter_apk] + if: ${{ github.event_name == 'pull_request' && startsWith(github.ref, 'refs/tags/') }} + steps: + - uses: actions/checkout@v3 + - uses: actions/download-artifact@v3 + with: + name: table + - uses: actions/download-artifact@v3 + with: + name: executable + - uses: actions/download-artifact@v3 + with: + name: apk + - name: Release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + generate_release_notes: true + files: | + app-release.apk + table.csv + first_aid_bot + + # notify: + # runs-on: ubuntu-latest + # needs: [deploy, release] + # + # steps: + # - uses: actions/download-artifact@v3 + # with: + # name: table + # + # - name: send telegram message on push + # uses: appleboy/telegram-action@master + # if: ${{ always() && github.event_name == 'pull_request' && !contains(needs.*.result, 'failure') }} + # with: + # to: ${{ secrets.TELEGRAM_TO }} + # token: ${{ secrets.TELEGRAM_TOKEN }} + # document: table.csv + # message: | + # ${{ github.actor }} created commit: + # Commit message: ${{ github.event.commits[0].message }} + # + # See changes: https://github.com/${{ github.repository }}/actions/runs/${{github.sha}} + # See error: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} + # Successfully deployed! 🙆 + # + # - name: send telegram message on push + # uses: appleboy/telegram-action@master + # if: ${{ always() && github.event_name == 'pull_request' && contains(needs.*.result, 'failure') }} + # with: + # to: ${{ secrets.TELEGRAM_TO }} + # token: ${{ secrets.TELEGRAM_TOKEN }} + # document: table.csv + # message: | + # ${{ github.actor }} created commit: + # Commit message: ${{ github.event.commits[0].message }} + # + # See changes: https://github.com/${{ github.repository }}/actions/runs/${{github.sha}} + # See error: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} + # The commit fails to build or tests have failed! 💣 + + # It should wait untill all checks will pass + auto-merge: + needs: [build_and_test_bot,build_flutter_apk] + runs-on: ubuntu-latest + if: ${{ github.event_name == 'pull_request' }} + permissions: + pull-requests: write + contents: write + steps: + - uses: fastify/github-action-merge-dependabot@v3 + with: + target: minor + github-token: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/build_and_test_bot.yml b/.github/workflows/build_and_test_bot.yml index 5903a615..ab9b4a00 100644 --- a/.github/workflows/build_and_test_bot.yml +++ b/.github/workflows/build_and_test_bot.yml @@ -42,7 +42,7 @@ jobs: if: inputs.upload-artifact run: mv target/*/bot target - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 if: inputs.upload-artifact with: name: executable diff --git a/.github/workflows/build_flutter_apk.yml b/.github/workflows/build_flutter_apk.yml index 5334ec94..725ce532 100644 --- a/.github/workflows/build_flutter_apk.yml +++ b/.github/workflows/build_flutter_apk.yml @@ -48,7 +48,7 @@ jobs: - run: flutter build apk --release env: SHEET_ID: ${{ secrets.SHEET_ID }} - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 if: inputs.upload-artifact with: name: apk From 77aa59b50f43212af60aeab96ff94a33545e591d Mon Sep 17 00:00:00 2001 From: Stadnik Andrii Date: Sun, 18 May 2025 10:29:48 +0300 Subject: [PATCH 2/6] Update ubuntu --- .github/workflows/build_and_test_bot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test_bot.yml b/.github/workflows/build_and_test_bot.yml index ab9b4a00..5ad35a56 100644 --- a/.github/workflows/build_and_test_bot.yml +++ b/.github/workflows/build_and_test_bot.yml @@ -14,7 +14,7 @@ on: jobs: build_and_test_bot: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 From a84eada92a7156d84433f0c7098fe24062332d1e Mon Sep 17 00:00:00 2001 From: Stadnik Andrii Date: Sun, 18 May 2025 10:46:13 +0300 Subject: [PATCH 3/6] Fix --- .github/workflows/build_and_test_bot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test_bot.yml b/.github/workflows/build_and_test_bot.yml index 5ad35a56..35de8a04 100644 --- a/.github/workflows/build_and_test_bot.yml +++ b/.github/workflows/build_and_test_bot.yml @@ -22,7 +22,7 @@ jobs: - uses: Swatinem/rust-cache@v2 - name: Download the table if: inputs.release - run: curl -L "docs.google.com/spreadsheets/d/${{ secrets.SHEET_ID }}/gviz/tq?tqx=out:csv&sheet=Ukrainian" -o table.csv + run: curl -L "docs.google.com/spreadsheets/d/${{ variables.SHEET_ID }}/gviz/tq?tqx=out:csv&sheet=Ukrainian" -o table.csv - name: Test and build release if: inputs.release From a539ec05be8da75d78b4e14a57cc2d0a19853cd4 Mon Sep 17 00:00:00 2001 From: Stadnik Andrii Date: Sun, 18 May 2025 10:47:47 +0300 Subject: [PATCH 4/6] IDK --- .github/workflows/CI_CD.yml | 205 ------------------------------------ 1 file changed, 205 deletions(-) delete mode 100644 .github/workflows/CI_CD.yml diff --git a/.github/workflows/CI_CD.yml b/.github/workflows/CI_CD.yml deleted file mode 100644 index 5916229f..00000000 --- a/.github/workflows/CI_CD.yml +++ /dev/null @@ -1,205 +0,0 @@ -name: Build, test and deploy - -on: - push: - branches: - - "dev" - # - "main" - pull_request: - branches: - # - "dev" - - "main" - -concurrency: - group: ${{ github.event_name }} - -env: - CARGO_TERM_COLOR: always - -jobs: - build_and_test_bot: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable - # - name: Install Rust - # run: rustup update stable - - uses: Swatinem/rust-cache@v2 - - name: Download the table - if: ${{ github.event_name == 'pull_request' }} - run: curl -L "docs.google.com/spreadsheets/d/${{ secrets.SHEET_ID }}/gviz/tq?tqx=out:csv&sheet=Ukrainian" -o table.csv - - - run: cargo test - env: - SHEET_ID: ${{ secrets.SHEET_ID }} - - - name: Build release - if: ${{ github.event_name == 'pull_request' }} - env: - SHEET_ID: ${{ secrets.SHEET_ID }} - run: cargo build --release - - - name: Build debug - if: ${{ github.event_name == 'pull_request' }} - env: - SHEET_ID: ${{ secrets.SHEET_ID }} - run: cargo build - - - name: Move binary - run: mv target/*/bot target - - - uses: actions/upload-artifact@v4 - with: - name: executable - path: target/bot - - - uses: actions/upload-artifact@v4 - if: ${{ github.event_name == 'pull_request' }} - with: - name: table - path: table.csv - - build_flutter_apk: - runs-on: ubuntu-latest - defaults: - run: - working-directory: app - steps: - - uses: actions/checkout@v3 - - uses: extractions/setup-just@v1 - - uses: subosito/flutter-action@v2 - with: - channel: "stable" - cache: true - - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: '11' - cache: 'gradle' - - uses: dtolnay/rust-toolchain@stable - with: - targets: aarch64-linux-android, armv7-linux-androideabi, x86_64-linux-android, i686-linux-android - - uses: Swatinem/rust-cache@v2 - - uses: baptiste0928/cargo-install@v2 - with: - crate: flutter_rust_bridge_codegen - - uses: baptiste0928/cargo-install@v2 - with: - crate: cargo-ndk - - run: just - # - run: cargo build - # env: - # SHEET_ID: ${{ secrets.SHEET_ID }} - # - run: flutter test - - run: flutter build apk --release - env: - SHEET_ID: ${{ secrets.SHEET_ID }} - # https://github.com/actions/upload-artifact/issues/294 - - uses: actions/upload-artifact@v4 - with: - name: apk - if-no-files-found: error - path: app/build/app/outputs/flutter-apk/app-release.apk - - deploy: - runs-on: [self-hosted] - needs: [build_and_test_bot,build_flutter_apk] - environment: ${{ github.event_name == 'pull_request' && 'main' || 'dev '}} - - steps: - - uses: actions/checkout@v3 - - uses: actions/download-artifact@v3 - with: - name: executable - path: bin/bot - - - uses: actions/download-artifact@v3 - if: ${{ github.event_name == 'pull_request' }} - with: - name: table - - - name: Restart bot - env: - TELOXIDE_TOKEN: ${{ secrets.TELOXIDE_TOKEN }} - run: | - docker build -t first_aid_bot:${{ github.event_name == 'pull_request' && 'main' || 'dev '}} . - docker compose -f docker-compose_${{ github.event_name == 'pull_request' && 'main' || 'dev '}}.yml -p ${{ github.event_name == 'pull_request' && 'main' || 'dev '}}_bot up -d - - release: - runs-on: ubuntu-latest - needs: [build_and_test_bot,build_flutter_apk] - if: ${{ github.event_name == 'pull_request' && startsWith(github.ref, 'refs/tags/') }} - steps: - - uses: actions/checkout@v3 - - uses: actions/download-artifact@v3 - with: - name: table - - uses: actions/download-artifact@v3 - with: - name: executable - - uses: actions/download-artifact@v3 - with: - name: apk - - name: Release - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - with: - generate_release_notes: true - files: | - app-release.apk - table.csv - first_aid_bot - - # notify: - # runs-on: ubuntu-latest - # needs: [deploy, release] - # - # steps: - # - uses: actions/download-artifact@v3 - # with: - # name: table - # - # - name: send telegram message on push - # uses: appleboy/telegram-action@master - # if: ${{ always() && github.event_name == 'pull_request' && !contains(needs.*.result, 'failure') }} - # with: - # to: ${{ secrets.TELEGRAM_TO }} - # token: ${{ secrets.TELEGRAM_TOKEN }} - # document: table.csv - # message: | - # ${{ github.actor }} created commit: - # Commit message: ${{ github.event.commits[0].message }} - # - # See changes: https://github.com/${{ github.repository }}/actions/runs/${{github.sha}} - # See error: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} - # Successfully deployed! 🙆 - # - # - name: send telegram message on push - # uses: appleboy/telegram-action@master - # if: ${{ always() && github.event_name == 'pull_request' && contains(needs.*.result, 'failure') }} - # with: - # to: ${{ secrets.TELEGRAM_TO }} - # token: ${{ secrets.TELEGRAM_TOKEN }} - # document: table.csv - # message: | - # ${{ github.actor }} created commit: - # Commit message: ${{ github.event.commits[0].message }} - # - # See changes: https://github.com/${{ github.repository }}/actions/runs/${{github.sha}} - # See error: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} - # The commit fails to build or tests have failed! 💣 - - # It should wait untill all checks will pass - auto-merge: - needs: [build_and_test_bot,build_flutter_apk] - runs-on: ubuntu-latest - if: ${{ github.event_name == 'pull_request' }} - permissions: - pull-requests: write - contents: write - steps: - - uses: fastify/github-action-merge-dependabot@v3 - with: - target: minor - github-token: "${{ secrets.GITHUB_TOKEN }}" From dfedd000301836dbb156f9e8fe2ef2d91dc14797 Mon Sep 17 00:00:00 2001 From: Stadnik Andrii Date: Sun, 18 May 2025 11:27:39 +0300 Subject: [PATCH 5/6] Update build_and_test_bot.yml --- .github/workflows/build_and_test_bot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test_bot.yml b/.github/workflows/build_and_test_bot.yml index 35de8a04..eb4f77b5 100644 --- a/.github/workflows/build_and_test_bot.yml +++ b/.github/workflows/build_and_test_bot.yml @@ -22,7 +22,7 @@ jobs: - uses: Swatinem/rust-cache@v2 - name: Download the table if: inputs.release - run: curl -L "docs.google.com/spreadsheets/d/${{ variables.SHEET_ID }}/gviz/tq?tqx=out:csv&sheet=Ukrainian" -o table.csv + run: curl -L "docs.google.com/spreadsheets/d/${{ vars.SHEET_ID }}/gviz/tq?tqx=out:csv&sheet=Ukrainian" -o table.csv - name: Test and build release if: inputs.release From e1e0767fadeb4ea86bc27f18104bd74a2bf28e47 Mon Sep 17 00:00:00 2001 From: Stadnik Andrii Date: Sun, 18 May 2025 11:59:16 +0300 Subject: [PATCH 6/6] Update --- .github/workflows/build_and_test_bot.yml | 4 ++-- app/android/settings.gradle | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_and_test_bot.yml b/.github/workflows/build_and_test_bot.yml index eb4f77b5..77fdead9 100644 --- a/.github/workflows/build_and_test_bot.yml +++ b/.github/workflows/build_and_test_bot.yml @@ -28,14 +28,14 @@ jobs: if: inputs.release env: SHEET_ID: ${{ secrets.SHEET_ID }} - RUST_LOG: info + RUST_LOG: info run: cargo test --release -- --nocapture && cargo build --release - name: Test and build debug if: ${{ !inputs.release }} env: SHEET_ID: ${{ secrets.SHEET_ID }} - RUST_LOG: info + RUST_LOG: info run: cargo test -- --nocapture && cargo build - name: Move binary diff --git a/app/android/settings.gradle b/app/android/settings.gradle index 1d6d19b7..0f9d8c91 100644 --- a/app/android/settings.gradle +++ b/app/android/settings.gradle @@ -19,7 +19,7 @@ pluginManagement { plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" - id "com.android.application" version "7.3.0" apply false + id "com.android.application" version "8.1.0" apply false id "org.jetbrains.kotlin.android" version "1.7.10" apply false }