mirror of https://github.com/prometheus/prometheus
Browse Source
[WIP] New release process using docker, circleci and a centralized building toolpull/1575/head
Fabian Reinartz
9 years ago
10 changed files with 136 additions and 163 deletions
@ -1,3 +1,5 @@
|
||||
data/ |
||||
prometheus |
||||
promtool |
||||
.build/ |
||||
.tarballs/ |
||||
|
||||
!.build/linux-amd64/ |
||||
|
@ -0,0 +1,45 @@
|
||||
go: 1.5.4 |
||||
repository: |
||||
path: github.com/prometheus/prometheus |
||||
build: |
||||
binaries: |
||||
- name: prometheus |
||||
path: ./cmd/prometheus |
||||
- name: promtool |
||||
path: ./cmd/promtool |
||||
flags: -tags netgo |
||||
ldflags: | |
||||
-X {{repoPath}}/version.Version={{.Version}} |
||||
-X {{repoPath}}/version.Revision={{.Revision}} |
||||
-X {{repoPath}}/version.Branch={{.Branch}} |
||||
-X {{repoPath}}/version.BuildUser={{user}}@{{host}} |
||||
-X {{repoPath}}/version.BuildDate={{date "20060102-15:04:05"}} |
||||
tarball: |
||||
files: |
||||
- consoles |
||||
- console_libraries |
||||
- documentation/examples/prometheus.yml |
||||
- LICENSE |
||||
- NOTICE |
||||
crossbuild: |
||||
platforms: |
||||
- linux/amd64 |
||||
- linux/386 |
||||
- darwin/amd64 |
||||
- darwin/386 |
||||
- windows/amd64 |
||||
- windows/386 |
||||
- freebsd/amd64 |
||||
- freebsd/386 |
||||
- openbsd/amd64 |
||||
- openbsd/386 |
||||
- netbsd/amd64 |
||||
- netbsd/386 |
||||
- dragonfly/amd64 |
||||
- linux/arm |
||||
- linux/arm64 |
||||
- freebsd/arm |
||||
- openbsd/arm |
||||
- netbsd/arm |
||||
- linux/ppc64 |
||||
- linux/ppc64le |
@ -1,11 +1,54 @@
|
||||
machine: |
||||
environment: |
||||
DOCKER_IMAGE_NAME: prom/prometheus |
||||
DOCKER_TEST_IMAGE_NAME: prom/golang-builder:1.5.3-main |
||||
REPO_PATH: github.com/prometheus/prometheus |
||||
pre: |
||||
- sudo curl -L -o /usr/bin/docker 'https://s3-external-1.amazonaws.com/circle-downloads/docker-1.9.1-circleci' |
||||
- sudo chmod 0755 /usr/bin/docker |
||||
- sudo curl -L 'https://github.com/aktau/github-release/releases/download/v0.6.2/linux-amd64-github-release.tar.bz2' | tar xvjf - --strip-components 3 -C $HOME/bin |
||||
services: |
||||
- docker |
||||
|
||||
dependencies: |
||||
pre: |
||||
- go get -u github.com/prometheus/promu |
||||
- docker info |
||||
override: |
||||
- make docker |
||||
- promu crossbuild |
||||
- ln -s .build/linux-amd64/prometheus prometheus |
||||
- ln -s .build/linux-amd64/promtool promtool |
||||
- | |
||||
if [ -n "$CIRCLE_TAG" ]; then |
||||
make docker DOCKER_IMAGE_NAME=$DOCKER_IMAGE_NAME DOCKER_IMAGE_TAG=$CIRCLE_TAG |
||||
else |
||||
make docker DOCKER_IMAGE_NAME=$DOCKER_IMAGE_NAME |
||||
fi |
||||
post: |
||||
- mkdir $CIRCLE_ARTIFACTS/binaries/ && cp -a .build/* $CIRCLE_ARTIFACTS/binaries/ |
||||
- docker images |
||||
|
||||
test: |
||||
override: |
||||
- /bin/true |
||||
- docker run --rm -t -v "$(pwd):/app" "${DOCKER_TEST_IMAGE_NAME}" -i "${REPO_PATH}" -T |
||||
|
||||
deployment: |
||||
hub_branch: |
||||
branch: master |
||||
owner: prometheus |
||||
commands: |
||||
- docker login -e $DOCKER_EMAIL -u $DOCKER_LOGIN -p $DOCKER_PASSWORD |
||||
- docker push $DOCKER_IMAGE_NAME |
||||
hub_tag: |
||||
tag: /^[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)$/ |
||||
owner: prometheus |
||||
commands: |
||||
- promu crossbuild tarballs |
||||
- promu release .tarballs |
||||
- mkdir $CIRCLE_ARTIFACTS/releases/ && cp -a .tarballs/* $CIRCLE_ARTIFACTS/releases/ |
||||
- docker login -e $DOCKER_EMAIL -u $DOCKER_LOGIN -p $DOCKER_PASSWORD |
||||
- | |
||||
if [[ "$CIRCLE_TAG" =~ ^[0-9]+(\.[0-9]+){2}$ ]]; then |
||||
docker tag "$DOCKER_IMAGE_NAME:$CIRCLE_TAG" "$DOCKER_IMAGE_NAME:latest" |
||||
fi |
||||
- docker push $DOCKER_IMAGE_NAME |
||||
|
@ -1,46 +0,0 @@
|
||||
#!/usr/bin/env bash |
||||
|
||||
# Copyright 2015 The Prometheus Authors |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||
# you may not use this file except in compliance with the License. |
||||
# You may obtain a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, |
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
# See the License for the specific language governing permissions and |
||||
# limitations under the License. |
||||
|
||||
set -e |
||||
|
||||
repo_path="github.com/prometheus/prometheus" |
||||
|
||||
version=$( cat version/VERSION ) |
||||
revision=$( git rev-parse --short HEAD 2> /dev/null || echo 'unknown' ) |
||||
branch=$( git rev-parse --abbrev-ref HEAD 2> /dev/null || echo 'unknown' ) |
||||
host=$( hostname ) |
||||
build_date=$( TZ=UTC date +%Y%m%d-%H:%M:%S ) |
||||
|
||||
if [ "$(go env GOOS)" = "windows" ]; then |
||||
ext=".exe" |
||||
fi |
||||
|
||||
ldflags=" |
||||
-X ${repo_path}/version.Version=${version} |
||||
-X ${repo_path}/version.Revision=${revision} |
||||
-X ${repo_path}/version.Branch=${branch} |
||||
-X ${repo_path}/version.BuildUser=${USER}@${host} |
||||
-X ${repo_path}/version.BuildDate=${build_date} |
||||
${EXTRA_LDFLAGS}" |
||||
|
||||
export GO15VENDOREXPERIMENT="1" |
||||
|
||||
echo " > prometheus" |
||||
go build -ldflags "${ldflags}" -o prometheus${ext} ${repo_path}/cmd/prometheus |
||||
|
||||
echo " > promtool" |
||||
go build -ldflags "${ldflags}" -o promtool${ext} ${repo_path}/cmd/promtool |
||||
|
||||
exit 0 |
@ -1,50 +0,0 @@
|
||||
# Copyright 2015 The Prometheus Authors |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||
# you may not use this file except in compliance with the License. |
||||
# You may obtain a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, |
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
# See the License for the specific language governing permissions and |
||||
# limitations under the License. |
||||
|
||||
goroot="$1" |
||||
gopath="$2" |
||||
|
||||
go_version_min="1.5" |
||||
go_version_install="1.5.3" |
||||
|
||||
vernum() { |
||||
printf "%03d%03d%03d" $(echo "$1" | tr '.' ' ') |
||||
} |
||||
|
||||
if command -v "go" >/dev/null; then |
||||
go_version=$(go version | sed -e 's/^[^0-9.]*\([0-9.]*\).*/\1/') |
||||
fi |
||||
|
||||
# If we satisfy the version requirement, there is nothing to do. Otherwise |
||||
# proceed downloading and installing a go environment. |
||||
if [ $(vernum ${go_version}) -ge $(vernum ${go_version_min}) ]; then |
||||
return |
||||
fi |
||||
|
||||
export GOPATH="${gopath}" |
||||
export GOROOT="${goroot}/${go_version_install}" |
||||
|
||||
export PATH="$PATH:$GOROOT/bin" |
||||
|
||||
if [ ! -x "${GOROOT}/bin/go" ]; then |
||||
|
||||
mkdir -p "${GOROOT}" |
||||
|
||||
os=$(uname | tr A-Z a-z) |
||||
arch=$(uname -m | sed -e 's/x86_64/amd64/' | sed -e 's/i.86/386/') |
||||
|
||||
url="https://golang.org/dl" |
||||
tarball="go${go_version_install}.${os}-${arch}.tar.gz" |
||||
|
||||
wget -qO- "${url}/${tarball}" | tar -C "${GOROOT}" --strip 1 -xz |
||||
fi |
@ -1,42 +0,0 @@
|
||||
#!/usr/bin/env bash |
||||
|
||||
# Copyright 2015 The Prometheus Authors |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||
# you may not use this file except in compliance with the License. |
||||
# You may obtain a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, |
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
# See the License for the specific language governing permissions and |
||||
# limitations under the License. |
||||
|
||||
set -e |
||||
|
||||
version=$(cat version/VERSION) |
||||
|
||||
for GOOS in "darwin" "freebsd" "linux" "windows"; do |
||||
for GOARCH in "amd64" "386"; do |
||||
export GOARCH |
||||
export GOOS |
||||
make build |
||||
|
||||
tarball_dir="prometheus-${version}.${GOOS}-${GOARCH}" |
||||
tarball="${tarball_dir}.tar.gz" |
||||
|
||||
if [ "$(go env GOOS)" = "windows" ]; then |
||||
ext=".exe" |
||||
fi |
||||
|
||||
echo " > $tarball" |
||||
mkdir -p "${tarball_dir}" |
||||
cp -a "prometheus${ext}" "promtool${ext}" consoles console_libraries "${tarball_dir}" |
||||
tar -czf "${tarball}" "${tarball_dir}" |
||||
rm -rf "${tarball_dir}" |
||||
rm "prometheus${ext}" "promtool${ext}" |
||||
done |
||||
done |
||||
|
||||
exit 0 |
Loading…
Reference in new issue