Skip to content

Commit d9b4b1d

Browse files
authored
Create release binary for protoc-gen-connect-go (#966)
This adds release artifacts and updates the RELEASE.md to validate. Builds `protoc-gen-connect-go-vX.Y.Z-{Darwin,Linux,Windows}-{x86_64,arm64/aarch64}` archives, each containing the binary, LICENSE and checksum. Closes #695 Signed-off-by: Edward McFarlane <emcfarlane@buf.build>
1 parent 5111260 commit d9b4b1d

6 files changed

Lines changed: 117 additions & 2 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ jobs:
4040
# supported version.
4141
if: matrix.go-version.name == 'latest'
4242
run: make checkgenerate && make lint
43+
- name: Check Release
44+
# Verifies that the release build works, so breakage surfaces here
45+
# rather than when a release is being cut. Releases are built with the
46+
# most recent supported version, so that's all we need to check.
47+
if: matrix.go-version.name == 'latest'
48+
run: make checkrelease
4349
conformance:
4450
name: conformance (go:${{ matrix.go-version.name }})
4551
runs-on: ubuntu-latest

.github/workflows/release.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: release
2+
on:
3+
release:
4+
types: [published]
5+
permissions:
6+
contents: write
7+
jobs:
8+
release:
9+
runs-on: ubuntu-latest
10+
# Release events fire for every tag, limit to target vX.Y.Z.
11+
if: ${{ startsWith(github.event.release.tag_name, 'v') }}
12+
steps:
13+
- name: Checkout Code
14+
uses: actions/checkout@v7
15+
with:
16+
fetch-depth: 1
17+
- name: Install Go
18+
uses: actions/setup-go@v7
19+
with:
20+
go-version: 1.27.x
21+
check-latest: true
22+
- name: Release
23+
env:
24+
GITHUB_TOKEN: ${{ github.TOKEN }}
25+
run: make release

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/.tmp/
2+
/dist/
23
*.pprof
34
*.svg
45
.idea

.goreleaser.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
2+
version: 2
3+
project_name: protoc-gen-connect-go
4+
5+
before:
6+
hooks:
7+
# connect.go's Version constant is edited by hand (RELEASE.md step 2) and is
8+
# what the plugin reports via --version, while the archive names below come
9+
# from the git tag. Nothing else checks that the two agree, so a missed edit
10+
# would silently ship mislabelled binaries. Skipped for snapshot builds,
11+
# where there is no release tag to compare against.
12+
- sh -c 'if [ "{{ .IsSnapshot }}" != "true" ]; then version="v$(go run ./cmd/protoc-gen-connect-go --version)"; if [ "$version" != "{{ .Tag }}" ]; then echo "connect.Version is $version, but the release tag is {{ .Tag }}" >&2; exit 1; fi; fi'
13+
14+
builds:
15+
- id: protoc-gen-connect-go
16+
binary: protoc-gen-connect-go
17+
main: ./cmd/protoc-gen-connect-go
18+
env:
19+
- CGO_ENABLED=0
20+
goos:
21+
- linux
22+
- darwin
23+
- windows
24+
goarch:
25+
- amd64
26+
- arm64
27+
ldflags:
28+
# Omit the symbol table and DWARF data, this is not a debuggable artifact.
29+
- -s -w
30+
31+
archives:
32+
- formats: [tar.gz]
33+
format_overrides:
34+
- goos: windows
35+
formats: [zip]
36+
# Matches the naming used by bufbuild/buf and connectconformance releases.
37+
name_template: >-
38+
protoc-gen-connect-go-
39+
{{- .Tag }}-
40+
{{- title .Os }}-
41+
{{- if and (eq .Os "linux") (eq .Arch "arm64") }}aarch64
42+
{{- else if eq .Arch "amd64" }}x86_64
43+
{{- else }}{{ .Arch }}{{ end }}
44+
files:
45+
- LICENSE
46+
47+
checksum:
48+
# The default template uses .Version, which renders without the leading "v"
49+
# that the archives above use. Pin it so the whole release is consistent.
50+
name_template: 'protoc-gen-connect-go-{{ .Tag }}-checksums.txt'
51+
52+
changelog:
53+
# Release notes are written by hand in the GitHub UI, so there is nothing to
54+
# generate here. Skipping it also avoids walking history that the release
55+
# workflow's shallow checkout doesn't have.
56+
disable: true
57+
58+
release:
59+
github:
60+
owner: connectrpc
61+
name: connect-go
62+
# Releases are created and their notes curated by hand in the GitHub UI, as
63+
# described in RELEASE.md. This only attaches artifacts to the existing
64+
# release.
65+
mode: keep-existing

Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ COPYRIGHT_YEARS := 2021-2026
1313
LICENSE_IGNORE := --ignore .github/ --ignore ".*\.ya?ml"
1414
BUF_VERSION := 1.69.0
1515
GOLANGCI_LINT_VERSION ?= v2.13.1
16+
GORELEASER_VERSION ?= v2.18.0
1617

1718
.PHONY: help
1819
help: ## Describe useful make targets
@@ -98,6 +99,16 @@ checkgenerate:
9899
@# Used in CI to verify that `make generate` doesn't produce a diff.
99100
test -z "$$(git status --porcelain | tee /dev/stderr)"
100101

102+
.PHONY: release
103+
release: $(BIN)/goreleaser ## Build release artifacts and attach them to the release
104+
goreleaser release
105+
106+
.PHONY: checkrelease
107+
checkrelease: $(BIN)/goreleaser
108+
@# Used in CI to verify that the release build works. Skips validation and
109+
@# doesn't publish anything.
110+
goreleaser release --clean --snapshot
111+
101112
.PHONY: $(BIN)/protoc-gen-connect-go
102113
$(BIN)/protoc-gen-connect-go:
103114
@mkdir -p $(@D)
@@ -115,6 +126,10 @@ $(BIN)/golangci-lint: Makefile
115126
@mkdir -p $(@D)
116127
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
117128

129+
$(BIN)/goreleaser: Makefile
130+
@mkdir -p $(@D)
131+
go install github.com/goreleaser/goreleaser/v2@$(GORELEASER_VERSION)
132+
118133
$(BIN)/protoc-gen-go: Makefile go.mod
119134
@mkdir -p $(@D)
120135
@# The version of protoc-gen-go is determined by the version in go.mod

RELEASE.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,16 @@ This document outlines how to create a release of connect-go.
3232

3333
7. Publish the release.
3434

35-
8. On a new branch, open [connect.go](connect.go) and change the `Version` to increment the minor tag and append the `-dev` suffix. Use the next minor release - we never anticipate bugs and patch releases.
35+
8. Check the [release workflow] triggered by publishing. It attaches the `protoc-gen-connect-go` binaries and a checksums file to the release. It fails if the `Version` constant doesn't match the tag: correct the constant, then delete the release and its tag and repeat step 6.
36+
37+
9. On a new branch, open [connect.go](connect.go) and change the `Version` to increment the minor tag and append the `-dev` suffix. Use the next minor release - we never anticipate bugs and patch releases.
3638

3739
```patch
3840
-const Version = "1.14.0"
3941
+const Version = "1.15.0-dev"
4042
```
4143

42-
9. Open a PR titled "Back to development" ([Example PR #662](https://github.com/connectrpc/connect-go/pull/662)). Once it's reviewed and CI passes, merge it.
44+
10. Open a PR titled "Back to development" ([Example PR #662](https://github.com/connectrpc/connect-go/pull/662)). Once it's reviewed and CI passes, merge it.
4345

4446
[latest release]: https://github.com/connectrpc/connect-go/releases/latest
47+
[release workflow]: https://github.com/connectrpc/connect-go/actions/workflows/release.yaml

0 commit comments

Comments
 (0)