mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-16 15:10:12 +01:00
redo ci
This commit is contained in:
parent
d44c6e7ddc
commit
6b1dfcedc1
6 changed files with 204 additions and 58 deletions
82
.circleci/config.yml
Normal file
82
.circleci/config.yml
Normal file
|
|
@ -0,0 +1,82 @@
|
||||||
|
version: 2.1
|
||||||
|
|
||||||
|
executors:
|
||||||
|
go:
|
||||||
|
docker:
|
||||||
|
- image: circleci/golang:latest
|
||||||
|
working_directory: ~/repo
|
||||||
|
|
||||||
|
workflows:
|
||||||
|
version: 2
|
||||||
|
ci:
|
||||||
|
jobs:
|
||||||
|
- checkout
|
||||||
|
- linting
|
||||||
|
requires:
|
||||||
|
- checkout
|
||||||
|
- testing
|
||||||
|
requires:
|
||||||
|
- checkout
|
||||||
|
- building
|
||||||
|
requires:
|
||||||
|
- testing
|
||||||
|
- linting
|
||||||
|
- building
|
||||||
|
requires:
|
||||||
|
- publishing
|
||||||
|
- publishing
|
||||||
|
requires:
|
||||||
|
- building
|
||||||
|
jobs:
|
||||||
|
checkout:
|
||||||
|
executor: go
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- persist_to_workspace:
|
||||||
|
paths:
|
||||||
|
- .
|
||||||
|
root: ~/repo
|
||||||
|
linting:
|
||||||
|
executor: go
|
||||||
|
steps:
|
||||||
|
- attach_workspace:
|
||||||
|
at: .
|
||||||
|
- run: go build .
|
||||||
|
- run: go get -u golang.org/x/lint/golint
|
||||||
|
- run: golint ./...
|
||||||
|
testing:
|
||||||
|
executor: go
|
||||||
|
steps:
|
||||||
|
- attach_workspace:
|
||||||
|
at: .
|
||||||
|
- run: go build ./...
|
||||||
|
- run: go test ./...
|
||||||
|
|
||||||
|
# version: 2
|
||||||
|
# jobs:
|
||||||
|
# build:
|
||||||
|
# docker:
|
||||||
|
# - image: v2tec/gobuilder:0.5.0_go1.7.4-glide0.12.3-goreleaser0.59.0-docker17.05.0
|
||||||
|
# working_directory: /src
|
||||||
|
# steps:
|
||||||
|
# - checkout
|
||||||
|
# - setup_remote_docker:
|
||||||
|
# version: 17.05.0-ce
|
||||||
|
# - run: git fetch --tags
|
||||||
|
# - run: |
|
||||||
|
# docker login -u $DOCKER_USER -p $DOCKER_PASS
|
||||||
|
# IS_RELEASE=$(if [ "$CIRCLE_TAG" != "" ] ; then echo release; else echo ci; fi;)
|
||||||
|
# /build.sh $IS_RELEASE || exit 1
|
||||||
|
# chmod 755 /src/dockerfile/push_containers.sh
|
||||||
|
# if [ "$CIRCLE_TAG" != "" ] ; then /src/dockerfile/push_containers.sh $CIRCLE_TAG; fi;
|
||||||
|
|
||||||
|
# - store_artifacts:
|
||||||
|
# path: /src/dist/
|
||||||
|
# workflows:
|
||||||
|
# version: 2
|
||||||
|
# build-deploy:
|
||||||
|
# jobs:
|
||||||
|
# - build:
|
||||||
|
# filters:
|
||||||
|
# tags:
|
||||||
|
# only: /.*/
|
||||||
28
circle.yml
28
circle.yml
|
|
@ -1,28 +0,0 @@
|
||||||
version: 2
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
docker:
|
|
||||||
- image: v2tec/gobuilder:0.5.0_go1.7.4-glide0.12.3-goreleaser0.59.0-docker17.05.0
|
|
||||||
working_directory: /src
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- setup_remote_docker:
|
|
||||||
version: 17.05.0-ce
|
|
||||||
- run: git fetch --tags
|
|
||||||
- run: |
|
|
||||||
docker login -u $DOCKER_USER -p $DOCKER_PASS
|
|
||||||
IS_RELEASE=$(if [ "$CIRCLE_TAG" != "" ] ; then echo release; else echo ci; fi;)
|
|
||||||
/build.sh $IS_RELEASE || exit 1
|
|
||||||
chmod 755 /src/dockerfile/push_containers.sh
|
|
||||||
if [ "$CIRCLE_TAG" != "" ] ; then /src/dockerfile/push_containers.sh $CIRCLE_TAG; fi;
|
|
||||||
|
|
||||||
- store_artifacts:
|
|
||||||
path: /src/dist/
|
|
||||||
workflows:
|
|
||||||
version: 2
|
|
||||||
build-deploy:
|
|
||||||
jobs:
|
|
||||||
- build:
|
|
||||||
filters:
|
|
||||||
tags:
|
|
||||||
only: /.*/
|
|
||||||
54
dockerfile/build/Dockerfile
Normal file
54
dockerfile/build/Dockerfile
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
FROM golang:1.7.4
|
||||||
|
MAINTAINER Fabrizio Steiner <stffabi@users.noreply.github.com>
|
||||||
|
|
||||||
|
ARG BUILD_DATE
|
||||||
|
ARG VCS_REF
|
||||||
|
ARG VERSION
|
||||||
|
|
||||||
|
LABEL org.label-schema.build-date=$BUILD_DATE \
|
||||||
|
org.label-schema.vcs-ref=$VCS_REF \
|
||||||
|
org.label-schema.vcs-url="https://github.com/stffabi/docker-gobuilder" \
|
||||||
|
org.label-schema.version="$VERSION" \
|
||||||
|
org.label-schema.schema-version="1.0"
|
||||||
|
|
||||||
|
ARG glide=0.12.3
|
||||||
|
ARG goreleaser=0.59.0
|
||||||
|
ARG docker=17.05.0-ce
|
||||||
|
|
||||||
|
# Install glide binary
|
||||||
|
RUN curl --silent --show-error --fail --location \
|
||||||
|
--header "Accept: application/tar+gzip, application/x-gzip, application/octet-stream" -o - \
|
||||||
|
"https://github.com/Masterminds/glide/releases/download/v${glide}/glide-v${glide}-linux-amd64.tar.gz" \
|
||||||
|
| tar --no-same-owner -xz linux-amd64/glide -O > /usr/bin/glide \
|
||||||
|
&& chmod 0755 /usr/bin/glide \
|
||||||
|
&& /usr/bin/glide -v
|
||||||
|
|
||||||
|
# Install goreleaser binary
|
||||||
|
RUN curl --silent --show-error --fail --location \
|
||||||
|
--header "Accept: application/tar+gzip, application/x-gzip, application/octet-stream" -o - \
|
||||||
|
"https://github.com/goreleaser/goreleaser/releases/download/v${goreleaser}/goreleaser_Linux_x86_64.tar.gz" \
|
||||||
|
| tar --no-same-owner -C /usr/bin/ -xz goreleaser \
|
||||||
|
&& chmod 0755 /usr/bin/goreleaser \
|
||||||
|
&& /usr/bin/goreleaser -v
|
||||||
|
|
||||||
|
# Install docker binary
|
||||||
|
RUN mkdir -p /tmp \
|
||||||
|
&& curl --silent --show-error --fail --location \
|
||||||
|
--header "Accept: application/tar+gzip, application/x-gzip, application/octet-stream" -o - \
|
||||||
|
"https://get.docker.com/builds/Linux/x86_64/docker-${docker}.tgz" \
|
||||||
|
| tar -xz -C /tmp \
|
||||||
|
&& mv /tmp/docker/* /usr/bin \
|
||||||
|
&& rm -rf /tmp \
|
||||||
|
&& chmod 0755 /usr/bin/docker \
|
||||||
|
&& chmod 0755 /usr/bin/docker* \
|
||||||
|
&& /usr/bin/docker -v
|
||||||
|
|
||||||
|
VOLUME /src
|
||||||
|
WORKDIR /src
|
||||||
|
|
||||||
|
COPY build_environment.sh /
|
||||||
|
COPY build.sh /
|
||||||
|
|
||||||
|
RUN chmod 0755 /*.sh
|
||||||
|
|
||||||
|
ENTRYPOINT ["/build.sh"]
|
||||||
28
dockerfile/build/build.sh
Normal file
28
dockerfile/build/build.sh
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
#!/bin/bash -e
|
||||||
|
|
||||||
|
if [ -z "$1" ]
|
||||||
|
then
|
||||||
|
echo "No argument supplied, please either supply 'release' for a release build or 'ci' for ci build."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
source /build_environment.sh
|
||||||
|
|
||||||
|
# Grab the last segment from the package name
|
||||||
|
name=${pkgName##*/}
|
||||||
|
|
||||||
|
echo "Running Tests $pkgName..."
|
||||||
|
(
|
||||||
|
go test -v $(glide novendor) || exit 1
|
||||||
|
)
|
||||||
|
|
||||||
|
if [ "$1" == "release" ]
|
||||||
|
then
|
||||||
|
echo "Release Building $pkgName..."
|
||||||
|
CGO_ENABLED=${CGO_ENABLED:-0} \
|
||||||
|
goreleaser
|
||||||
|
else
|
||||||
|
echo "Snapshot Building $pkgName..."
|
||||||
|
CGO_ENABLED=${CGO_ENABLED:-0} \
|
||||||
|
goreleaser --snapshot --skip-publish
|
||||||
|
fi
|
||||||
40
dockerfile/build/build_environment.sh
Normal file
40
dockerfile/build/build_environment.sh
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
files=$(ls -1 /src | wc -l)
|
||||||
|
if [ "$files" == "0" ];
|
||||||
|
then
|
||||||
|
echo "Error: Must mount Go source code into /src directory"
|
||||||
|
exit 990
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Grab Go package name
|
||||||
|
pkgName="$(go list -e -f '{{.ImportComment}}' 2>/dev/null || true)"
|
||||||
|
|
||||||
|
if [ -z "$pkgName" ];
|
||||||
|
then
|
||||||
|
echo "Error: Must add canonical import path to root package"
|
||||||
|
exit 992
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Grab just first path listed in GOPATH
|
||||||
|
goPath="${GOPATH%%:*}"
|
||||||
|
|
||||||
|
# Construct Go package path
|
||||||
|
pkgPath="$goPath/src/$pkgName"
|
||||||
|
|
||||||
|
# Set-up src directory tree in GOPATH
|
||||||
|
mkdir -p "$(dirname "$pkgPath")"
|
||||||
|
|
||||||
|
# Link source dir into GOPATH
|
||||||
|
ln -sf /src "$pkgPath"
|
||||||
|
cd "$pkgPath"
|
||||||
|
|
||||||
|
echo "Restoring dependencies..."
|
||||||
|
if [ -e glide.yaml ];
|
||||||
|
then
|
||||||
|
# Install dependencies with glide...
|
||||||
|
glide install
|
||||||
|
else
|
||||||
|
# Get all package dependencies
|
||||||
|
go get -t -d -v ./...
|
||||||
|
fi
|
||||||
|
|
@ -1,39 +1,15 @@
|
||||||
# Build customization
|
|
||||||
build:
|
build:
|
||||||
# Path to main.go file.
|
|
||||||
# Default is `main.go`
|
|
||||||
main: ./main.go
|
main: ./main.go
|
||||||
|
|
||||||
# GOOS list to build in.
|
|
||||||
# For more info refer to https://golang.org/doc/install/source#environment
|
|
||||||
# Defaults are darwin and linux
|
|
||||||
goos:
|
goos:
|
||||||
- linux
|
- linux
|
||||||
- windows
|
- windows
|
||||||
|
|
||||||
# GOARCH to build in.
|
|
||||||
# For more info refer to https://golang.org/doc/install/source#environment
|
|
||||||
# Defaults are 386 and amd64
|
|
||||||
goarch:
|
goarch:
|
||||||
- amd64
|
- amd64
|
||||||
- arm
|
- arm
|
||||||
- arm64
|
- arm64
|
||||||
|
|
||||||
# Archive customization
|
|
||||||
archive:
|
archive:
|
||||||
# You can change the name of the archive.
|
|
||||||
# This is parsed with Golang template engine and the following variables.
|
|
||||||
name_template: "{{.ProjectName}}_{{.Os}}_{{.Arch}}"
|
name_template: "{{.ProjectName}}_{{.Os}}_{{.Arch}}"
|
||||||
|
|
||||||
# Archive format. Valid options are `tar.gz` and `zip`.
|
|
||||||
# Default is `zip`
|
|
||||||
format: tar.gz
|
format: tar.gz
|
||||||
|
|
||||||
# Replacements for GOOS and GOARCH on the archive name.
|
|
||||||
# The keys should be valid GOOS or GOARCH values followed by your custom
|
|
||||||
# replacements.
|
|
||||||
# By default, `replacements` replace GOOS and GOARCH values with valid outputs
|
|
||||||
# of `uname -s` and `uname -m` respectively.
|
|
||||||
replacements:
|
replacements:
|
||||||
arm: armhf
|
arm: armhf
|
||||||
arm64: arm64v8
|
arm64: arm64v8
|
||||||
|
|
@ -41,17 +17,11 @@ archive:
|
||||||
386: 386
|
386: 386
|
||||||
darwin: macOS
|
darwin: macOS
|
||||||
linux: linux
|
linux: linux
|
||||||
|
|
||||||
format_overrides:
|
format_overrides:
|
||||||
- goos: windows
|
- goos: windows
|
||||||
format: zip
|
format: zip
|
||||||
|
|
||||||
# Additional files you want to add to the archive.
|
|
||||||
# Defaults are any files matching `LICENCE*`, `LICENSE*`,
|
|
||||||
# `README*` and `CHANGELOG*` (case-insensitive)
|
|
||||||
files:
|
files:
|
||||||
- LICENSE.md
|
- LICENSE.md
|
||||||
|
|
||||||
dockers:
|
dockers:
|
||||||
-
|
-
|
||||||
goos: linux
|
goos: linux
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue