Skip to content

Commit

Permalink
adopt shellcheck changes
Browse files Browse the repository at this point in the history
  • Loading branch information
programminghoch10 committed Aug 26, 2023
1 parent 9053822 commit 19b3bb4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
3 changes: 2 additions & 1 deletion compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
set -e
set -u
set -o pipefail
shopt -s inherit_errexit
IFS=$'\n'
renice -n 19 $$ &>/dev/null
cd "$(dirname "$(readlink -f "$0")")"
Expand All @@ -27,7 +28,7 @@ git diff --exit-code --quiet && LOCALCHANGES=false || LOCALCHANGES=true
$LOCALCHANGES && CHANGES="+" || CHANGES="-"
MODULE_COMMITS=$(getCommitCount)
HOSTS_COMMITS=$(getCommitCount hosts)
VERSIONCODE=$MODULE_COMMITS$(printf '%05d' $HOSTS_COMMITS)
VERSIONCODE=$MODULE_COMMITS$(printf '%05d' "$HOSTS_COMMITS")
COMMITHASH=$(git log -1 --pretty=%h)
COMMITHASHFULL=$(git log -1 --pretty=%H)
VERSIONTAG=mv$MODULE_COMMITS-hv$HOSTS_COMMITS
Expand Down
12 changes: 8 additions & 4 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
set -e
set -u
set -o pipefail
shopt -s inherit_errexit
IFS=$'\n'
cd "$(dirname "$(readlink -f "$0")")"

Expand All @@ -13,12 +14,14 @@ for cmd in git curl jq; do
done

FILE="${1-}"
# shellcheck disable=SC2012
[ -z "$FILE" ] && FILE=$(ls MagicalProtection-*.zip | tail -n 1)
[ -z "$FILE" ] && echo "require input file" && exit 1

function getprop() {
local prop="$1"
local content=$(cat)
local content
content=$(cat)
[ -z "$content" ] && echo "missing content in getProp" >&2 && return 1
grep -q "^$prop" <<< "$content" || return 1
grep "^$prop" <<< "$content" | head -n 1 | cut -d'=' -f2
Expand Down Expand Up @@ -47,7 +50,8 @@ NEW_TAG_NAME=$(getprop versionTag <<< "$FILE_MODULE_PROP")
export FILENAME="$FILE"
export VERSIONTAG="$NEW_TAG_NAME"
export VERSION="$FILE_VERSION"
export VERSIONCODE=$(getprop versionCode <<< "$FILE_MODULE_PROP")
VERSIONCODE=$(getprop versionCode <<< "$FILE_MODULE_PROP")
export VERSIONCODE
envsubst < update_template.json > deploy/update.json
echo "$FILE_MODULE_PROP" > deploy/module.prop

Expand Down Expand Up @@ -76,7 +80,7 @@ CREATE_RELEASE_RESPONSE=$(curl \
--silent \
"${CURL_GITHUB_API_ARGS[@]}" \
--request POST \
https://api.github.com/repos/$GITHUB_OWNER/$GITHUB_REPO/releases \
"https://api.github.com/repos/$GITHUB_OWNER/$GITHUB_REPO/releases" \
--data "{
\"tag_name\":\"$VERSIONTAG\",
\"target_commitish\":\"$COMMITISH\",
Expand All @@ -103,7 +107,7 @@ curl \
--silent \
"${CURL_GITHUB_API_ARGS[@]}" \
--request PATCH \
https://api.github.com/repos/$GITHUB_OWNER/$GITHUB_REPO/releases/$RELEASE_ID \
"https://api.github.com/repos/$GITHUB_OWNER/$GITHUB_REPO/releases/$RELEASE_ID" \
--data '{"draft":false}' \
--output /dev/null

Expand Down
5 changes: 4 additions & 1 deletion update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
set -e
set -u
set -o pipefail
shopt -s inherit_errexit
IFS=$'\n'
cd "$(dirname "$(readlink -f "$0")")"

Expand All @@ -16,7 +17,7 @@ function checkOutBranch() {
! git branch | grep -q "$branch" && git fetch origin "$branch":"$branch"
[ -d "$folder" ] && rm -rf "$folder"
mkdir "$folder"
git clone -q $(pwd) "$folder"
git clone -q "$(pwd)" "$folder"
cd "$folder"
git config --local push.autoSetupRemote true
git fetch -q origin "$branch":"$branch"
Expand Down Expand Up @@ -61,6 +62,8 @@ case "${1-}" in
pushBranch deploy
exit
;;
*)
;;
esac

$0 checkOutHosts
Expand Down

0 comments on commit 19b3bb4

Please sign in to comment.