package script added
This commit is contained in:
parent
5fd9a5f45f
commit
f904f731f3
5 changed files with 179 additions and 38 deletions
27
upload.sh
27
upload.sh
|
@ -68,12 +68,22 @@ fi
|
|||
# Split the target into its components
|
||||
IFS='-' read -r COMPONENT ARCH RELEASE PLATFORM <<< "$TARGET"
|
||||
|
||||
# Download the existing packages.json
|
||||
echo "Downloading existing packages.json from SourceForge..."
|
||||
scp -i "$SF_KEY_PATH" "$SF_USER@$SF_HOST:/home/frs/project/$SF_PROJECT/packages.json" packages.json 2>/dev/null || { echo "Failed to download packages.json. Creating a new one."; echo "{}" > packages.json; }
|
||||
|
||||
# Check if packages.json is a valid JSON object
|
||||
if ! jq empty packages.json >/dev/null 2>&1; then
|
||||
echo "Invalid packages.json format. Resetting to an empty JSON object."
|
||||
echo "{}" > packages.json
|
||||
fi
|
||||
|
||||
# Handle versioning
|
||||
if [ -z "$VERSION" ]; then
|
||||
if [[ "$RELEASE" == "nightly" ]]; then
|
||||
VERSION=$(date +"%Y-%m-%d")
|
||||
elif [[ "$RELEASE" == "stable" ]]; then
|
||||
CURRENT_VERSION=$(grep -oP '(?<="'"$COMPONENT"'": ")([^"]*)' packages.json)
|
||||
CURRENT_VERSION=$(jq -r --arg comp "$COMPONENT" --arg arch "$ARCH" --arg rel "$RELEASE" --arg plat "$PLATFORM" '.[$comp][$arch][$rel][$plat] | keys | map(select(test("^[0-9]+\\.[0-9]+$"))) | max' packages.json)
|
||||
if [ -n "$CURRENT_VERSION" ]; then
|
||||
MAJOR_VERSION=$(echo $CURRENT_VERSION | cut -d. -f1)
|
||||
MINOR_VERSION=$(echo $CURRENT_VERSION | cut -d. -f2)
|
||||
|
@ -85,13 +95,6 @@ if [ -z "$VERSION" ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
# Update packages.json
|
||||
if [ ! -f packages.json ]; then
|
||||
echo "{}" > packages.json
|
||||
fi
|
||||
|
||||
jq --arg comp "$COMPONENT" --arg ver "$VERSION" '.[$comp] = $ver' packages.json > packages_temp.json && mv packages_temp.json packages.json
|
||||
|
||||
# Determine the upload directory based on the target and version
|
||||
if [[ "$RELEASE" == "nightly" ]]; then
|
||||
if [[ "$VERSION" == $(date +"%Y-%m-%d") ]]; then
|
||||
|
@ -140,6 +143,14 @@ if [ $UPLOAD_STATUS -ne 0 ]; then
|
|||
scp -i "$SF_KEY_PATH" "$BUILD_PATH" "$SF_USER@$SF_HOST:$REMOTE_DIR/" || { echo "Failed to upload files after creating directory structure. Exiting."; exit 1; }
|
||||
fi
|
||||
|
||||
# Update packages.json with the new information
|
||||
jq --arg comp "$COMPONENT" --arg arch "$ARCH" --arg rel "$RELEASE" --arg plat "$PLATFORM" --arg ver "$VERSION" \
|
||||
'if .[$comp] == null then .[$comp] = {} else .[$comp] end |
|
||||
if .[$comp][$arch] == null then .[$comp][$arch] = {} else .[$comp][$arch] end |
|
||||
if .[$comp][$arch][$rel] == null then .[$comp][$arch][$rel] = {} else .[$comp][$arch][$rel] end |
|
||||
if .[$comp][$arch][$rel][$plat] == null then .[$comp][$arch][$rel][$plat] = {} else .[$comp][$arch][$rel][$plat] end |
|
||||
.[$comp][$arch][$rel][$plat][$ver] = $ver' packages.json > packages_temp.json && mv packages_temp.json packages.json
|
||||
|
||||
# Upload the updated packages.json to the root directory
|
||||
echo "Uploading packages.json to the root directory on SourceForge..."
|
||||
scp -i "$SF_KEY_PATH" packages.json "$SF_USER@$SF_HOST:/home/frs/project/$SF_PROJECT/" || { echo "Failed to upload packages.json. Exiting."; exit 1; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue