Skip to content

Commit 050b2da

Browse files
committed
fix: fixes goreleaser config, adds gha
1 parent 0ce4a93 commit 050b2da

File tree

4 files changed

+64
-8
lines changed

4 files changed

+64
-8
lines changed

.github/workflows/release.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# This GitHub action can publish assets for release when a tag is created.
2+
# Currently its setup to run on any tag that matches the pattern "v*" (ie. v0.1.0).
3+
#
4+
# This uses an action (hashicorp/ghaction-import-gpg) that assumes you set your
5+
# private key in the `GPG_PRIVATE_KEY` secret and passphrase in the `PASSPHRASE`
6+
# secret. If you would rather own your own GPG handling, please fork this action
7+
# or use an alternative one for key handling.
8+
#
9+
# You will need to pass the `--batch` flag to `gpg` in your signing step
10+
# in `goreleaser` to indicate this is being used in a non-interactive mode.
11+
#
12+
name: release
13+
on:
14+
push:
15+
tags:
16+
- "v*"
17+
jobs:
18+
goreleaser:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/[email protected]
23+
- name: Unshallow
24+
run: git fetch --prune --unshallow
25+
- name: Set up Go
26+
uses: actions/setup-go@v2
27+
with:
28+
go-version: "1.19"
29+
- name: Import GPG key
30+
id: import_gpg
31+
uses: crazy-max/[email protected]
32+
with:
33+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
34+
passphrase: ${{ secrets.GPG_PASSPHRASE }}
35+
- name: Run GoReleaser
36+
uses: goreleaser/goreleaser-action@v4
37+
with:
38+
version: latest
39+
args: release --rm-dist
40+
env:
41+
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.goreleaser.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
# This is an example .goreleaser.yml file with some sensible defaults.
2-
# Make sure to check the documentation at https://goreleaser.com
31
project_name: protoc-gen-go_temporal
42
before:
53
hooks:
6-
# You may remove this if you don't use go modules.
74
- go mod tidy
85
builds:
96
- id: protoc-gen-go-temporal
@@ -17,6 +14,8 @@ builds:
1714
goarch:
1815
- amd64
1916
- arm64
17+
ldflags:
18+
- "-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}"
2019
archives:
2120
- files:
2221
- LICENSE.md
@@ -36,3 +35,11 @@ release:
3635
name: protoc-gen-go-temporal
3736
signs:
3837
- artifacts: checksum
38+
args:
39+
- "--batch"
40+
- "--local-user"
41+
- "{{ .Env.GPG_FINGERPRINT }}" # set this environment variable for your signing key
42+
- "--output"
43+
- "${signature}"
44+
- "--detach-sign"
45+
- "${artifact}"

cmd/protoc-gen-go-temporal/main.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,24 @@ import (
99
"google.golang.org/protobuf/compiler/protogen"
1010
)
1111

12-
var Version = "dev"
12+
var (
13+
version = "dev"
14+
commit = "latest"
15+
)
1316

1417
func main() {
1518
showVersion := flag.Bool("version", false, "print the version and exit")
1619
flag.Parse()
1720
if *showVersion {
18-
fmt.Printf("protoc-gen-go-temporal: %s\n", Version)
21+
fmt.Printf("protoc-gen-go-temporal: %s\n", version)
1922
fmt.Printf("go: %s\n", runtime.Version())
2023
return
2124
}
2225

23-
p := plugin.Plugin{}
26+
p := plugin.Plugin{
27+
Commit: commit,
28+
Version: version,
29+
}
2430

2531
opts := protogen.Options{
2632
ParamFunc: p.Param,

internal/plugin/plugin.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import (
1111
// Plugin provides a protoc plugin for generating temporal workers and clients in go
1212
type Plugin struct {
1313
*protogen.Plugin
14-
version string
14+
Commit string
15+
Version string
1516
}
1617

1718
// Param provides a protogen ParamFunc handler
@@ -66,7 +67,7 @@ func (p *Plugin) Run(plugin *protogen.Plugin) error {
6667
func genCodeGenerationHeader(p *Plugin, f *g.File, target *protogen.File) {
6768
f.PackageComment("Code generated by protoc-gen-go_temporal. DO NOT EDIT.")
6869
f.PackageComment("versions: ")
69-
f.PackageComment(fmt.Sprintf(" protoc-gen-go_temporal %s", p.version))
70+
f.PackageComment(fmt.Sprintf(" protoc-gen-go_temporal %s (%s)", p.Version, p.Commit))
7071
f.PackageComment(fmt.Sprintf(" go %s", runtime.Version()))
7172
compilerVersion := p.Plugin.Request.CompilerVersion
7273
if compilerVersion != nil {

0 commit comments

Comments
 (0)