diff --git a/.circleci/config.yml b/.circleci/config.yml index a0ade82a6..44a7fbfd0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -97,6 +97,45 @@ jobs: make integration-test - go/save-cache + release: + docker: + - image: circleci/golang:1.12.10 + working_directory: /go/src/github.com/dragonflyoss/Dragonfly + steps: + - checkout + - go/load-cache + # TODO(yeya24): consider a better way to inject build date + - run: + name: inject build date + command: echo 'export DATE=$(date "+%Y%m%d-%H:%M:%S")' >> $BASH_ENV + - run: curl -sL https://git.io/goreleaser | bash + - go/save-cache + +# TODO(yeya24): Consider changing to use goreleaser to publish images later + publish-images: + docker: + - image: circleci/golang:1.12.10 + working_directory: /go/src/github.com/dragonflyoss/Dragonfly + steps: + - checkout + - setup_remote_docker + - run: echo 'export DF_VERSION=${CIRCLE_TAG:1}' >> $BASH_ENV + - go/load-cache + - run: make docker-build + - run: + name: push images + command: | + echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin + docker tag dfclient:$DF_VERSION dragonflyoss/dfclient:$DF_VERSION + docker tag supernode:$DF_VERSION dragonflyoss/supernode:$DF_VERSION + docker tag dfclient:$DF_VERSION dragonflyoss/dfclient:latest + docker tag supernode:$DF_VERSION dragonflyoss/supernode:latest + docker push dragonflyoss/dfclient:$DF_VERSION + docker push dragonflyoss/supernode:$DF_VERSION + docker push dragonflyoss/dfclient:latest + docker push dragonflyoss/supernode:latest + - go/save-cache + workflows: version: 2 ci: @@ -104,3 +143,19 @@ workflows: - linters-check - unit-test-golang - api-integration-test + + release: + jobs: + - release: + # Only run this job on git tag pushes + filters: + branches: + ignore: /.*/ + tags: + only: /^v[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)$/ + - publish-images: + filters: + branches: + ignore: /.*/ + tags: + only: /^v[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)$/ diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 000000000..fc8896d69 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,58 @@ +# This is an example goreleaser.yaml file with some sane defaults. +# Make sure to check the documentation at http://goreleaser.com +env: + - GO111MODULE=on + - CGO_ENABLED=0 +before: + hooks: + - go mod tidy +builds: + - binary: supernode + id: "supernode" + main: cmd/supernode/main.go + goarch: + - amd64 + goos: + - linux + - darwin + ldflags: + - -s -w -X github.com/dragonflyoss/Dragonfly/version.version={{.Version}} + - -X github.com/dragonflyoss/Dragonfly/version.revision={{.ShortCommit}} + - -X github.com/dragonflyoss/Dragonfly/version.buildDate={{.Env.DATE}} + + - binary: dfget + id: "dfget" + main: cmd/dfget/main.go + goarch: + - amd64 + goos: + - linux + - darwin + ldflags: + - -s -w -X github.com/dragonflyoss/Dragonfly/version.version={{.Version}} + - -X github.com/dragonflyoss/Dragonfly/version.revision={{.ShortCommit}} + - -X github.com/dragonflyoss/Dragonfly/version.buildDate={{.Env.DATE}} + + - binary: dfdaemon + id: "dfdaemon" + main: cmd/dfdaemon/main.go + goarch: + - amd64 + goos: + - linux + - darwin + ldflags: + - -s -w -X github.com/dragonflyoss/Dragonfly/version.version={{.Version}} + - -X github.com/dragonflyoss/Dragonfly/version.revision={{.ShortCommit}} + - -X github.com/dragonflyoss/Dragonfly/version.buildDate={{.Env.DATE}} + +# archives in the tarball +archives: + - wrap_in_directory: true + # additional files + files: + - LICENSE + - README.md + +checksum: + name_template: 'checksums.txt'