Skip to content

Commit

Permalink
upgrade build script
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvinjjwong committed Dec 28, 2024
1 parent 469a684 commit 50ed942
Showing 1 changed file with 32 additions and 21 deletions.
53 changes: 32 additions & 21 deletions build_pod.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
#Version:1.0.6
#Version:1.0.7
SCRIPT_VERSION=`grep "Version:" $0 | head -1 | awk -F':' '{print $NF}'`
echo "Current SPA VERSION: $SCRIPT_VERSION"
echo
Expand Down Expand Up @@ -68,7 +68,7 @@ pod trunk me
if [[ $? -ne 0 ]]; then
echo "Please register like below before retry: "
echo
echo "pod trunk register `defaults read MobileMeAccounts Accounts | grep AccountDescription | awk -F'\"' '{print $2}'` '`whoami`' --description='`hostname -s`'"
echo "pod trunk register `defaults read MobileMeAccounts Accounts | grep AccountID | awk -F'\"' '{print $2}'` '`whoami`' --description='`hostname -s`'"
echo
exit -1
fi
Expand All @@ -80,7 +80,14 @@ if [[ "$GIT_BASE_BRANCH" = "" ]]; then
GIT_BASE_BRANCH="main"
fi

REQUIRE_UPPERCASE=`echo ${PWD##*/} | awk '{for (i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) substr($i,2)} 1'`
IS_HYPHEN=0
if [[ $GIT_REPOSITORY == *-* ]]
then
IS_HYPHEN=1
REQUIRE_UPPERCASE=$GIT_REPOSITORY
else
REQUIRE_UPPERCASE=`echo ${PWD##*/} | awk '{for (i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) substr($i,2)} 1'`
fi

if [[ "$REQUIRE_UPPERCASE" != "$GIT_REPOSITORY" ]]; then
GIT_REPOSITORY=$REQUIRE_UPPERCASE
Expand Down Expand Up @@ -158,24 +165,28 @@ if [[ "`git config --get remote.origin.url`" = "" ]]; then
fi
fi

if [[ ! -e Sources/${GIT_REPOSITORY}/ ]]; then
mkdir -p Sources/${GIT_REPOSITORY}/
curl -fsSL https://raw.githubusercontent.com/kelvinjjwong/spa/main/template/PROJECT_NAME.swift > Sources/${GIT_REPOSITORY}/${GIT_REPOSITORY}.swift
sed -i '' -e "s/PROJECT_NAME/${GIT_REPOSITORY}/" Sources/${GIT_REPOSITORY}/${GIT_REPOSITORY}.swift
git add Sources/${GIT_REPOSITORY}/${GIT_REPOSITORY}.swift
git commit -m "initial commit"
git push
echo "Completed create Sources/${GIT_REPOSITORY}/${GIT_REPOSITORY}.swift"
fi
if [[ $IS_HYPHEN -eq 0 ]]; then

if [[ ! -e Sources/${GIT_REPOSITORY}/ ]]; then
mkdir -p Sources/${GIT_REPOSITORY}/
curl -fsSL https://raw.githubusercontent.com/kelvinjjwong/spa/main/template/PROJECT_NAME.swift > Sources/${GIT_REPOSITORY}/${GIT_REPOSITORY}.swift
sed -i '' -e "s/PROJECT_NAME/${GIT_REPOSITORY}/" Sources/${GIT_REPOSITORY}/${GIT_REPOSITORY}.swift
git add Sources/${GIT_REPOSITORY}/${GIT_REPOSITORY}.swift
git commit -m "initial commit"
git push
echo "Completed create Sources/${GIT_REPOSITORY}/${GIT_REPOSITORY}.swift"
fi

if [[ ! -e Tests/${GIT_REPOSITORY}Tests/ ]]; then
mkdir -p Tests/${GIT_REPOSITORY}Tests/
curl -fsSL https://raw.githubusercontent.com/kelvinjjwong/spa/main/template/PROJECT_NAMETests.swift > Tests/${GIT_REPOSITORY}Tests/${GIT_REPOSITORY}Tests.swift
sed -i '' -e "s/PROJECT_NAME/${GIT_REPOSITORY}/" Tests/${GIT_REPOSITORY}Tests/${GIT_REPOSITORY}Tests.swift
git add Tests/${GIT_REPOSITORY}Tests/${GIT_REPOSITORY}Tests.swift
git commit -m "initial commit"
git push
echo "Completed create Tests/${GIT_REPOSITORY}Tests/${GIT_REPOSITORY}Tests.swift"
fi

if [[ ! -e Tests/${GIT_REPOSITORY}Tests/ ]]; then
mkdir -p Tests/${GIT_REPOSITORY}Tests/
curl -fsSL https://raw.githubusercontent.com/kelvinjjwong/spa/main/template/PROJECT_NAMETests.swift > Tests/${GIT_REPOSITORY}Tests/${GIT_REPOSITORY}Tests.swift
sed -i '' -e "s/PROJECT_NAME/${GIT_REPOSITORY}/" Tests/${GIT_REPOSITORY}Tests/${GIT_REPOSITORY}Tests.swift
git add Tests/${GIT_REPOSITORY}Tests/${GIT_REPOSITORY}Tests.swift
git commit -m "initial commit"
git push
echo "Completed create Tests/${GIT_REPOSITORY}Tests/${GIT_REPOSITORY}Tests.swift"
fi

if [[ $IS_INIT -eq 1 ]]; then
Expand Down Expand Up @@ -318,4 +329,4 @@ if [[ "$2" = "not-publish" ]] || [[ "$3" = "not-publish" ]]; then
fi

pod trunk push $PODSPEC --allow-warnings
echo "Completed publish to Cocoapods trunk."
echo "Completed publish to Cocoapods trunk."

0 comments on commit 50ed942

Please sign in to comment.