Skip to content

Commit

Permalink
Merge branch 'main' of github.com:lyrasoft/authman-app
Browse files Browse the repository at this point in the history
  • Loading branch information
asika32764 committed Jun 23, 2024
2 parents 31ea347 + bf4ca87 commit 0f07608
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 8 deletions.
16 changes: 16 additions & 0 deletions bin/functions/cross-replace.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

case "$OSTYPE" in
darwin*) PLATFORM="OSX" ;;
linux*) PLATFORM="LINUX" ;;
bsd*) PLATFORM="BSD" ;;
*) PLATFORM="UNKNOWN" ;;
esac

replace() {
if [[ "$PLATFORM" == "OSX" || "$PLATFORM" == "BSD" ]]; then
sed -i "" "$1" "$2"
else
sed -i "$1" "$2"
fi
}
15 changes: 15 additions & 0 deletions bin/new-version-android.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#! /bin/sh

source $(dirname $0)/functions/cross-replace.sh

if [[ -z "$1" ]]; then
echo "Error: Please provide a version string."
exit 1
fi

CONFIG_FILE=$(realpath $(dirname $0)/../android/app/build.gradle)
NEW_VERSION="$1"

replace "s/versionName \"[^\"]*\"/versionName \"$NEW_VERSION\"/g" "$CONFIG_FILE"

echo "Update Android versionName to: $NEW_VERSION"
14 changes: 14 additions & 0 deletions bin/new-version-electron.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#! /bin/sh

if [[ -z "$1" ]]; then
echo "Error: Please provide a version string."
exit 1
fi

ELECTRON_PATH=$(realpath $(dirname $0)/../electron)
NEW_VERSION="$1"

cd $ELECTRON_PATH;
npm version $NEW_VERSION --no-git-tag-version >> /dev/null

echo "Update Electron package.json Version to: $NEW_VERSION"
4 changes: 3 additions & 1 deletion bin/new-version-ios.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#! /bin/sh

source $(dirname $0)/functions/cross-replace.sh

if [[ -z "$1" ]]; then
echo "Error: Please provide a version string."
exit 1
Expand All @@ -8,6 +10,6 @@ fi
CONFIG_FILE=$(realpath $(dirname $0)/../ios/App/App.xcodeproj/project.pbxproj)
NEW_VERSION="$1"

sed -i '' "s/MARKETING_VERSION = [^;]*;/MARKETING_VERSION = $NEW_VERSION;/g" "$CONFIG_FILE"
replace "s/MARKETING_VERSION = [^;]*;/MARKETING_VERSION = $NEW_VERSION;/g" "$CONFIG_FILE"

echo "Update iOS MARKETING_VERSION to: $NEW_VERSION"
12 changes: 10 additions & 2 deletions bin/push-build-android.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
#! /bin/sh

source $(dirname $0)/functions/cross-replace.sh

CONFIG_FILE=$(realpath $(dirname $0)/../android/app/build.gradle)
PROJECT_PATH=$(realpath $(dirname $0)/../ios/App)

cd $PROJECT_PATH;

if [ -z $1 ]; then
CURRENT_BUILD=$(sed -n 's/versionCode \([0-9]*\).*/\1/p' "$CONFIG_FILE")

if [ -z $CURRENT_BUILD ]; then
echo "Unable to get versionCode";
exit 1;
fi

NEW_BUILD=$((CURRENT_BUILD + 1))
else
NEW_BUILD="$1"
Expand All @@ -16,7 +24,7 @@ if [[ -z "$NEW_BUILD" ]]; then
echo "Error: Empty build version."
exit 1
fi
#
sed -i '' "s/versionCode \([0-9]*\).*/versionCode $NEW_BUILD/g" "$CONFIG_FILE"

replace "s/versionCode \([0-9]*\).*/versionCode $NEW_BUILD/g" "$CONFIG_FILE"

echo "Update Android versionCode to: $NEW_BUILD"
16 changes: 14 additions & 2 deletions bin/push-build-ios.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
#! /bin/sh

source $(dirname $0)/functions/cross-replace.sh

CONFIG_FILE=$(realpath $(dirname $0)/../ios/App/App.xcodeproj/project.pbxproj)
PROJECT_PATH=$(realpath $(dirname $0)/../ios/App)

cd $PROJECT_PATH;

if [ -z $1 ]; then
CURRENT_BUILD=$(agvtool vers -terse)
CURRENT_BUILD=$(sed -n 's/CURRENT_PROJECT_VERSION = \([0-9]*\);/\1/p' "$CONFIG_FILE")

# CURRENT_PROJECT_VERSION has 2 lines, return value will contains 2 numbers.
# We split them and only get first.
read -r CURRENT_BUILD _ <<< "$CURRENT_BUILD";

if [ -z $CURRENT_BUILD ]; then
echo "Unable to get CURRENT_PROJECT_VERSION";
exit 1;
fi

NEW_BUILD=$((CURRENT_BUILD + 1))
else
NEW_BUILD="$1"
Expand All @@ -17,6 +29,6 @@ if [[ -z "$NEW_BUILD" ]]; then
exit 1
fi

sed -i '' "s/CURRENT_PROJECT_VERSION = [^;]*;/CURRENT_PROJECT_VERSION = $NEW_BUILD;/g" "$CONFIG_FILE"
replace "s/CURRENT_PROJECT_VERSION = [^;]*;/CURRENT_PROJECT_VERSION = $NEW_BUILD;/g" "$CONFIG_FILE"

echo "Update iOS CURRENT_PROJECT_VERSION to: $NEW_BUILD"
20 changes: 17 additions & 3 deletions bin/push-versions.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
#! /bin/sh

if [ -z $1 ]; then
echo "Please provide version name or version type:";
echo " [major | minor | patch | premajor | preminor | prepatch | prerelease | from-git]";
exit 1;
fi

BASE=$(dirname $0)
NEW_VERSION=$(npm version $1 --no-git-tag-version)

sh $(dirname $0)/push-ios-version.sh "$NEW_VERSION"
echo "Update package.json Version to: $NEW_VERSION"

# iOS
sh $BASE/push-build-ios.sh
sh $BASE/new-version-ios.sh "$NEW_VERSION"

#git commit -am "Prepare version: $NEW_VERSION"
# Android
sh $BASE/push-build-android.sh
sh $BASE/new-version-android.sh "$NEW_VERSION"

sh ./release-ios.sh
# Electron
sh $BASE/new-version-electron.sh "$NEW_VERSION"

0 comments on commit 0f07608

Please sign in to comment.