Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
de10afe
add build workflow
AlaaElattar Feb 13, 2025
1cef585
fix workflow error
AlaaElattar Feb 13, 2025
7cb091e
add ANDROID_NDK_VERSION
AlaaElattar Feb 13, 2025
5d871de
build apk using build.sh
AlaaElattar Feb 13, 2025
4b09a8c
WIP: debugging bug
AlaaElattar Feb 13, 2025
ba043d8
WIP: update non-existing directory
AlaaElattar Feb 13, 2025
e5bf2b7
WIP: update non-existing directory
AlaaElattar Feb 13, 2025
e850b3d
fix apk path and debug running build.sh
AlaaElattar Feb 16, 2025
a8630ac
update path
AlaaElattar Feb 16, 2025
bbe0ab7
update path
AlaaElattar Feb 16, 2025
c43859a
WIP: check that api directory exists
AlaaElattar Feb 16, 2025
0fbd021
WIP: debugging
AlaaElattar Feb 16, 2025
c3e9f1d
fix working directory
AlaaElattar Feb 16, 2025
b7191a2
WIP: debugging where the apk is uploaded
AlaaElattar Feb 16, 2025
9e04c45
make uploading path matches build.sh
AlaaElattar Feb 16, 2025
c9e0b39
change building script with debug
AlaaElattar Feb 16, 2025
e308713
build script with local environment
AlaaElattar Feb 16, 2025
6d72870
update path of app-apk
AlaaElattar Feb 16, 2025
74b7e52
update configs in buld.sh when runnign local
AlaaElattar Feb 16, 2025
9f08c07
remove -v from build.sh
AlaaElattar Feb 16, 2025
6627f9c
debug to see exit code of build script
AlaaElattar Feb 16, 2025
bb330f6
fix condition with debug and release modes
AlaaElattar Feb 16, 2025
bdc36cb
hanlde app_config_local issue
AlaaElattar Feb 16, 2025
430d81c
check on flutter version
AlaaElattar Feb 16, 2025
522595b
fix apk renaming
AlaaElattar Feb 16, 2025
46a1933
WIP: debugging the directory of apk
AlaaElattar Feb 17, 2025
87477bc
update artifact path
AlaaElattar Feb 17, 2025
28d2aae
add absolute path
AlaaElattar Feb 17, 2025
75d00bb
WIP: trying absolute path of github
AlaaElattar Feb 17, 2025
f837787
undo latest changes
AlaaElattar Feb 17, 2025
3c728f1
add app/ at starting path of artifact
AlaaElattar Feb 17, 2025
22a9abd
remove NDK version
AlaaElattar Feb 17, 2025
8e844c8
remove space
AlaaElattar Feb 17, 2025
ab47c2c
undo changes in format_analyze.yml
AlaaElattar Feb 17, 2025
69a3a5e
remove unnecessary space
AlaaElattar Feb 17, 2025
1b569eb
comment creating app_config_local from build workflow
AlaaElattar Feb 17, 2025
c210396
remove listing files &&
AlaaElattar Feb 17, 2025
50ddba4
remove listing changes && add -v to build.sh
AlaaElattar Feb 17, 2025
ba54eb5
update workflow handle failures
AlaaElattar Feb 19, 2025
3c2b4e7
test failure of build script
AlaaElattar Feb 19, 2025
45762fa
undo latest change
AlaaElattar Feb 19, 2025
cd6e731
Some fixes to build script (#934)
AhmedHanafy725 Mar 6, 2025
00eb0db
WIP: fix script init
AlaaElattar Mar 6, 2025
7ea4dd0
comment shell: bash && set -e
AlaaElattar Mar 6, 2025
c011197
remove unused logic from script
AlaaElattar Mar 11, 2025
283a89d
fix bug in compoleAndUpload
AlaaElattar Mar 11, 2025
bc6e2aa
remove commented code
AlaaElattar Mar 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build APK

on:
pull_request:
branches:
- development
push:
branches:
- development

jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: app
steps:
- name: Set up Repository
uses: actions/checkout@v4

- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: "3.27.2"
channel: "stable"

- name: Get dependencies
run: flutter pub get

- name: Ensure Build Script is Executable
run: chmod +x build.sh

- name: Run Build Script
# shell: bash
run: |
./build.sh --init
./build.sh --build --production --debug

- name: Verify APK Exists
run: |
if [ ! -f "build/app/outputs/flutter-apk/app-debug.apk" ]; then
echo "APK not found! Build failed."
exit 1
fi

- name: Upload APK Artifact
uses: actions/upload-artifact@v4
with:
name: app-apk
path: app/build/app/outputs/flutter-apk/app-debug.apk
8 changes: 4 additions & 4 deletions app/android/app/build_production
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ android {

signingConfigs {
release {
keyAlias localProperties.getProperty('keyAlias')
keyPassword localProperties.getProperty('keyPassword')
storeFile file(localProperties.getProperty('storeFile'))
storePassword localProperties.getProperty('storePassword')
// keyAlias localProperties.getProperty('keyAlias')
// keyPassword localProperties.getProperty('keyPassword')
// storeFile file(localProperties.getProperty('storeFile'))
// storePassword localProperties.getProperty('storePassword')
}
Comment thread
zaelgohary marked this conversation as resolved.
debug {

Expand Down
8 changes: 4 additions & 4 deletions app/android/app/build_testing
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ android {

signingConfigs {
release {
keyAlias localProperties.getProperty('keyAlias')
keyPassword localProperties.getProperty('keyPassword')
storeFile file(localProperties.getProperty('storeFile'))
storePassword localProperties.getProperty('storePassword')
// keyAlias localProperties.getProperty('keyAlias')
// keyPassword localProperties.getProperty('keyPassword')
// storeFile file(localProperties.getProperty('storeFile'))
// storePassword localProperties.getProperty('storePassword')
}
Comment thread
zaelgohary marked this conversation as resolved.
debug {

Expand Down
52 changes: 26 additions & 26 deletions app/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,21 @@ logcurrent_time=$(date "+%H:%M:%S %d.%m.%Y")
current_time=$(date "+%Y.%m.%d-%H.%M.%S")

compileAndUpload() {
if [[ $2 == "--$5" ]]
if [[ $2 == "--$4" ]]
then
switchConfigs "$5"
switchConfigs "$4"

if [[ $1 == "--run" ]]
then
echo "[$5]: Running."
echo "[$4]: Running."
flutter run -t lib/main.dart
elif [[ $1 == "--switch" ]]
then
echo "[$5]: Switched configs."
echo "[$4]: Switched configs."
else
echo "[$5]: Building apk."
echo "[$4]: Building apk."

setConfigsAndBuild
msgTelegramAndUploadToAppServer "$5" $4
setConfigsAndBuild "$3"
fi

exit 0
Expand All @@ -43,27 +42,19 @@ switchConfigs() {
cp android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_$1.png android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png

cp ios/Runner/Info_$1 ios/Runner/Info.plist

# cp android/app/google-services_$1 android/app/google-services.json
# cp ios/Runner/GoogleService-Info_$1 ios/Runner/GoogleService-Info.plist
}

setConfigsAndBuild() {
sed -i -e "s/githashvalue/$githash/g" lib/helpers/env_config.dart
sed -i -e "s/timevalue/$logcurrent_time/g" lib/helpers/env_config.dart

flutter build apk -t lib/main.dart -v --target-platform android-arm,android-arm64 --release
}

msgTelegramAndUploadToAppServer () {
mv build/app/outputs/apk/release/app-release.apk "build/app/outputs/apk/release/$current_time-TF-Connect-$1-$githash.apk"

scp "build/app/outputs/apk/release/$current_time-TF-Connect-$1-$githash.apk" jimber@192.168.3.10:/opt/apps/threefold/$1/

# curl --http1.1 -s -X POST "https://api.telegram.org/bot868129294:AAEd-UDDSru9zGeGklzWL6mPO33NovuXYqo/sendMessage" -d parse_mode=markdown -d chat_id=-1001186043363 -d parse_mode=markdown -d text="Type: *$1* %0AGit user: *$gituser* %0AGit branch: *$gitbranch* %0AGit hash: *$githash* %0ATime: *$logcurrent_time* %0AMessage: *$2* %0AURL: *https://apps.staging.jimber.io/threefold/$1/*"
# curl --http1.1 -s -X POST "https://api.telegram.org/bot868129294:AAEd-UDDSru9zGeGklzWL6mPO33NovuXYqo/sendDocument" -F chat_id=-1001186043363 -F document="@build/app/outputs/apk/release/$githash-TF-Connect-$1-$current_time.apk"

paplay /usr/share/sounds/gnome/default/alerts/glass.ogg
if [[ "$1" == "--debug" ]]; then
echo "Running local debug build..."
flutter build apk -t lib/main.dart --target-platform android-arm,android-arm64 --debug
else
echo "Running release build..."
flutter build apk -t lib/main.dart --target-platform android-arm,android-arm64 --release
fi
}

generateFile () {
Expand All @@ -87,8 +78,10 @@ then
AndroidManifestMainPath=android/app/src/main/AndroidManifest.xml
AndroidManifestDebugPath=android/app/src/debug/AndroidManifest.xml


env_configFilePath=lib/helpers/env_config.dart
AppConfigLocalFilePath=lib/app_config_local.dart
ReflectablePath=lib/main.reflectable.dart

BuildGradlePath=android/app/build.gradle

Expand All @@ -113,13 +106,20 @@ then
generateFile $AndroidManifestMainPath android/app/src/main/AndroidManifest_local
generateFile $AndroidManifestDebugPath android/app/src/main/AndroidManifest_local

if ! test -f $ReflectablePath; then
echo "$ReflectablePath doesn't exist, generating ..."
dart run build_runner build
else
echo "$1 already exists."
fi

exit 0
fi

compileAndUpload "$1" "$2" "$3" "$4" "local"
compileAndUpload "$1" "$2" "$3" "$4" "testing"
compileAndUpload "$1" "$2" "$3" "$4" "staging"
compileAndUpload "$1" "$2" "$3" "$4" "production"
compileAndUpload "$1" "$2" "$3" "local"
compileAndUpload "$1" "$2" "$3" "testing"
compileAndUpload "$1" "$2" "$3" "staging"
compileAndUpload "$1" "$2" "$3" "production"

echo "Syntax error."
echo "Usage: ./build.sh --[[run|build|switch]] --[[local|testing|staging|production]]"
Expand Down