Fix build versioning; add dev.docker file
This commit is contained in:
parent
db787f9a83
commit
7b41da4ddd
10
Makefile
10
Makefile
|
@ -49,12 +49,16 @@ test-all: lint
|
||||||
go test ./...
|
go test ./...
|
||||||
|
|
||||||
package:
|
package:
|
||||||
./scripts/build.py --package --version="$(VERSION)" --platform=linux --arch=all --upload
|
./scripts/build.py --package --platform=all --arch=all
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-rm -f telegraf
|
-rm -f telegraf
|
||||||
-rm -f telegraf.exe
|
-rm -f telegraf.exe
|
||||||
|
|
||||||
|
docker-image:
|
||||||
|
./scripts/build.py --package --platform=linux --arch=amd64
|
||||||
|
cp build/telegraf*$(COMMIT)*.deb .
|
||||||
|
docker build -f scripts/dev.docker --build-arg "package=telegraf*$(COMMIT)*.deb" -t "telegraf-dev:$(COMMIT)" .
|
||||||
|
|
||||||
# Run all docker containers necessary for integration tests
|
# Run all docker containers necessary for integration tests
|
||||||
docker-run:
|
docker-run:
|
||||||
docker run --name aerospike -p "3000:3000" -d aerospike/aerospike-server:3.9.0
|
docker run --name aerospike -p "3000:3000" -d aerospike/aerospike-server:3.9.0
|
||||||
|
@ -114,4 +118,4 @@ docker-kill:
|
||||||
openldap postgres rabbitmq redis riemann zookeeper
|
openldap postgres rabbitmq redis riemann zookeeper
|
||||||
|
|
||||||
.PHONY: deps telegraf telegraf.exe install test test-windows lint test-all \
|
.PHONY: deps telegraf telegraf.exe install test test-windows lint test-all \
|
||||||
package clean docker-run docker-run-circle docker-kill
|
package clean docker-run docker-run-circle docker-kill docker-image
|
||||||
|
|
|
@ -268,7 +268,7 @@ func (p *program) Stop(s service.Service) error {
|
||||||
|
|
||||||
func displayVersion() string {
|
func displayVersion() string {
|
||||||
if version == "" {
|
if version == "" {
|
||||||
return fmt.Sprintf("v%s~pre%s", nextVersion, commit)
|
return fmt.Sprintf("v%s~%s", nextVersion, commit)
|
||||||
}
|
}
|
||||||
return "v" + version
|
return "v" + version
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,6 +95,8 @@ supported_packages = {
|
||||||
"freebsd": [ "tar" ]
|
"freebsd": [ "tar" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
next_version = '1.5.0'
|
||||||
|
|
||||||
################
|
################
|
||||||
#### Telegraf Functions
|
#### Telegraf Functions
|
||||||
################
|
################
|
||||||
|
@ -158,7 +160,8 @@ def go_get(branch, update=False, no_uncommitted=False):
|
||||||
get_command = "go get github.com/sparrc/gdm"
|
get_command = "go get github.com/sparrc/gdm"
|
||||||
run(get_command)
|
run(get_command)
|
||||||
logging.info("Retrieving dependencies with `gdm`...")
|
logging.info("Retrieving dependencies with `gdm`...")
|
||||||
run("{}/bin/gdm restore -v".format(os.environ.get("GOPATH")))
|
run("{}/bin/gdm restore -v".format(os.environ.get("GOPATH",
|
||||||
|
os.path.expanduser("~/go"))))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def run_tests(race, parallel, timeout, no_vet):
|
def run_tests(race, parallel, timeout, no_vet):
|
||||||
|
@ -223,13 +226,16 @@ def increment_minor_version(version):
|
||||||
def get_current_version_tag():
|
def get_current_version_tag():
|
||||||
"""Retrieve the raw git version tag.
|
"""Retrieve the raw git version tag.
|
||||||
"""
|
"""
|
||||||
version = run("git describe --always --tags --abbrev=0")
|
version = run("git describe --exact-match --tags 2>/dev/null",
|
||||||
|
allow_failure=True, shell=True)
|
||||||
return version
|
return version
|
||||||
|
|
||||||
def get_current_version():
|
def get_current_version():
|
||||||
"""Parse version information from git tag output.
|
"""Parse version information from git tag output.
|
||||||
"""
|
"""
|
||||||
version_tag = get_current_version_tag()
|
version_tag = get_current_version_tag()
|
||||||
|
if not version_tag:
|
||||||
|
return None
|
||||||
# Remove leading 'v'
|
# Remove leading 'v'
|
||||||
if version_tag[0] == 'v':
|
if version_tag[0] == 'v':
|
||||||
version_tag = version_tag[1:]
|
version_tag = version_tag[1:]
|
||||||
|
@ -474,12 +480,17 @@ def build(version=None,
|
||||||
if len(tags) > 0:
|
if len(tags) > 0:
|
||||||
build_command += "-tags {} ".format(','.join(tags))
|
build_command += "-tags {} ".format(','.join(tags))
|
||||||
|
|
||||||
build_command += "-ldflags=\"-w -s -X main.version={} -X main.branch={} -X main.commit={}\" ".format(
|
ldflags = [
|
||||||
version,
|
'-w', '-s',
|
||||||
get_current_branch(),
|
'-X', 'main.branch={}'.format(get_current_branch()),
|
||||||
get_current_commit())
|
'-X', 'main.commit={}'.format(get_current_commit(short=True))]
|
||||||
|
if version:
|
||||||
|
ldflags.append('-X')
|
||||||
|
ldflags.append('main.version={}'.format(version))
|
||||||
|
build_command += ' -ldflags="{}" '.format(' '.join(ldflags))
|
||||||
|
|
||||||
if static:
|
if static:
|
||||||
build_command += "-a -installsuffix cgo "
|
build_command += " -a -installsuffix cgo "
|
||||||
build_command += path
|
build_command += path
|
||||||
start_time = datetime.utcnow()
|
start_time = datetime.utcnow()
|
||||||
run(build_command, shell=True)
|
run(build_command, shell=True)
|
||||||
|
@ -575,10 +586,8 @@ def package(build_output, pkg_name, version, nightly=False, iteration=1, static=
|
||||||
package_arch = 'armv6hl'
|
package_arch = 'armv6hl'
|
||||||
else:
|
else:
|
||||||
package_arch = arch
|
package_arch = arch
|
||||||
if not release and not nightly:
|
if not version:
|
||||||
# For non-release builds, just use the commit hash as the version
|
package_version = "{}~{}".format(next_version, get_current_commit(short=True))
|
||||||
package_version = "{}~{}".format(version,
|
|
||||||
get_current_commit(short=True))
|
|
||||||
package_iteration = "0"
|
package_iteration = "0"
|
||||||
package_build_root = build_root
|
package_build_root = build_root
|
||||||
current_location = build_output[platform][arch]
|
current_location = build_output[platform][arch]
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
FROM debian:stretch
|
||||||
|
ARG package
|
||||||
|
ADD ${package} ${package}
|
||||||
|
RUN dpkg -i ${package}
|
||||||
|
|
||||||
|
EXPOSE 8125/udp 8092/udp 8094
|
||||||
|
|
||||||
|
CMD ["telegraf"]
|
Loading…
Reference in New Issue