Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lint: improve shell coding style #819

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
32 changes: 0 additions & 32 deletions .appveyor.yml

This file was deleted.

14 changes: 7 additions & 7 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ then
VERSION="$OPTARG"
;;
*)
echo -e "${r}Unexpected flag not supported${x}"
echo -e "Unexpected flag not supported"
exit 1
;;
esac
Expand All @@ -69,8 +69,8 @@ echo -e "

if [[ -n "${CLI_ON_MACOS-}" ]]
then
curl -O -fsSL https://aliyuncli.alicdn.com/aliyun-cli-macosx-$VERSION-universal.tgz
tar zxf aliyun-cli-macosx-$VERSION-universal.tgz
curl -O -fsSL https://aliyuncli.alicdn.com/aliyun-cli-macosx-"$VERSION"-universal.tgz
tar zxf aliyun-cli-macosx-"$VERSION"-universal.tgz
mv ./aliyun /usr/local/bin/
fi

Expand All @@ -79,11 +79,11 @@ then
UNAME_MACHINE="$(/usr/bin/uname -m)"
if [[ "${UNAME_MACHINE}" == "arm64" ]]
then
curl -O -fsSL https://aliyuncli.alicdn.com/aliyun-cli-linux-$VERSION-arm64.tgz
tar zxf aliyun-cli-linux-$VERSION-arm64.tgz
curl -O -fsSL https://aliyuncli.alicdn.com/aliyun-cli-linux-"$VERSION"-arm64.tgz
tar zxf aliyun-cli-linux-"$VERSION"-arm64.tgz
else
curl -O -fsSL https://aliyuncli.alicdn.com/aliyun-cli-linux-$VERSION-amd64.tgz
tar zxf aliyun-cli-linux-$VERSION-amd64.tgz
curl -O -fsSL https://aliyuncli.alicdn.com/aliyun-cli-linux-"$VERSION"-amd64.tgz
tar zxf aliyun-cli-linux-"$VERSION"-amd64.tgz
fi
mv ./aliyun /usr/local/bin/
fi
20 changes: 10 additions & 10 deletions tools/build_pkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ mkdir -p out/productbuild
cp out/aliyun out/dist/usr/local/bin/

mkdir -p out/pkgs
pkgbuild --version $VERSION \
pkgbuild --version "$VERSION" \
--identifier com.aliyun.cli.pkg \
--root out/dist out/pkgs/aliyun-cli-${VERSION}.pkg
--root out/dist out/pkgs/aliyun-cli-"${VERSION}".pkg

cat pkg/productbuild/distribution.xml.tmpl | \
sed -E "s/\\{cli_version\\}/$VERSION/g" > out/productbuild/distribution.xml

