Skip to content

Commit

Permalink
feat: Support productFlavor
Browse files Browse the repository at this point in the history
  • Loading branch information
fwh1990 committed Apr 9, 2020
1 parent 845f5a1 commit 69f5ddf
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 26 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ npx upload-pgy --no-android
npx upload-pgy --no-ios

# 安卓默认打包release版本,可以改成debug版本
npx upload-pgy --debug
npx upload-pgy --variant=debug
```

### fir.im
Expand All @@ -139,7 +139,7 @@ npx upload-fir --no-android
npx upload-fir --no-ios

# 安卓默认打包release版本,可以改成debug版本
npx upload-fir --debug
npx upload-fir --variant=debug
```

### App Store
Expand All @@ -164,6 +164,9 @@ npx upload-tf
### 同时打包android和ios
```bash
npx upload-build --ios-export-plist path/to/xxx.plist

# 安卓默认打包release版本,可以改成debug版本
npx upload-build --ios-export-plist path/to/xxx.plist --variant=debug
```


Expand Down
8 changes: 5 additions & 3 deletions src/build-android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ libs=$dir/libs

echo -e "\n\033[32mBuilding android app...\033[0m\n"

pack_type=$(node $libs/pack-type.js "$@")
eval $(node $libs/pack-type.js "$@")
# pack_variant=
# pack_output_path=

bash $libs/build-android.sh $pack_type
bash $libs/build-android.sh $pack_variant

echo -e "\nView apk file at: \033[32m./android/app/build/outputs/apk/$pack_type\033[0m\n"
echo -e "\nView apk file at: \033[32m./android/app/build/outputs/apk/$pack_output_path\033[0m\n"
9 changes: 6 additions & 3 deletions src/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@ ios_app_save_dir=./ios/build/app-$(date +%Y-%m-%d-%H-%M-%S)

echo -e "\n\033[32mBuilding android app...\033[0m\n"

pack_type=$(node $libs/pack-type.js "$@")
bash $libs/build-android.sh $pack_type
eval $(node $libs/pack-type.js "$@")
# pack_variant=
# pack_output_path=

bash $libs/build-android.sh $pack_variant

echo -e "\n\033[32mBuilding ios app...\033[0m\n"

bash $libs/archive.sh
bash $libs/export-ipa.sh $ios_export_plist $ios_app_save_dir

echo -e "\nView apk file at: \033[32m./android/app/build/outputs/apk/release\033[0m"
echo -e "\nView apk file at: \033[32m./android/app/build/outputs/apk/$pack_output_path\033[0m"
echo -e "\nView ipa file at: \033[32m$ios_app_save_dir\033[0m\n"
9 changes: 2 additions & 7 deletions src/libs/build-android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,14 @@

set -e

pack_type=$1
pack_variant=$1

# Build for android
# The apk file will be at
# android/app/build/outputs/apk/app-release.apk
cd android
rm -rf build/ app/build/

if [ $pack_type = "debug" ]
then
./gradlew assembleDebug
else
./gradlew assembleRelease
fi
eval "./gradlew assemble$pack_variant"

cd -
16 changes: 11 additions & 5 deletions src/libs/pack-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ const minimist = require('minimist');

const args = minimist(process.argv.slice(2));

let releaseType = 'release';

if (args.debug === true) {
releaseType = 'debug';
if (!args.variant || typeof args.variant !== 'string') {
args.variant = 'release';
}

console.log(releaseType);
// path is case-insensitive on macos
const packVariant = args.variant.toLowerCase();

console.log(
`
pack_variant=${packVariant}
pack_output_path=${packVariant.replace(/^(.*)(release|debug)$/, '$1/$2')}
`
);
8 changes: 5 additions & 3 deletions src/upload-fir.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ else
echo -e "\033[32m[$log_prefix] Building android app...\033[0m"
sleep 1

pack_type=$(node $libs/pack-type.js "$@")
eval $(node $libs/pack-type.js "$@")
# pack_variant=
# pack_output_path=

sh $libs/build-android.sh $pack_type
sh $libs/build-android.sh $pack_variant

android_app=$(ls -l ./android/app/build/outputs/apk/$pack_type/*.apk | tail -n 1 | awk '{print $NF}')
android_app=$(ls -l ./android/app/build/outputs/apk/$pack_output_path/*.apk | tail -n 1 | awk '{print $NF}')
apk_info=$(node $libs/apk-info.js $android_app)
eval "$apk_info"
fi
Expand Down
8 changes: 5 additions & 3 deletions src/upload-pgy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ else
echo -e "\033[32m[$log_prefix] Building android app...\033[0m"
sleep 1

pack_type=$(node $libs/pack-type.js "$@")
eval $(node $libs/pack-type.js "$@")
# pack_variant=
# pack_output_path=

sh $libs/build-android.sh $pack_type
android_app=$(ls -l ./android/app/build/outputs/apk/$pack_type/*.apk | tail -n 1 | awk '{print $NF}')
sh $libs/build-android.sh $pack_variant
android_app=$(ls -l ./android/app/build/outputs/apk/$pack_output_path/*.apk | tail -n 1 | awk '{print $NF}')
fi

if [ $ios -eq 0 ]
Expand Down

0 comments on commit 69f5ddf

Please sign in to comment.