|
|
6dca2e |
#!/bin/bash
|
|
|
6dca2e |
|
|
|
6dca2e |
set -e
|
|
|
6dca2e |
|
|
|
6dca2e |
PUBLISH_DIR=$(cd `dirname "$0"`; pwd)
|
|
|
6dca2e |
|
|
|
6dca2e |
publish_file() {
|
|
|
6dca2e |
local NAME="$1"
|
|
|
6dca2e |
local TEMPLATE="$2" # Xxxxx-%VERSION%-%DATE%-%COMMIT%-xxxxx.xxx"
|
|
|
6dca2e |
local PATH="$3"
|
|
|
6dca2e |
local MASK="$4"
|
|
|
6dca2e |
local VERSION_FILE="$5"
|
|
|
6dca2e |
|
|
|
6dca2e |
local FILE=`ls "$PATH/"$MASK`
|
|
|
6dca2e |
|
|
|
6dca2e |
local VERSION=`cat "$VERSION_FILE" | cut -d'-' -f 1`
|
|
|
6dca2e |
local COMMIT=`cat "$VERSION_FILE" | cut -d'-' -f 2-`
|
|
|
6dca2e |
COMMIT="${COMMIT:0:5}"
|
|
|
6dca2e |
local DATE=`date -u +%Y.%m.%d`
|
|
|
6dca2e |
if [ -z "$COMMIT" ]; then
|
|
|
6dca2e |
echo "Cannot find version, pheraps package not ready. Cancel."
|
|
|
6dca2e |
return 1
|
|
|
6dca2e |
fi
|
|
|
6dca2e |
|
|
|
6dca2e |
local CHECK_MASK=` \
|
|
|
6dca2e |
echo "$TEMPLATE" \
|
|
|
6dca2e |
| sed "s|%VERSION%|$VERSION|g" \
|
|
|
6dca2e |
| sed "s|%DATE%|*|g" \
|
|
|
6dca2e |
| sed "s|%COMMIT%|$COMMIT|g" `
|
|
|
6dca2e |
local CHECK=`ls "$PUBLISH_DIR/"$CHECK_MASK`
|
|
|
6dca2e |
if [ -z "$CHECK" ]; then
|
|
|
6dca2e |
local TARGET_NAME=` \
|
|
|
6dca2e |
echo "$TEMPLATE" \
|
|
|
6dca2e |
| sed "s|%VERSION%|$VERSION|g" \
|
|
|
6dca2e |
| sed "s|%DATE%|$DATE|g" \
|
|
|
6dca2e |
| sed "s|%COMMIT%|$COMMIT|g" `
|
|
|
6dca2e |
local TARGET="$PUBLISH_DIR/$TARGET_NAME"
|
|
|
6dca2e |
|
|
|
6dca2e |
echo "Publish new version $VERSION-$COMMIT ($TARGET_NAME)"
|
|
|
6dca2e |
`rm -f "$PUBLISH_DIR/"$CHECK_MASK`
|
|
|
6dca2e |
cp "$FILE" "$TARGET"
|
|
|
6dca2e |
if [ -f "$PUBLISH_DIR/publish-$NAME.sh" ]; then
|
|
|
6dca2e |
echo "Call publish-$NAME.sh"
|
|
|
6dca2e |
"$PUBLISH_DIR/publish-$NAME.sh" "$TARGET"
|
|
|
6dca2e |
fi
|
|
|
6dca2e |
else
|
|
|
6dca2e |
echo "Version $VERSION-$COMMIT already published ($CHECK)"
|
|
|
6dca2e |
fi
|
|
|
6dca2e |
}
|
|
|
6dca2e |
|
|
|
6dca2e |
publish $@
|