Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle being able to build for both LTS and latest Major #49

Merged
merged 1 commit into from Sep 26, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
95 changes: 79 additions & 16 deletions scripts/build-package.sh
Expand Up @@ -7,6 +7,17 @@

VERSION="$1"

###########################################
# Current Latest Piwik Major Version
# -----------------------------------------
# * We will only update the website piwik.org/download
# when building a release for this latest major version.
# * Update this right before releasing a first "public beta" of a new major version
###########################################
CURRENT_LATEST_MAJOR_VERSION="2"

MAJOR_VERSION=`echo $VERSION | cut -d'.' -f1`

URL_REPO=https://github.com/piwik/piwik.git

LOCAL_REPO="piwik_last_version_git"
Expand Down Expand Up @@ -222,22 +233,41 @@ checkEnv

[ ! -z "$VERSION" ] || die "Expected a version number as a parameter"

echo -e "Going to build Piwik $VERSION (Major version: $MAJOR_VERSION)"

if [ "$MAJOR_VERSION" == "$CURRENT_LATEST_MAJOR_VERSION" ]
then
echo -e "-> Building a new release for the current latest major version (stable or beta)"
BUILDING_LATEST_MAJOR_VERSION_STABLE_OR_BETA=1
else
echo -e "-> Building a new (stable or beta) release for the LONG TERM SUPPORT LTS (not for the current latest major version!) <-"
BUILDING_LATEST_MAJOR_VERSION_STABLE_OR_BETA=0
fi

echo -e "Proceeding..."
sleep 2

############################
echo "Starting build...."
############################


[ -d "$LOCAL_ARCH" ] || mkdir "$LOCAL_ARCH"

cd $BUILD_DIR


if ! [ -d $LOCAL_REPO ]
then
git clone "$URL_REPO" "$LOCAL_REPO"
fi

# we need to exclude LFS files from the upcoming git clone/git checkout,
# unfortunately this git config command does not work...
git config lfs.fetchexclude "tests/"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this git config lfs.fetchexclude "tests/" is not working for some reasons. I'd like the build script to skip all LFS files so the build is faster, but couldn't make it work...

# ^^ not working, LFS files are fetched below... why?!

cd "$LOCAL_REPO"
git checkout master
git checkout master --force
git pull
git fetch --tags
echo "checkout repository for tag $VERSION..."
Expand Down Expand Up @@ -292,20 +322,32 @@ if [ "$(echo "$VERSION" | grep -E 'rc|b|a|alpha|beta|dev' -i | wc -l)" -eq 1 ]
then
if [ "$(echo $VERSION | grep -E 'rc|b|beta' -i | wc -l)" -eq 1 ]
then
echo "Beta or RC release"
echo -e "Beta or RC release"

if [ "$BUILDING_LATEST_MAJOR_VERSION_STABLE_OR_BETA" -eq "1" ]
then
echo -e "Beta or RC release of the latest Major Piwik release"
echo $REMOTE_CMD
$REMOTE_CMD "echo $VERSION > $REMOTE_HTTP_PATH/LATEST_BETA" || die "failed to deploy latest beta version file"

echo $REMOTE_CMD_API
$REMOTE_CMD_API "echo $VERSION > $API_PATH/LATEST_BETA" || die "cannot deploy new version file on piwik-api@$REMOTE_SERVER"
fi

echo -e "Updating LATEST_${MAJOR_VERSION}X_BETA version on api.piwik.org..."
echo $REMOTE_CMD_API
$REMOTE_CMD_API "echo $VERSION > $API_PATH/LATEST_${MAJOR_VERSION}X_BETA" || die "cannot deploy new version file on piwik-api@$REMOTE_SERVER"

fi
echo "build finished! http://builds.piwik.org/piwik-$VERSION.zip"
else
echo "Stable release";

#linking piwik.org/latest.zip to the newly created build
echo "Creating symlinks on the remote server"

if [ "$BUILDING_LATEST_MAJOR_VERSION_STABLE_OR_BETA" -eq "1" ]
then
echo -e "Built current latest Piwik major version: creating symlinks on the remote server"
for name in latest piwik piwik-latest
do
for ext in zip tar.gz; do
Expand All @@ -317,26 +359,17 @@ else
# record filesize in MB
SIZE=$(ls -l "../$LOCAL_ARCH/piwik-$VERSION.zip" | awk '/d|-/{printf("%.3f %s\n",$5/(1024*1024),$9)}')

# upload to builds.piwik.org/LATEST*
echo $REMOTE_CMD
$REMOTE_CMD "echo $VERSION > $REMOTE_HTTP_PATH/LATEST" || die "cannot deploy new version file on $REMOTE"
$REMOTE_CMD "echo $SIZE > $REMOTE_HTTP_PATH/LATEST_SIZE" || die "cannot deploy new archive size on $REMOTE"
$REMOTE_CMD "echo $VERSION > $REMOTE_HTTP_PATH/LATEST_BETA" || die "cannot deploy new version file on $REMOTE"

# upload to piwik.org/LATEST* for the website
echo $REMOTE_CMD_WWW
$REMOTE_CMD_WWW "echo $VERSION > $WWW_PATH/LATEST" || die "cannot deploy new version file on piwik@$REMOTE_SERVER"
$REMOTE_CMD_WWW "echo $SIZE > $WWW_PATH/LATEST_SIZE" || die "cannot deploy new archive size on piwik@$REMOTE_SERVER"

echo $REMOTE_CMD_API
$REMOTE_CMD_API "echo $VERSION > $API_PATH/LATEST" || die "cannot deploy new version file on piwik-api@$REMOTE_SERVER"
$REMOTE_CMD_API "echo $VERSION > $API_PATH/LATEST_BETA" || die "cannot deploy new version file on piwik-api@$REMOTE_SERVER"

# Copy Windows App Gallery release only for stable releases (makes Building betas faster)
echo $REMOTE
$REMOTE_CMD "test -d $REMOTE_HTTP_PATH/WebAppGallery || mkdir $REMOTE_HTTP_PATH/WebAppGallery" || die "cannot access the remote server $REMOTE"
scp -p "../$LOCAL_ARCH/piwik-$VERSION-WAG.zip" "../$LOCAL_ARCH/piwik-$VERSION-WAG.zip.asc" "${REMOTE}:$REMOTE_HTTP_PATH/WebAppGallery/" || die "failed to copy WebAppGalery files"

SHA1_WINDOWS="$(sha1sum ../$LOCAL_ARCH/piwik-$VERSION-WAG.zip | cut -d' ' -f1)"
[ -z "$SHA1_WINDOWS" ] && die "cannot compute sha1 hash for ../$LOCAL_ARCH/piwik-$VERSION-WAG.zip"

echo -e "Sending email to Microsoft web team \n\n"
echo -e "Hello, \n\n\
Expand All @@ -350,5 +383,35 @@ Thank you,\n\n\
Piwik team"
echo -e "\n----> Send this email 'New Piwik Version $VERSION' to appgal@microsoft.com,hello@piwik.org"

echo "build finished! http://builds.piwik.org/piwik.zip"
fi

# Copy Windows App Gallery release only for stable releases (makes Building betas faster)
echo $REMOTE
$REMOTE_CMD "test -d $REMOTE_HTTP_PATH/WebAppGallery || mkdir $REMOTE_HTTP_PATH/WebAppGallery" || die "cannot access the remote server $REMOTE"
scp -p "../$LOCAL_ARCH/piwik-$VERSION-WAG.zip" "../$LOCAL_ARCH/piwik-$VERSION-WAG.zip.asc" "${REMOTE}:$REMOTE_HTTP_PATH/WebAppGallery/" || die "failed to copy WebAppGalery files"

SHA1_WINDOWS="$(sha1sum ../$LOCAL_ARCH/piwik-$VERSION-WAG.zip | cut -d' ' -f1)"
[ -z "$SHA1_WINDOWS" ] && die "cannot compute sha1 hash for ../$LOCAL_ARCH/piwik-$VERSION-WAG.zip"

echo -e ""

if [ "$BUILDING_LATEST_MAJOR_VERSION_STABLE_OR_BETA" -eq "1" ]
then
echo -e "Updating LATEST and LATEST_BETA versions on api.piwik.org..."
echo $REMOTE_CMD_API
$REMOTE_CMD_API "echo $VERSION > $API_PATH/LATEST" || die "cannot deploy new version file on piwik-api@$REMOTE_SERVER"
$REMOTE_CMD_API "echo $VERSION > $API_PATH/LATEST_BETA" || die "cannot deploy new version file on piwik-api@$REMOTE_SERVER"
fi

echo -e "Updating the LATEST_${MAJOR_VERSION}X and LATEST_${MAJOR_VERSION}X_BETA version on api.piwik.org"
echo $REMOTE_CMD_API
$REMOTE_CMD_API "echo $VERSION > $API_PATH/LATEST_${MAJOR_VERSION}X" || die "cannot deploy new version file on piwik-api@$REMOTE_SERVER"
$REMOTE_CMD_API "echo $VERSION > $API_PATH/LATEST_${MAJOR_VERSION}X_BETA" || die "cannot deploy new version file on piwik-api@$REMOTE_SERVER"

if [ "$BUILDING_LATEST_MAJOR_VERSION_STABLE_OR_BETA" -eq "1" ]
then
echo -e "build finished! http://builds.piwik.org/piwik.zip"
else
echo -e "build for LONG TERM SUPPORT version finished! http://builds.piwik.org/piwik-$VERSION.zip"
fi
fi