From 6f43f8f37f5c7bc46a36b95b1ffc56a8ab918b26 Mon Sep 17 00:00:00 2001 From: Johan Brandhorst Date: Fri, 21 Dec 2018 12:32:37 +0000 Subject: [PATCH] Replace complicated release procedure with goreleaser --- .circleci/config.yml | 117 ++----------------------------------------- .goreleaser.yml | 27 ++++++++++ Makefile | 26 +++++----- 3 files changed, 44 insertions(+), 126 deletions(-) create mode 100644 .goreleaser.yml diff --git a/.circleci/config.yml b/.circleci/config.yml index 09d050563e0..68dd572a8ca 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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: @@ -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]+)*(-.*)*/ diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 00000000000..28131d84ff0 --- /dev/null +++ b/.goreleaser.yml @@ -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 diff --git a/Makefile b/Makefile index b2d6722d2c7..32ae9e498ee 100644 --- a/Makefile +++ b/Makefile @@ -181,19 +181,19 @@ test: examples go test -race $(PKG)/... go test -race $(PKG)/examples/integration -args -network=unix -endpoint=test.sock changelog: - docker run --rm \ - --interactive \ - --tty \ - -e "CHANGELOG_GITHUB_TOKEN=${CHANGELOG_GITHUB_TOKEN}" \ - -v "$(PWD):/usr/local/src/your-app" \ - ferrarimarco/github-changelog-generator:1.14.3 \ - -u grpc-ecosystem \ - -p grpc-gateway \ - --author \ - --compare-link \ - --github-site=https://grpc-ecosystem.github.io/grpc-gateway \ - --unreleased-label "**Next release**" \ - --future-release=v1.6.0 + docker run --rm \ + --interactive \ + --tty \ + -e "CHANGELOG_GITHUB_TOKEN=${CHANGELOG_GITHUB_TOKEN}" \ + -v "$(PWD):/usr/local/src/your-app" \ + ferrarimarco/github-changelog-generator:1.14.3 \ + -u grpc-ecosystem \ + -p grpc-gateway \ + --author \ + --compare-link \ + --github-site=https://grpc-ecosystem.github.io/grpc-gateway \ + --unreleased-label "**Next release**" \ + --future-release=v1.6.0 lint: golint --set_exit_status $(PKG)/runtime golint --set_exit_status $(PKG)/utilities/...