Commit e90b8b63 authored by nanahira's avatar nanahira

work

parent 68761f0f
...@@ -14,22 +14,44 @@ ...@@ -14,22 +14,44 @@
## 如何使用 ## 如何使用
### 查看 APP JSON 信息
```bash
./index.sh getAppJson <APP 名称>
```
同时会把文件保存在 `./jsons/<APP 名称>.json` 下。
### 更新 APP JSON 信息
```bash
./index.sh uploadAppsJson <APP 名称> <JSON 文件路径>
```
文件默认从 `./jsons/<APP 名称>.json` 获取。
### 更新包信息
```bash
./index.sh getAppBuilds <APP 名称>
```
### 查看包信息 ### 查看包信息
```bash ```bash
./get-builds.sh <APP 名称> ./index.sh getAppJson <APP 名称>
``` ```
### 打包 ### 打包
```bash ```bash
./pack.sh <APP 名称> <APP 路径> <APP 版本号> ./index.sh makeBuild <APP 名称> <APP 路径> <APP 版本号>
``` ```
### 删除版本 ### 删除打包
```bash ```bash
./delete-build.sh <APP 名称> <APP 版本号> ./index.sh deleteBuild <APP 名称> <APP 版本号>
``` ```
## 变量 ## 变量
......
#!/bin/bash
# set -o errexit
source ./src/pack-utility.sh
getAppBuilds "$@"
...@@ -2,4 +2,8 @@ ...@@ -2,4 +2,8 @@
# set -o errexit # set -o errexit
source ./src/pack-utility.sh source ./src/pack-utility.sh
deleteBuild "$@" if [[ -n "$1" ]]; then
"$@"
else
help
fi
#!/bin/bash
# set -o errexit
source ./src/pack-utility.sh
appName="$1"
appPath="$2"
if [[ -z "$appPath" ]]; then
appPath="pool/$appName"
fi
makeBuild "$appName" "$appPath"
apiRoot=https://sapi.moecube.com:444 apiRoot=https://sapi.moecube.com:444
loginInfo=$(curl -sL -X POST $apiRoot/accounts/signin -d account=$username -d password=$password) loginInfo=$(curl -sL -X POST $apiRoot/accounts/signin -d account=$username -d password=$password)
token=$(echo $loginInfo | jq '.token' | sed 's/"//g') loginExitCode="$?"
loginErrorMessage=$(echo "$loginInfo" | jq '.message' | sed 's/"//g')
if [[ "$loginExitCode" -gt 0 ]]; then
echo "Login failed: $loginErrorMessage"
exit 1
fi
token=$(echo "$loginInfo" | jq '.token' | sed 's/"//g')
header="Authorization: $token" header="Authorization: $token"
set -o errexit
apiRoot=https://sapi.moecube.com:444 apiRoot=https://sapi.moecube.com:444
source ./src/login.sh source ./src/login.sh
source ./src/prefix.sh source ./src/prefix.sh
handleErrorMessage() {
rawJsonInput="$1"
successInfo=$(echo "$rawJsonInput" | jq '.success')
statusCode=$(echo "$rawJsonInput" | jq '.statusCode')
if [[ "$successInfo" != "true" ]]; then
failMessage=$(echo "$rawJsonInput" | jq '.success')
echo "$rawJsonInput"
exit 1
fi
}
makeBuild() { makeBuild() {
appName="$1" appName="$1"
appPath="$2" appPath="$2"
if [[ -z "$appPath" ]]; then
appPath="pool/$appName"
fi
echo "Packaging $appName from $appPath" echo "Packaging $appName from $appPath"
if [[ -z "$appVersion" ]]; then if [[ -z "$appVersion" ]]; then
appVersion="$3" appVersion="$3"
...@@ -19,9 +36,9 @@ makeBuild() { ...@@ -19,9 +36,9 @@ makeBuild() {
echo "Version: $appVersion" echo "Version: $appVersion"
currentPath="$PWD" currentPath="$PWD"
cd "$appPath" cd "$appPath"
tar --zstd -cvf - * | curl -sL -H "$header" -X POST "$apiRoot/release/api/build/$appName/${appVersion}${suffix}" -F file=@- | jq result=$(tar --zstd -cvf - * | curl -sL -H "$header" -X POST "$apiRoot/release/api/build/$appName/${appVersion}${suffix}" -F file=@-)
echo "Finished." handleErrorMessage "$result"
cd "$currentPath" echo "$result" | jq
} }
deleteBuild() { deleteBuild() {
...@@ -31,10 +48,39 @@ deleteBuild() { ...@@ -31,10 +48,39 @@ deleteBuild() {
fi fi
echo "Removing build $appName" echo "Removing build $appName"
echo "Version: $appVersion" echo "Version: $appVersion"
curl -sL -H "$header" -X DELETE "$apiRoot/release/api/build/$appName/${appVersion}${suffix}" result=$(curl -sL -H "$header" -X DELETE "$apiRoot/release/api/build/$appName/${appVersion}${suffix}")
handleErrorMessage "$result"
echo "$result" | jq
}
getAppInfoRaw() {
appName="$1"
result=$(curl -sL -H "$header" "$apiRoot/release/api/app?id=$appName")
handleErrorMessage "$result"
echo "$result"
} }
getAppBuilds() { getAppBuilds() {
getAppInfoRaw "$@" | jq ".data[0].depots"
}
getAppJson() {
appName="$1"
getAppInfoRaw "$@" | jq ".data[0].appData" | tee "./jsons/$appName.json"
}
uploadAppsJson() {
appName="$1" appName="$1"
curl -sL -H "$header" "$apiRoot/release/api/app?id=$appName" | jq ".data[0].depots" jsonPath="$2"
if [[ -z "$jsonPath" ]]; then
jsonPath="./jsons/$appName.json"
fi
echo "Updating $appName with info from $jsonPath."
result=$(curl -sL -H "$header" -H "Content-Type: application/json" -d "@$jsonPath" -X POST "$apiRoot/release/api/app")
handleErrorMessage "$result"
echo "$result" | jq
}
help() {
cat ./README.md
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment