ovpn-certman/.gitlab-ci.yml

91 lines
2.6 KiB
YAML
Raw Normal View History

2018-01-26 08:43:53 +01:00
image: golang:latest
variables:
REPO_NAME: git.klink.asia/paul/certman
# The problem is that to be able to use go get, one needs to put
# the repository in the $GOPATH. So for example if your gitlab domain
# is gitlab.com, and that your repository is namespace/project, and
# the default GOPATH being /go, then you'd need to have your
# repository in /go/src/gitlab.com/namespace/project
# Thus, making a symbolic link corrects this.
before_script:
- mkdir -p $GOPATH/src/$REPO_NAME
- ln -svf $CI_PROJECT_DIR/* $GOPATH/src/$REPO_NAME
- cd $GOPATH/src/$REPO_NAME
stages:
2018-02-03 18:14:47 +01:00
- test
- build
- release
2018-01-26 08:43:53 +01:00
format:
2018-02-03 18:14:47 +01:00
stage: test
tags:
- docker
script:
# we use tags="dev" so there is no dependency on the prebuilt assets yet
- go get -tags="dev" -v $(go list ./... | grep -v /vendor/) # get missing dependencies
- go fmt $(go list ./... | grep -v /vendor/)
2018-04-22 20:47:23 +02:00
- go vet -tags="dev" $(go list ./... | grep -v /vendor/)
2018-02-03 18:14:47 +01:00
- go test -tags="dev" -race $(go list ./... | grep -v /vendor/) -v -coverprofile .testCoverage.txt
# Use coverage parsing regex: ^coverage:\s(\d+(?:\.\d+)?%)
2018-01-26 08:43:53 +01:00
compile:
2018-02-03 18:14:47 +01:00
stage: build
tags:
- docker
script:
# we use tags="dev" so there is no dependency on the prebuilt assets yet
- go get -tags="dev" -v $(go list ./... | grep -v /vendor/) # get missing dependencies
2018-01-26 08:43:53 +01:00
2018-02-03 18:14:47 +01:00
# generate assets
- go get github.com/shurcooL/vfsgen/cmd/vfsgendev
- go generate git.klink.asia/paul/certman/assets
2018-01-26 08:43:53 +01:00
2018-02-03 18:14:47 +01:00
# build binaries -- list of supported plattforms is here:
# https://stackoverflow.com/a/20728862
- GOOS=linux GOARCH=amd64 go build -tags "netgo" -o $CI_PROJECT_DIR/certman
- GOOS=linux GOARCH=arm GOARM=6 go build -tags "netgo" -o $CI_PROJECT_DIR/certman.arm
- GOOS=windows GOARCH=amd64 go build -tags "netgo" -o $CI_PROJECT_DIR/certman.exe
artifacts:
expire_in: "8 hrs"
paths:
- certman
- certman.arm
- certman.exe
2018-01-26 08:43:53 +01:00
minify:
2018-02-03 18:14:47 +01:00
stage: release
tags:
- docker
dependencies:
- compile
image:
name: znly/upx:latest
entrypoint: ["/bin/sh", "-c"]
script:
- upx --best --brute $CI_PROJECT_DIR/certman $CI_PROJECT_DIR/certman.arm $CI_PROJECT_DIR/certman.exe
artifacts:
paths:
- certman
- certman.arm
- certman.exe
only:
- tags
build_image:
stage: release
tags:
- dind
image: "docker:latest"
2018-02-03 18:34:56 +01:00
services:
- docker:dind
script:
- cd $CI_PROJECT_DIR
2018-02-03 18:14:47 +01:00
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker build -t $CI_REGISTRY_IMAGE:${CI_COMMIT_REF_NAME#v} .
- docker push $CI_REGISTRY_IMAGE:${CI_COMMIT_REF_NAME#v}
2018-02-03 18:34:56 +01:00
# only:
2018-04-22 20:47:23 +02:00
# - tags