Build system: Add automatic version file updates for picocms.org
This commit is contained in:
parent
4140ad48ac
commit
3a36dbd934
2 changed files with 79 additions and 3 deletions
|
@ -6,8 +6,11 @@ fi
|
|||
if [ "$DEPLOY_VERSION_BADGE" != "true" ]; then
|
||||
echo "Skipping version badge deployment because it has been disabled"
|
||||
fi
|
||||
if [ "$DEPLOY_PHPDOC_RELEASES" != "true" ] || [ "$DEPLOY_VERSION_BADGE" != "true" ]; then
|
||||
[ "$DEPLOY_PHPDOC_RELEASES" != "true" ] && [ "$DEPLOY_VERSION_BADGE" != "true" ] && exit 0 || echo
|
||||
if [ "$DEPLOY_VERSION_FILE" != "true" ]; then
|
||||
echo "Skipping version file deployment because it has been disabled"
|
||||
fi
|
||||
if [ "$DEPLOY_PHPDOC_RELEASES" != "true" ] || [ "$DEPLOY_VERSION_BADGE" != "true" ] || [ "$DEPLOY_VERSION_FILE" != "true" ]; then
|
||||
[ "$DEPLOY_PHPDOC_RELEASES" != "true" ] && [ "$DEPLOY_VERSION_BADGE" != "true" ] && [ "$DEPLOY_VERSION_FILE" != "true" ] && exit 0 || echo
|
||||
fi
|
||||
|
||||
DEPLOYMENT_ID="${TRAVIS_BRANCH//\//_}"
|
||||
|
@ -51,7 +54,7 @@ if [ "$DEPLOY_VERSION_BADGE" == "true" ]; then
|
|||
"release" "$TRAVIS_TAG" "blue"
|
||||
|
||||
# commit version badge
|
||||
echo "Committing changes..."
|
||||
echo "Committing version badge..."
|
||||
git add "$DEPLOYMENT_DIR/badges/pico-version.svg"
|
||||
git commit \
|
||||
--message="Update version badge for $TRAVIS_TAG" \
|
||||
|
@ -60,6 +63,22 @@ if [ "$DEPLOY_VERSION_BADGE" == "true" ]; then
|
|||
echo
|
||||
fi
|
||||
|
||||
# update version file
|
||||
if [ "$DEPLOY_VERSION_FILE" == "true" ]; then
|
||||
generate-version.sh \
|
||||
"$DEPLOYMENT_DIR/_data/version.yml" \
|
||||
"${TRAVIS_TAG#v}"
|
||||
|
||||
# commit version file
|
||||
echo "Committing version file..."
|
||||
git add "$DEPLOYMENT_DIR/_data/version.yml"
|
||||
git commit \
|
||||
--message="Update version file for $TRAVIS_TAG" \
|
||||
"$DEPLOYMENT_DIR/_data/version.yml"
|
||||
[ $? -eq 0 ] || exit 1
|
||||
echo
|
||||
fi
|
||||
|
||||
# deploy
|
||||
github-deploy.sh "$TRAVIS_REPO_SLUG" "tags/$TRAVIS_TAG" "$TRAVIS_COMMIT"
|
||||
[ $? -eq 0 ] || exit 1
|
||||
|
|
57
_build/generate-version.sh
Executable file
57
_build/generate-version.sh
Executable file
|
@ -0,0 +1,57 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
##
|
||||
# Updates the version file
|
||||
#
|
||||
# @author Daniel Rudolf
|
||||
# @link http://picocms.org
|
||||
# @license http://opensource.org/licenses/MIT
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
# parameters
|
||||
VERSION_FILE_PATH="$1" # target file path
|
||||
VERSION_FULL="$2" # full version string (e.g. 1.0.0-beta.1+7b4ad7f)
|
||||
|
||||
# print parameters
|
||||
echo "Generating version file..."
|
||||
printf 'VERSION_FILE_PATH="%s"\n' "$VERSION_FILE_PATH"
|
||||
printf 'VERSION_FULL="%s"\n' "$VERSION_FULL"
|
||||
echo
|
||||
|
||||
# evaluate version constraint (see http://semver.org/)
|
||||
printf 'Evaluating version constraint...\n'
|
||||
if [[ "$VERSION_FULL" =~ ^([0-9]+)\.([0-9]{1,2})\.([0-9]{1,2})(-([0-9A-Za-z\.\-]+))?(\+([0-9A-Za-z\.\-]+))?$ ]]; then
|
||||
VERSION_MAJOR="${BASH_REMATCH[1]}"
|
||||
VERSION_MINOR="${BASH_REMATCH[2]}"
|
||||
VERSION_PATCH="${BASH_REMATCH[3]}"
|
||||
VERSION_SUFFIX="${BASH_REMATCH[5]}"
|
||||
VERSION_BUILD="${BASH_REMATCH[7]}"
|
||||
|
||||
VERSION_MILESTONE="$VERSION_MAJOR.$VERSION_MINOR"
|
||||
VERSION_NAME="$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH"
|
||||
VERSION_ID="$VERSION_MAJOR$(printf '%02d' "$VERSION_MINOR")$(printf '%02d' "$VERSION_PATCH")"
|
||||
else
|
||||
echo "Invalid version constraint; skipping..." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# generate version file
|
||||
printf 'Updating version file...\n'
|
||||
echo -n "" > "$VERSION_FILE_PATH"
|
||||
exec 3> "$VERSION_FILE_PATH"
|
||||
|
||||
printf 'full: %s\n' "$VERSION_FULL" >&3
|
||||
printf 'name: %s\n' "$VERSION_NAME" >&3
|
||||
printf 'milestone: %s\n' "$VERSION_MILESTONE" >&3
|
||||
printf 'id: %d\n' "$VERSION_ID" >&3
|
||||
printf 'major: %d\n' "$VERSION_MAJOR" >&3
|
||||
printf 'minor: %d\n' "$VERSION_MINOR" >&3
|
||||
printf 'patch: %d\n' "$VERSION_PATCH" >&3
|
||||
printf 'suffix: %s\n' "$VERSION_SUFFIX" >&3
|
||||
printf 'build: %s\n' "$VERSION_BUILD" >&3
|
||||
|
||||
exec 3>&-
|
||||
|
||||
echo
|
Loading…
Add table
Reference in a new issue