Last active
May 20, 2025 04:23
-
-
Save Nurlan199206/5fd251d01fe14e89c9e071697d03b91f to your computer and use it in GitHub Desktop.
flutter-cicd
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
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/ubuntu/flutter/bin" | |
source /etc/environment | |
export ANDROID_HOME=$HOME/Android | |
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin | |
export PATH=$PATH:$ANDROID_HOME/platform-tools | |
export PATH=$PATH:$ANDROID_HOME/emulator | |
==================================================================================== | |
stages: | |
- build | |
- upload | |
- notify | |
build_apk: | |
stage: build | |
tags: | |
- flutter | |
before_script: | |
- sudo su | |
- export ANDROID_HOME=/home/gitlab-runner/Android | |
- export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin | |
- export PATH=$PATH:$ANDROID_HOME/platform-tools | |
- export PATH=$PATH:$ANDROID_HOME/emulator | |
- export PATH=$PATH:/home/gitlab-runner/flutter/bin | |
script: | |
- ls -l $PWD | |
- cd "$CI_PROJECT_DIR" | |
- java -version | |
- dart run build_runner build --delete-conflicting-outputs | |
- flutter clean | |
- flutter build apk -t lib/main.dart --profile --obfuscate --split-debug-info=build/app/outputs/symbols | |
- pkill -f "java" | |
artifacts: | |
paths: | |
- $CI_PROJECT_DIR/build/app/outputs/apk/profile/app-profile.apk | |
upload: | |
stage: upload | |
variables: | |
URL: "apk.galamatdev.com:5000" | |
TELEGRAM_BOT_TOKEN: "$TELEGRAM_BOT_TOKEN" | |
TELEGRAM_CHAT_ID: "-1001787585240" | |
SANITIZED_BRANCH: "${CI_COMMIT_REF_NAME//\//-}" | |
tags: | |
- flutter | |
before_script: | |
- sudo su | |
script: | |
- cd $CI_PROJECT_DIR/build/app/outputs/apk/profile | |
- ls -l $PWD | |
- mv $CI_PROJECT_DIR/build/app/outputs/apk/profile/app-profile.apk /var/www/html/$(echo "$CI_COMMIT_REF_NAME" | tr '/' '-')-$CI_COMMIT_SHORT_SHA-$(date +%Y-%m-%d).apk | |
notify_telegram: | |
stage: notify | |
tags: | |
- flutter | |
variables: | |
URL: "http://apk.galamatdev.com:5000" | |
TELEGRAM_BOT_TOKEN: "$TELEGRAM_BOT_TOKEN" | |
TELEGRAM_CHAT_ID: "-1001787585240" | |
script: | |
- | | |
curl -X POST \ | |
-H 'Content-Type: application/json' \ | |
-d "{\"message_thread_id\": \"7419\", \"chat_id\": \"-1001787585240\", \"text\": \"New release!\n Branch: ${CI_COMMIT_REF_NAME}\n Commit: ${CI_COMMIT_MESSAGE}\n Commit ID: ${CI_COMMIT_SHORT_SHA}\n\n Uploaded to ${URL}\", \"disable_notification\": true}" \ | |
https://api.telegram.org/bot7494783785:AAFaiWKg5OuQ0kVdcUSKfeGgBhCjk1RTQf4/sendMessage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment