Skip to content

Commit

Permalink
Merge pull request #285 from Waldz/feature/MYST-577-working-releases
Browse files Browse the repository at this point in the history
MYST-577 Fix missing version during "dev" builds
  • Loading branch information
Waldz authored Jul 11, 2018
2 parents 7e064c9 + 19fa95d commit 32a1774
Show file tree
Hide file tree
Showing 13 changed files with 97 additions and 91 deletions.
23 changes: 15 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ env:
- CACHE_ROOT_DIR=$HOME/cache
- BUILD_TOOLS_PATH=$CACHE_ROOT_DIR/build_tools
- GLIDE_HOME=$HOME/glide-home
- COMMIT=$TRAVIS_COMMIT
- BRANCH=$TRAVIS_BRANCH
- BUILD_COMMIT=$TRAVIS_COMMIT
- BUILD_BRANCH=$TRAVIS_BRANCH
- BUILD_NUMBER=$TRAVIS_BUILD_NUMBER
- VERSION=$TRAVIS_TAG
- BUILD_VERSION_MAJOR=0

cache:
directories:
Expand All @@ -21,26 +21,27 @@ cache:
install:
- source bin/travis_scripts/setup_tools_dir.sh $BUILD_TOOLS_PATH
- source bin/travis_scripts/ensure_glide.sh $BUILD_TOOLS_PATH "v0.13.1"
- bin/travis_scripts/ensure_xgo.sh
- glide "-home" $GLIDE_HOME install

script:
- BUILD_VERSION=${TRAVIS_TAG:="$BUILD_VERSION_MAJOR-dev.$TRAVIS_BUILD_NUMBER"}
- bin/check_vet
# This check requires development dependency
- bin/builder_run bin/check_lint
- bin/check_fmt
- bin/check_license
- bin/test
# Run e2e tests on Pull Requests only
# Run e2e tests (on Pull Requests only)
- if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
bin/travis_scripts/check_docker.sh;
bin/travis_scripts/check_docker_compose.sh;
bin/test_e2e;
fi
- bin/package_all $BUILD_VERSION

before_deploy:
- bin/travis_scripts/ensure_xgo.sh
- bin/package_all $VERSION
deploy:
# Development bleeding-edge release (on master commits only)
- provider: pages
local-dir: build/package
skip-cleanup: true
Expand All @@ -51,6 +52,12 @@ deploy:
on:
tags: false
branch: master
- provider: script
script: bin/release_docker dev
on:
tags: false
branch: master
# Official release (on tags only)
- provider: releases
file_glob: true
file: build/package/*
Expand All @@ -59,7 +66,7 @@ deploy:
on:
tags: true
- provider: script
script: bin/release_docker $VERSION
script: bin/release_docker $TRAVIS_TAG latest
on:
tags: true
notifications:
Expand Down
7 changes: 3 additions & 4 deletions bin/client_package_docker
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@

set -e

DOCKER_IMAGE="mysteriumnetwork/mysterium-client"
DOCKER_BUILD_TAG="alpine"
source bin/helpers/output.sh

printf "Building Alpine image..\n"
docker build \
--file bin/client_docker/alpine/Dockerfile \
--tag ${DOCKER_IMAGE}:${DOCKER_BUILD_TAG} \
--tag mysterium-client:alpine \
.

printf "\e[0;32m%s\e[0m\n" "Docker image building process complete!"
print_success "Docker image building process complete!"
exit 0
13 changes: 6 additions & 7 deletions bin/client_package_docker_ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,20 @@

set -e

source bin/helpers/output.sh

VERSION=$1
if [ -z "$VERSION" ]; then
printf "\e[0;31m%s\e[0m\n" "Missing version!"
print_error "Missing version!"
exit 1
fi

DOCKER_IMAGE="mysteriumnetwork/mysterium-client"
DOCKER_BUILD_TAG="ubuntu"

printf "Building Ubuntu image..\n" \
printf "Building Ubuntu image..\n"
docker build \
--file bin/client_docker/ubuntu/Dockerfile \
--build-arg PACKAGE_VERSION=${VERSION} \
--tag ${DOCKER_IMAGE}:${DOCKER_BUILD_TAG} \
--tag mysterium-client:ubuntu \
.

printf "\e[0;32m%s\e[0m\n" "Docker image building process complete!"
print_success "Docker image building process complete!"
exit 0
2 changes: 1 addition & 1 deletion bin/client_package_standalone
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ if [ "$OS" == "windows" ]; then
PACKAGE_FILE="${DIR_BUILD}/`basename -s .exe ${BINARY}`.zip"
(cd ${DIR_TEMP} && zip -r - .) > ${PACKAGE_FILE}
else
PACKAGE_FILE="${DIR_BUILD}/`basename -s .exe ${BINARY}`.tar.gz"
PACKAGE_FILE="${DIR_BUILD}/`basename ${BINARY}`.tar.gz"
tar -zcv -f ${PACKAGE_FILE} -C ${DIR_TEMP} .
fi
rm -rf ${DIR_TEMP}
Expand Down
23 changes: 8 additions & 15 deletions bin/helpers/docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,15 @@
# Uploads already created Docker image to Docker Hub
#
# Usage:
# > docker_release_image <version> [tag..]
# > docker_release_image <image-local> <image-release>
#
# Uploads specific version:
# > docker_release_image mysteriumnetwork/mysterium-node alpine 0.0.1
#
# Uploads several versions
# > docker_release_image mysteriumnetwork/mysterium-node ubuntu ${VERSION}-ubuntu ubuntu
# Uploads specific tag:
# > docker_release_image mysterium-node:alpine mysteriumnetwork/mysterium-node:0.0.1
docker_release_image () {
DOCKER_IMAGE=$1; shift;
DOCKER_BUILD_TAG=$2; shift;

while test $# -gt 0; do
DOCKER_TAG=$1; shift;
IMAGE_LOCAL=$1;
IMAGE_RELEASE=$2;

printf "Publishing '${DOCKER_TAG}' image..\n"
docker tag ${DOCKER_IMAGE}:${DOCKER_BUILD_TAG} ${DOCKER_IMAGE}:${DOCKER_TAG}
docker push ${DOCKER_IMAGE}:${DOCKER_TAG}
done
printf "Publishing '${IMAGE_RELEASE}' image..\n"
docker tag ${IMAGE_LOCAL} ${IMAGE_RELEASE}
docker push ${IMAGE_RELEASE}
}
6 changes: 3 additions & 3 deletions bin/helpers/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

# Map environment variables to flags for Golang linker's -ldflags usage
function get_linker_ldflags {
[ -n "$BRANCH" ] && echo -n "-X 'github.com/mysterium/node/metadata.BuildBranch=${BRANCH}' "
[ -n "$COMMIT" ] && echo -n "-X 'github.com/mysterium/node/metadata.BuildCommit=${COMMIT}' "
[ -n "$BUILD_BRANCH" ] && echo -n "-X 'github.com/mysterium/node/metadata.BuildBranch=${BUILD_BRANCH}' "
[ -n "$BUILD_COMMIT" ] && echo -n "-X 'github.com/mysterium/node/metadata.BuildCommit=${BUILD_COMMIT}' "
[ -n "$BUILD_NUMBER" ] && echo -n "-X 'github.com/mysterium/node/metadata.BuildNumber=${BUILD_NUMBER}' "

[ -n "$BUILD_VERSION" ] && echo -n "-X 'github.com/mysterium/node/metadata.Version=${BUILD_VERSION}' "
}
14 changes: 7 additions & 7 deletions bin/package_all
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ fi

DIR_BUILD="build/package"

printf "Creating build directory '$DIR_BUILD' ..\n"
printf "Building version '$VERSION' packages to directory '$DIR_BUILD' ..\n"
rm -rf ${DIR_BUILD}
mkdir -p ${DIR_BUILD}

bin/server_build_xgo darwin/amd64 windows/amd64 linux/amd64
bin/client_build_xgo darwin/amd64 windows/amd64 linux/amd64

BINARY=build/server/mysterium_server_darwin_amd64 bin/server_package_standalone
BINARY=build/server/mysterium_server_windows_amd64.exe bin/server_package_standalone
BINARY=build/server/mysterium_server_linux_amd64 bin/server_package_standalone
BINARY=build/server/mysterium_server_darwin_amd64 bin/server_package_standalone darwin
BINARY=build/server/mysterium_server_windows_amd64.exe bin/server_package_standalone windows
BINARY=build/server/mysterium_server_linux_amd64 bin/server_package_standalone linux

BINARY=build/client/mysterium_client_darwin_amd64 bin/client_package_standalone
BINARY=build/client/mysterium_client_windows_amd64.exe bin/client_package_standalone
BINARY=build/client/mysterium_client_linux_amd64 bin/client_package_standalone
BINARY=build/client/mysterium_client_darwin_amd64 bin/client_package_standalone darwin
BINARY=build/client/mysterium_client_windows_amd64.exe bin/client_package_standalone windows
BINARY=build/client/mysterium_client_linux_amd64 bin/client_package_standalone linux

bin/builder_run BINARY=build/server/mysterium_server_linux_amd64 bin/server_package_debian ${VERSION} amd64
bin/builder_run BINARY=build/client/mysterium_client_linux_amd64 bin/client_package_debian ${VERSION} amd64
Expand Down
34 changes: 21 additions & 13 deletions bin/release_docker
Original file line number Diff line number Diff line change
@@ -1,38 +1,46 @@
#!/bin/bash

###########################################################################
# Release creates all supported Docker images and uploads them to Docker Hub
# Uploads all created Docker images to Docker Hub
# - https://hub.docker.com/r/mysteriumnetwork/mysterium-node/
# - https://hub.docker.com/r/mysteriumnetwork/mysterium-client/
#
# Usage:
#> bin/release_docker <version>
#> bin/release_docker <version>..
#
# Release specific version with personal Docker Hub account:
#> docker login john.developer ****
# Release image (specific version):
#> bin/release_docker 0.0.1
#
# Tag several versions at the same time
#> bin/release_docker 0.0.1 0.0.1-alpine alpine latest
# Release image (several versions):
#> bin/release_docker 0.0.1 latest
#
# Create image (with personal Docker Hub account):
#> DOCKER_USERNAME=john.developer DOCKER_PASSWORD=**** bin/release_docker 0.0.1

set -e

source bin/helpers/output.sh
source bin/helpers/docker.sh

VERSION=$1
if [ -z "$VERSION" ]; then
if [ -z "$1" ]; then
print_error "Missing version!"
exit 1
fi

echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin

docker_release_image mysteriumnetwork/mysterium-node alpine ${VERSION} ${VERSION}-alpine alpine latest
docker_release_image mysteriumnetwork/mysterium-node ubuntu ${VERSION} ${VERSION}-ubuntu ubuntu
while test $# -gt 0; do
VERSION_TAG=$1; shift;
printf "Creating Docker Hub release '$VERSION_TAG' ..\n" \

docker_release_image mysterium-node:alpine mysteriumnetwork/mysterium-node:${VERSION_TAG}
docker_release_image mysterium-node:alpine mysteriumnetwork/mysterium-node:${VERSION_TAG}-alpine
docker_release_image mysterium-node:ubuntu mysteriumnetwork/mysterium-node:${VERSION_TAG}-ubuntu

docker_release_image mysteriumnetwork/mysterium-client alpine ${VERSION} ${VERSION}-alpine alpine latest
docker_release_image mysteriumnetwork/mysterium-client ubuntu ${VERSION}-ubuntu ubuntu
docker_release_image mysterium-client:alpine mysteriumnetwork/mysterium-client:${VERSION_TAG}
docker_release_image mysterium-client:alpine mysteriumnetwork/mysterium-client:${VERSION_TAG}-alpine
docker_release_image mysterium-client:ubuntu mysteriumnetwork/mysterium-client:${VERSION_TAG}-ubuntu
done

print_success "Docker Hub release '$VERSION' created!"
print_success "Docker Hub releases created!"
exit 0
9 changes: 4 additions & 5 deletions bin/server_package_docker
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@

set -e

DOCKER_IMAGE="mysteriumnetwork/mysterium-node"
DOCKER_BUILD_TAG="alpine"
source bin/helpers/output.sh

printf "Building Alpine image..\n" \
printf "Building Alpine image..\n"
docker build \
--file bin/server_docker/alpine/Dockerfile \
--tag ${DOCKER_IMAGE}:${DOCKER_BUILD_TAG} \
--tag mysterium-node:alpine \
.

printf "\e[0;32m%s\e[0m\n" "Docker image building process complete!"
print_success "Docker image building process complete!"
exit 0
13 changes: 6 additions & 7 deletions bin/server_package_docker_ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,20 @@

set -e

source bin/helpers/output.sh

VERSION=$1
if [ -z "$VERSION" ]; then
printf "\e[0;31m%s\e[0m\n" "Missing version!"
print_error "Missing version!"
exit 1
fi

DOCKER_IMAGE="mysteriumnetwork/mysterium-node"
DOCKER_BUILD_TAG="ubuntu"

printf "Building Ubuntu image..\n" \
printf "Building Ubuntu image..\n"
docker build \
--file bin/server_docker/ubuntu/Dockerfile \
--build-arg PACKAGE_VERSION=${VERSION} \
--tag ${DOCKER_IMAGE}:${DOCKER_BUILD_TAG} \
--tag mysterium-node:ubuntu \
.

printf "\e[0;32m%s\e[0m\n" "Docker image building process complete!"
print_success "Docker image building process complete!"
exit 0
2 changes: 1 addition & 1 deletion bin/server_package_standalone
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ if [ "$OS" == "windows" ]; then
PACKAGE_FILE="${DIR_BUILD}/`basename -s .exe ${BINARY}`.zip"
(cd ${DIR_TEMP} && zip -r - .) > ${PACKAGE_FILE}
else
PACKAGE_FILE="${DIR_BUILD}/`basename -s ${BINARY}`.tar.gz"
PACKAGE_FILE="${DIR_BUILD}/`basename ${BINARY}`.tar.gz"
tar -zcv -f ${PACKAGE_FILE} -C ${DIR_TEMP} .
fi
tar -zcv -f ${PACKAGE_FILE} -C ${DIR_TEMP} .
Expand Down
8 changes: 4 additions & 4 deletions metadata/build_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ package metadata
import "fmt"

var (
// BuildCommit comes from COMMIT env variable
BuildCommit = "<unknown>"
// BuildBranch comes from BRANCH env variable - if it's github release, this variable will contain release tag name
// BuildCommit comes from BUILD_COMMIT env variable (set via linker flags)
BuildCommit = ""
// BuildBranch comes from BUILD_BRANCH env variable (set via linker flags)
BuildBranch = "<unknown>"
// BuildNumber comes from TRAVIS_JOB_NUMBER env variable
// BuildNumber comes from BUILD_NUMBER env variable (set via linker flags)
BuildNumber = "dev-build"
)

Expand Down
34 changes: 18 additions & 16 deletions metadata/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,10 @@

package metadata

import (
"fmt"
)

const (
// VersionMajor is version component of the current release
VersionMajor = 0
// VersionMinor is version component of the current release
VersionMinor = 0
// VersionPatch is version component of the current release
VersionPatch = 6
)
import "fmt"

// VersionAsString returns all defined version constants as single string
func VersionAsString() string {
return fmt.Sprintf("%d.%d.%d", VersionMajor, VersionMinor, VersionPatch)
}
// Version comes from BUILD_VERSION env variable (set via linker flags)
var Version = ""

const versionSummaryFormat = `Mysterium Node
Version: %s
Expand All @@ -42,6 +29,21 @@ const versionSummaryFormat = `Mysterium Node
%s
%s`

// VersionAsString returns all defined version constants as single string
func VersionAsString() string {
if Version != "" {
return Version
}

version := "source"
if len(BuildCommit) >= 8 {
version += "." + BuildCommit[:8]
} else if BuildNumber != "" {
version += "." + BuildNumber
}
return version
}

// VersionAsSummary returns overview of current program's version
func VersionAsSummary(licenseCopyright string) string {
return fmt.Sprintf(
Expand Down

0 comments on commit 32a1774

Please sign in to comment.