for dirname in pkg/productbuild/Resources/*/; do
lang=$(basename $dirname)
mkdir -p out/productbuild/Resources/$lang
printf "Found localization directory $dirname\n"
cat $dirname/welcome.html.tmpl | \
sed -E "s/\\{cli_version\\}/$VERSION/g" > out/productbuild/Resources/$lang/welcome.html
cat $dirname/conclusion.html.tmpl | \
sed -E "s/\\{cli_version\\}/$VERSION/g" > out/productbuild/Resources/$lang/conclusion.html
lang=$(basename "$dirname")
mkdir -p out/productbuild/Resources/"$lang"
printf "Found localization directory %s\n" "$dirname"
cat "$dirname"/welcome.html.tmpl | \
sed -E "s/\\{cli_version\\}/$VERSION/g" > out/productbuild/Resources/"$lang"/welcome.html
cat "$dirname"/conclusion.html.tmpl | \
sed -E "s/\\{cli_version\\}/$VERSION/g" > out/productbuild/Resources/"$lang"/conclusion.html
done

cp pkg/osx_installer_logo.png out/productbuild/Resources
Expand All @@ -30,4 +30,4 @@ cp LICENSE out/productbuild/Resources/license.txt
productbuild --distribution out/productbuild/distribution.xml \
--resources out/productbuild/Resources \
--package-path out/pkgs \
out/aliyun-cli-${VERSION}.pkg
out/aliyun-cli-"${VERSION}".pkg
12 changes: 3 additions & 9 deletions tools/download_assets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@

VERSION=$1

RELEASE_ID=$(curl -fsSL \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/aliyun/aliyun-cli/releases/tags/v$VERSION | jq '.["id"]')

LIST=(
"aliyun-cli-macosx-$VERSION-amd64.tgz"
"aliyun-cli-macosx-$VERSION-arm64.tgz"
Expand All @@ -18,12 +12,12 @@ LIST=(
"aliyun-cli-windows-$VERSION-amd64.zip"
)

for filename in ${LIST[@]}
for filename in "${LIST[@]}"
do
curl -fsSL -O \
-H "Authorization: Bearer $GITHUB_TOKEN" \
https://github.com/aliyun/aliyun-cli/releases/download/v$VERSION/$filename
shasum -a 256 $filename >> SHASUMS256.txt
https://github.com/aliyun/aliyun-cli/releases/download/v"$VERSION"/"$filename"
shasum -a 256 "$filename" >> SHASUMS256.txt
done

cat ./SHASUMS256.txt
50 changes: 25 additions & 25 deletions tools/finish_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,53 +9,53 @@ go build -ldflags "-X 'github.com/aliyun/aliyun-cli/cli.Version=${VERSION}'" -o
FLAGS="oss://aliyun-cli --force --access-key-id ${ACCESS_KEY_ID} --access-key-secret ${ACCESS_KEY_SECRET} --region cn-hangzhou"

# mac amd64
${ALIYUN} oss cp ./aliyun-cli-macosx-${VERSION}-amd64.tgz $FLAGS
${ALIYUN} oss cp ./aliyun-cli-macosx-"${VERSION}"-amd64.tgz "$FLAGS"
# mac arm64
${ALIYUN} oss cp ./aliyun-cli-macosx-${VERSION}-arm64.tgz $FLAGS
${ALIYUN} oss cp ./aliyun-cli-macosx-"${VERSION}"-arm64.tgz "$FLAGS"
# mac universal
${ALIYUN} oss cp ./aliyun-cli-macosx-${VERSION}-universal.tgz $FLAGS
${ALIYUN} oss cp ./aliyun-cli-macosx-"${VERSION}"-universal.tgz "$FLAGS"
# mac pkg
${ALIYUN} oss cp ./aliyun-cli-${VERSION}.pkg $FLAGS
${ALIYUN} oss cp ./aliyun-cli-"${VERSION}".pkg "$FLAGS"
# linux amd64
${ALIYUN} oss cp ./aliyun-cli-linux-${VERSION}-amd64.tgz $FLAGS
${ALIYUN} oss cp ./aliyun-cli-linux-"${VERSION}"-amd64.tgz "$FLAGS"
# linux arm64
${ALIYUN} oss cp ./aliyun-cli-linux-${VERSION}-arm64.tgz $FLAGS
${ALIYUN} oss cp ./aliyun-cli-linux-"${VERSION}"-arm64.tgz "$FLAGS"
# windows
${ALIYUN} oss cp ./aliyun-cli-windows-${VERSION}-amd64.zip $FLAGS
${ALIYUN} oss cp ./aliyun-cli-windows-"${VERSION}"-amd64.zip "$FLAGS"

if [[ "$VERSION" == *"-beta" ]]; then
echo "beta. skip."
else
cp ./aliyun-cli-macosx-${VERSION}-amd64.tgz ./aliyun-cli-macosx-latest-amd64.tgz
${ALIYUN} oss cp ./aliyun-cli-macosx-latest-amd64.tgz $FLAGS
cp ./aliyun-cli-macosx-"${VERSION}"-amd64.tgz ./aliyun-cli-macosx-latest-amd64.tgz
${ALIYUN} oss cp ./aliyun-cli-macosx-latest-amd64.tgz "$FLAGS"

cp ./aliyun-cli-macosx-${VERSION}-arm64.tgz ./aliyun-cli-macosx-latest-arm64.tgz
${ALIYUN} oss cp ./aliyun-cli-macosx-latest-arm64.tgz $FLAGS
cp ./aliyun-cli-macosx-"${VERSION}"-arm64.tgz ./aliyun-cli-macosx-latest-arm64.tgz
${ALIYUN} oss cp ./aliyun-cli-macosx-latest-arm64.tgz "$FLAGS"

cp ./aliyun-cli-macosx-${VERSION}-universal.tgz ./aliyun-cli-macosx-latest-universal.tgz
${ALIYUN} oss cp ./aliyun-cli-macosx-latest-universal.tgz $FLAGS
cp ./aliyun-cli-macosx-"${VERSION}"-universal.tgz ./aliyun-cli-macosx-latest-universal.tgz
${ALIYUN} oss cp ./aliyun-cli-macosx-latest-universal.tgz "$FLAGS"

cp ./aliyun-cli-${VERSION}.pkg ./aliyun-cli-latest.pkg
${ALIYUN} oss cp ./aliyun-cli-latest.pkg $FLAGS
cp ./aliyun-cli-"${VERSION}".pkg ./aliyun-cli-latest.pkg
${ALIYUN} oss cp ./aliyun-cli-latest.pkg "$FLAGS"

cp ./aliyun-cli-linux-${VERSION}-amd64.tgz ./aliyun-cli-linux-latest-amd64.tgz
${ALIYUN} oss cp ./aliyun-cli-linux-latest-amd64.tgz $FLAGS
cp ./aliyun-cli-linux-"${VERSION}"-amd64.tgz ./aliyun-cli-linux-latest-amd64.tgz
${ALIYUN} oss cp ./aliyun-cli-linux-latest-amd64.tgz "$FLAGS"

cp ./aliyun-cli-linux-${VERSION}-arm64.tgz ./aliyun-cli-linux-latest-arm64.tgz
${ALIYUN} oss cp ./aliyun-cli-linux-latest-arm64.tgz $FLAGS
cp ./aliyun-cli-linux-"${VERSION}"-arm64.tgz ./aliyun-cli-linux-latest-arm64.tgz
${ALIYUN} oss cp ./aliyun-cli-linux-latest-arm64.tgz "$FLAGS"

cp ./aliyun-cli-windows-${VERSION}-amd64.zip ./aliyun-cli-windows-latest-amd64.zip
${ALIYUN} oss cp ./aliyun-cli-windows-latest-amd64.zip $FLAGS
cp ./aliyun-cli-windows-"${VERSION}"-amd64.zip ./aliyun-cli-windows-latest-amd64.zip
${ALIYUN} oss cp ./aliyun-cli-windows-latest-amd64.zip "$FLAGS"
# local version

echo ${VERSION} > out/version
${ALIYUN} oss cp out/version $FLAGS
echo "${VERSION}" > out/version
${ALIYUN} oss cp out/version "$FLAGS"

RELEASE_ID=$(curl -fsSL \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/aliyun/aliyun-cli/releases/tags/v$VERSION | jq '.["id"]')
https://api.github.com/repos/aliyun/aliyun-cli/releases/tags/v"$VERSION" | jq '.["id"]')

DATA='{"draft":false,"prerelease":false,"make_latest":true}'

Expand All @@ -64,6 +64,6 @@ else
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/aliyun/aliyun-cli/releases/$RELEASE_ID \
https://api.github.com/repos/aliyun/aliyun-cli/releases/"$RELEASE_ID" \
-d "$DATA"
fi
10 changes: 5 additions & 5 deletions tools/upload_asset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ ASSET=$2

if [[ $ASSET == *.tgz ]]
then
TYPE=application/x-compressed-tar
TYPE=application/x-compressed-tar
elif [[ $ASSET == *.txt ]]
then
TYPE=text/plain
TYPE=text/plain
else
TYPE=application/zip
TYPE=application/zip
fi

RELEASE_ID=$(curl -fsSL \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/aliyun/aliyun-cli/releases/tags/$TAG | jq '.["id"]')
https://api.github.com/repos/aliyun/aliyun-cli/releases/tags/"$TAG" | jq '.["id"]')

curl -fsSL \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type: $TYPE" \
"https://uploads.github.com/repos/aliyun/aliyun-cli/releases/$RELEASE_ID/assets?name=$(basename $ASSET)" \
"https://uploads.github.com/repos/aliyun/aliyun-cli/releases/$RELEASE_ID/assets?name=$(basename "$ASSET")" \
--data-binary "@$ASSET"
Loading