ci: added release (semi)automation
- security: updated Golang version to 1.12.8 for CI builds - added: configuration for build and release automation using GoReleaser (https://goreleaser.com) - (Releases will be semi-automatic for now due to the need of the access token. When/if project specific access token is supported then I'll complete the release stage of the pipeline.) - added: version.go for printing out the versions
This commit is contained in:
parent
18cdd01dc8
commit
0cd7dab556
6 changed files with 80 additions and 21 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
||||||
tags
|
tags
|
||||||
bin/*
|
bin/*
|
||||||
!bin/.gitkeep
|
!bin/.gitkeep
|
||||||
|
dist/
|
||||||
|
|
|
@ -1,25 +1,16 @@
|
||||||
---
|
---
|
||||||
image: golang:1.12.6
|
image: golang:1.12.8
|
||||||
|
|
||||||
|
variables:
|
||||||
|
CGO_ENABLED: 0
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- test
|
- test
|
||||||
- build
|
|
||||||
#- release
|
#- release
|
||||||
|
|
||||||
test:
|
test:unit:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- make test
|
- make test_unit
|
||||||
|
|
||||||
build:
|
#release
|
||||||
stage: build
|
|
||||||
script:
|
|
||||||
- make build
|
|
||||||
artifacts:
|
|
||||||
expire_in: 1 hour
|
|
||||||
name: "pominal-$CI_COMMIT_REF_SLUG"
|
|
||||||
paths:
|
|
||||||
- bin/pominal
|
|
||||||
only:
|
|
||||||
refs:
|
|
||||||
- master
|
|
||||||
|
|
50
.goreleaser.yml
Normal file
50
.goreleaser.yml
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
---
|
||||||
|
project_name: pominal
|
||||||
|
|
||||||
|
before:
|
||||||
|
hooks:
|
||||||
|
- go mod download
|
||||||
|
|
||||||
|
builds:
|
||||||
|
- binary: pominal
|
||||||
|
env:
|
||||||
|
- CGO_ENABLED=0
|
||||||
|
flags:
|
||||||
|
- -a
|
||||||
|
- -v
|
||||||
|
goarch:
|
||||||
|
- 386
|
||||||
|
- amd64
|
||||||
|
goos:
|
||||||
|
- linux
|
||||||
|
id: pominal-build
|
||||||
|
ldflags:
|
||||||
|
- s -w -X main.version={{.Version}} -X main.commit={{.ShortCommit}} -X main.date={{.Date}} -X main.goversion={{.Env.GOVERSION}}
|
||||||
|
|
||||||
|
archives:
|
||||||
|
- files:
|
||||||
|
- LICENSE
|
||||||
|
- README.md
|
||||||
|
format: tar.gz
|
||||||
|
id: pominal-archive
|
||||||
|
name_template: "{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}"
|
||||||
|
replacements:
|
||||||
|
386: i386
|
||||||
|
amd64: x86_64
|
||||||
|
wrap_in_directory: true
|
||||||
|
|
||||||
|
checksum:
|
||||||
|
algorithm: sha256
|
||||||
|
name_template: "{{ .ProjectName }}-{{ .Version }}-CHECKSUMS.txt"
|
||||||
|
|
||||||
|
snapshot:
|
||||||
|
name_template: "SNAPSHOT-{{ .ShortCommit }}"
|
||||||
|
|
||||||
|
changelog:
|
||||||
|
sort: desc
|
||||||
|
filters:
|
||||||
|
exclude:
|
||||||
|
- "^docs:"
|
||||||
|
- "^test:"
|
||||||
|
- "^chore:"
|
||||||
|
- "^ci:"
|
13
Makefile
13
Makefile
|
@ -1,13 +1,16 @@
|
||||||
.PHONY: all test build clean
|
NAME := pominal
|
||||||
|
BIN_DIR := ./bin
|
||||||
|
BIN_FILE := $(BIN_DIR)/$(NAME)
|
||||||
|
|
||||||
all: test build
|
.PHONY: all test_unit build clean
|
||||||
|
|
||||||
test:
|
all: test_unit build
|
||||||
|
|
||||||
|
test_unit:
|
||||||
go test -v -cover ./...
|
go test -v -cover ./...
|
||||||
|
|
||||||
build:
|
build:
|
||||||
go build -a -v -o bin/pominal
|
go build -a -v -o $(BIN_FILE)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
go clean
|
go clean
|
||||||
find bin -type f -not -iname .gitkeep | xargs -I v rm v
|
|
||||||
|
|
14
version.go
Normal file
14
version.go
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
var (
|
||||||
|
commit string
|
||||||
|
date string
|
||||||
|
goversion string
|
||||||
|
version string
|
||||||
|
)
|
||||||
|
|
||||||
|
func Version() {
|
||||||
|
fmt.Printf("Version: %s\nCommit: %s\nGo Version: %s\nDate: %s", version, commit, goversion, date)
|
||||||
|
}
|
Loading…
Reference in a new issue