Skip to content

Commit

Permalink
Allow specification of build version
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo Chacin <[email protected]>
  • Loading branch information
pablochacin committed Jul 27, 2023
1 parent b04eac6 commit 9e1211b
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions build-package.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/bash

ARCH=$(go env GOARCH)
BUILD="build"
Expand All @@ -7,7 +7,7 @@ DIST="dist"
PKG=""
NAME="xk6-disruptor"
OS=$(go env GOOS)
VERSION="latest"
VERSION=""

function usage() {
cat << EOF
Expand All @@ -33,7 +33,6 @@ options:
-v, --version: package version in semver formatf
-y, --binary: name of the binary (default is name-os-arch)
EOF
}

Expand All @@ -59,6 +58,13 @@ function build() {
binary="$NAME-$os-$arch"
fi

# set disruptor version to use for build
mod=$(go list -m)
replace="."
if [[ ! -z $version ]]; then
replace=${mod}@${version}
fi

#start sub shell to create its own environment
(
if [[ $os == "linux" ]]; then # disable cross-compiling for linux
Expand All @@ -67,8 +73,8 @@ function build() {

export GOARCH=$arch
export GOOS=$os
export XK6_BUILD_FLAGS='-ldflags "-w -s -X github.com/grafana/xk6-disruptor/pkg/internal/consts.Version='${version}'"'
xk6 build --with $(go list -m)=. --output $BUILD/$binary
export XK6_BUILD_FLAGS='-ldflags "-w -s'
xk6 build --with $mod=${replace} --output $BUILD/$binary
)
}

Expand Down

0 comments on commit 9e1211b

Please sign in to comment.