mirror of
https://github.com/itzg/mc-router.git
synced 2024-11-21 11:25:41 +01:00
Setup CircleCI and goreleaser
This commit is contained in:
parent
17a4bd6515
commit
fccf5f9eef
50
.circleci/config.yml
Normal file
50
.circleci/config.yml
Normal file
@ -0,0 +1,50 @@
|
||||
# Golang CircleCI 2.0 configuration file
|
||||
#
|
||||
# Check https://circleci.com/docs/2.0/language-go/ for more details
|
||||
version: 2
|
||||
|
||||
defaults: &defaults
|
||||
docker:
|
||||
# specify the version
|
||||
- image: circleci/golang:1.10
|
||||
|
||||
# Specify service dependencies here if necessary
|
||||
# CircleCI maintains a library of pre-built images
|
||||
# documented at https://circleci.com/docs/2.0/circleci-images/
|
||||
# - image: circleci/postgres:9.4
|
||||
|
||||
working_directory: /go/src/github.com/itzg/mc-router
|
||||
|
||||
|
||||
jobs:
|
||||
build:
|
||||
<<: *defaults
|
||||
steps:
|
||||
- checkout
|
||||
|
||||
- run: make install-dep
|
||||
- run: make test
|
||||
|
||||
release:
|
||||
<<: *defaults
|
||||
steps:
|
||||
- checkout
|
||||
|
||||
- run: make install-dep
|
||||
- run: docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
|
||||
- run: make release
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
incremental:
|
||||
jobs:
|
||||
- build:
|
||||
filters:
|
||||
tags:
|
||||
ignore: /.*/
|
||||
tagged:
|
||||
jobs:
|
||||
- release:
|
||||
filters:
|
||||
tags:
|
||||
only: /.*/
|
43
.goreleaser.yml
Normal file
43
.goreleaser.yml
Normal file
@ -0,0 +1,43 @@
|
||||
project_name: mc-router
|
||||
release:
|
||||
github:
|
||||
owner: itzg
|
||||
name: mc-router
|
||||
brew:
|
||||
install: bin.install "mc-router"
|
||||
builds:
|
||||
- goos:
|
||||
- linux
|
||||
- darwin
|
||||
- windows
|
||||
goarch:
|
||||
- amd64
|
||||
- "386"
|
||||
goarm:
|
||||
- "6"
|
||||
main: cmd/mc-router/main.go
|
||||
binary: mc-router
|
||||
env:
|
||||
- CGO_ENABLED=0
|
||||
archive:
|
||||
format: tar.gz
|
||||
name_template: '{{ .Binary }}_{{.Version}}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{
|
||||
.Arm }}{{ end }}'
|
||||
files:
|
||||
- licence*
|
||||
- LICENCE*
|
||||
- license*
|
||||
- LICENSE*
|
||||
- readme*
|
||||
- README*
|
||||
- changelog*
|
||||
- CHANGELOG*
|
||||
snapshot:
|
||||
name_template: SNAPSHOT-{{ .Commit }}
|
||||
dockers:
|
||||
- goos: linux
|
||||
goarch: amd64
|
||||
image: itzg/mc-router
|
||||
tag_templates:
|
||||
- "{{.Tag}}"
|
||||
- latest
|
3
Dockerfile
Normal file
3
Dockerfile
Normal file
@ -0,0 +1,3 @@
|
||||
FROM scratch
|
||||
COPY mc-router /
|
||||
ENTRYPOINT ["/mc-router"]
|
13
Makefile
Normal file
13
Makefile
Normal file
@ -0,0 +1,13 @@
|
||||
test: vendor
|
||||
go test ./...
|
||||
|
||||
vendor:
|
||||
dep ensure -vendor-only
|
||||
|
||||
.PHONY: release
|
||||
release: vendor
|
||||
curl -sL https://git.io/goreleaser | bash
|
||||
|
||||
.PHONY: install-dep
|
||||
install-dep:
|
||||
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
|
@ -9,6 +9,7 @@ import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -18,11 +19,28 @@ var (
|
||||
String()
|
||||
mappings = kingpin.Flag("mapping", "Mapping of external hostname to internal server host:port").
|
||||
StringMap()
|
||||
versionFlag = kingpin.Flag("version", "Output version and exit").
|
||||
Bool()
|
||||
)
|
||||
|
||||
var (
|
||||
version = "dev"
|
||||
commit = "none"
|
||||
date = "unknown"
|
||||
)
|
||||
|
||||
func showVersion() {
|
||||
fmt.Printf("%v, commit %v, built at %v", version, commit, date)
|
||||
}
|
||||
|
||||
func main() {
|
||||
kingpin.Parse()
|
||||
|
||||
if *versionFlag {
|
||||
showVersion()
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
||||
c := make(chan os.Signal, 1)
|
||||
|
Loading…
Reference in New Issue
Block a user