diff --git a/upload.sh b/upload.sh index 8bf95aa..9c6bc68 100755 --- a/upload.sh +++ b/upload.sh @@ -68,16 +68,10 @@ fi # Split the target into its components IFS='-' read -r COMPONENT ARCH RELEASE PLATFORM <<< "$TARGET" -# Determine the upload directory based on the target -UPLOAD_DIR="$COMPONENT/$ARCH/$RELEASE/$PLATFORM" - -# Construct the remote directory path -REMOTE_DIR="/home/frs/project/$SF_PROJECT/$UPLOAD_DIR" - # Handle versioning if [ -z "$VERSION" ]; then if [[ "$RELEASE" == "nightly" ]]; then - VERSION=$(date +"%Y%m%d") + VERSION=$(date +"%Y-%m-%d") elif [[ "$RELEASE" == "stable" ]]; then CURRENT_VERSION=$(grep -oP '(?<="'"$COMPONENT"'": ")([^"]*)' packages.json) if [ -n "$CURRENT_VERSION" ]; then @@ -98,6 +92,24 @@ 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 + UPLOAD_DIR="$COMPONENT/$ARCH/$RELEASE/latest" + else + UPLOAD_DIR="$COMPONENT/$ARCH/$RELEASE/$VERSION" + fi +elif [[ "$RELEASE" == "stable" ]]; then + if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+$ ]]; then + UPLOAD_DIR="$COMPONENT/$ARCH/$RELEASE/$VERSION" + else + UPLOAD_DIR="$COMPONENT/$ARCH/$RELEASE/latest" + fi +fi + +# Construct the remote directory path +REMOTE_DIR="/home/frs/project/$SF_PROJECT/$UPLOAD_DIR" + # Handle compression if specified if [ "$COMPRESS" = true ]; then COMPRESSED_FILE="/tmp/${TARGET}.tar.gz"