Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace complicated circle CI release with goreleaser. #828

Merged
merged 2 commits into from
Dec 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 4 additions & 113 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,94 +76,14 @@ jobs:
command: 'bazel run //:buildifier_check ||
(echo "ERROR: Bazel files not formatted, please run \`bazel run :buildifier\`" >&2; exit 1)'
when: always
write_release_version:
docker:
- image: docker:git
working_directory: /src
steps:
- checkout
- run: git describe --tags --abbrev=0 > VERSION
- persist_to_workspace:
root: ./
paths:
- VERSION
build_linux_release:
docker:
- image: jfbrandhorst/grpc-gateway-build-env
working_directory: /go/src/github.com/grpc-ecosystem/grpc-gateway
environment:
CGO_ENABLED: "0"
GOOS: "linux"
GOARCH: "amd64"
steps:
- checkout
- run: mkdir -p release
- run: dep ensure --vendor-only
- run: |
VERSION=$(git describe --tags --abbrev=0)
go build -o ./release/protoc-gen-grpc-gateway-${VERSION}-linux-x86_64 ./protoc-gen-grpc-gateway/
- run: |
VERSION=$(git describe --tags --abbrev=0)
go build -o ./release/protoc-gen-swagger-${VERSION}-linux-x86_64 ./protoc-gen-swagger/
- persist_to_workspace:
root: ./
paths:
- release
build_darwin_release:
docker:
- image: jfbrandhorst/grpc-gateway-build-env
working_directory: /go/src/github.com/grpc-ecosystem/grpc-gateway
environment:
CGO_ENABLED: "0"
GOOS: "darwin"
GOARCH: "amd64"
steps:
- checkout
- run: mkdir -p release
- run: dep ensure --vendor-only
- run: |
VERSION=$(git describe --tags --abbrev=0)
go build -o ./release/protoc-gen-grpc-gateway-${VERSION}-darwin-x86_64 ./protoc-gen-grpc-gateway/
- run: |
VERSION=$(git describe --tags --abbrev=0)
go build -o ./release/protoc-gen-swagger-${VERSION}-darwin-x86_64 ./protoc-gen-swagger/
- persist_to_workspace:
root: ./
paths:
- release
build_windows_release:
release:
docker:
- image: jfbrandhorst/grpc-gateway-build-env
working_directory: /go/src/github.com/grpc-ecosystem/grpc-gateway
environment:
CGO_ENABLED: "0"
GOOS: "windows"
GOARCH: "amd64"
steps:
- checkout
- run: mkdir -p release
- run: dep ensure --vendor-only
- run: |
VERSION=$(git describe --tags --abbrev=0)
go build -o ./release/protoc-gen-grpc-gateway-${VERSION}-windows-x86_64.exe ./protoc-gen-grpc-gateway/
- run: |
VERSION=$(git describe --tags --abbrev=0)
go build -o ./release/protoc-gen-swagger-${VERSION}-windows-x86_64.exe ./protoc-gen-swagger/
- persist_to_workspace:
root: ./
paths:
- release
publish_github_release:
docker:
- image: cibuilds/github:0.10
steps:
- attach_workspace:
at: /workspace
- run:
name: "Publish Release on GitHub"
command: |
VERSION=$(cat /workspace/VERSION)
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${VERSION} /workspace/release/
- run: curl -sL https://git.io/goreleaser | bash
workflows:
version: 2
all:
Expand All @@ -174,38 +94,9 @@ workflows:
- generate
- lint
- bazel
- write_release_version:
filters:
branches:
ignore: /.*/
tags:
only: /^v\d+\.\d+\.\d+$/
- build_linux_release:
filters:
branches:
ignore: /.*/
tags:
only: /^v\d+\.\d+\.\d+$/
- build_windows_release:
filters:
branches:
ignore: /.*/
tags:
only: /^v\d+\.\d+\.\d+$/
- build_darwin_release:
- release:
filters:
branches:
ignore: /.*/
tags:
only: /^v\d+\.\d+\.\d+$/
# - publish_github_release:
# requires:
# - write_release_version
# - build_linux_release
# - build_darwin_release
# - build_windows_release
# filters:
# branches:
# ignore: /.*/
# tags:
# only: /^v\d+\.\d+\.\d+$/
only: /v[0-9]+(\.[0-9]+)*(-.*)*/
27 changes: 27 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
builds:
- main: ./protoc-gen-grpc-gateway/main.go
binary: protoc-gen-grpc-gateway
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
- windows
goarch:
- amd64
- main: ./protoc-gen-swagger/main.go
binary: protoc-gen-swagger
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
- windows
goarch:
- amd64
archive:
name_template: "{{ .Binary }}-{{ .Tag }}-{{ .Os }}-{{ .Arch }}"
format: binary
replacements:
amd64: x86_64
dist: _output
14 changes: 14 additions & 0 deletions protoc-gen-grpc-gateway/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ package main

import (
"flag"
"fmt"
"os"
"strings"

Expand All @@ -31,12 +32,25 @@ var (
pathType = flag.String("paths", "", "specifies how the paths of generated files are structured")
allowRepeatedFieldsInBody = flag.Bool("allow_repeated_fields_in_body", false, "allows to use repeated field in `body` and `response_body` field of `google.api.http` annotation option")
repeatedPathParamSeparator = flag.String("repeated_path_param_separator", "csv", "configures how repeated fields should be split. Allowed values are `csv`, `pipes`, `ssv` and `tsv`.")
versionFlag = flag.Bool("version", false, "print the current verison")
)

// Variables set by goreleaser at build time
var (
version = "dev"
commit = "unknown"
date = "unknown"
)

func main() {
flag.Parse()
defer glog.Flush()

if *versionFlag {
fmt.Printf("Version %v, commit %v, built at %v\n", version, commit, date)
os.Exit(0)
}

reg := descriptor.NewRegistry()

glog.V(1).Info("Parsing code generator request")
Expand Down
13 changes: 13 additions & 0 deletions protoc-gen-swagger/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,25 @@ var (
mergeFileName = flag.String("merge_file_name", "apidocs", "target swagger file name prefix after merge")
useJSONNamesForFields = flag.Bool("json_names_for_fields", false, "if it sets Field.GetJsonName() will be used for generating swagger definitions, otherwise Field.GetName() will be used")
repeatedPathParamSeparator = flag.String("repeated_path_param_separator", "csv", "configures how repeated fields should be split. Allowed values are `csv`, `pipes`, `ssv` and `tsv`.")
versionFlag = flag.Bool("version", false, "print the current verison")
)

// Variables set by goreleaser at build time
var (
version = "dev"
commit = "unknown"
date = "unknown"
)

func main() {
flag.Parse()
defer glog.Flush()

if *versionFlag {
fmt.Printf("Version %v, commit %v, built at %v\n", version, commit, date)
os.Exit(0)
}

reg := descriptor.NewRegistry()

glog.V(1).Info("Processing code generator request")
Expand Down