Skip to content

Commit 4304e45

Browse files
authored
Fix/releaser (#53)
1 parent 4670e83 commit 4304e45

13 files changed

Lines changed: 70 additions & 28 deletions

File tree

.github/workflows/lint.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,26 @@ jobs:
1212
runs-on: ubuntu-latest
1313

1414
steps:
15+
- name: Create cache directories
16+
run: |
17+
mkdir -p ~/.cache/golangci-lint
18+
mkdir -p ~/.cache/go-build
19+
1520
- uses: actions/checkout@v4
16-
- name: Set up Go
17-
uses: actions/setup-go@v5
21+
- uses: actions/setup-go@v5
1822
with:
19-
go-version: 1.22
23+
go-version-file: 'go.mod'
2024

2125
- name: Go Lint Cache
22-
uses: actions/cache@v3
26+
uses: actions/cache@v4
2327
with:
2428
path: ~/.cache/golangci-lint/
2529
key: go-lint-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
2630
restore-keys: |
2731
go-lint-cache-${{ runner.os }}-
2832
2933
- name: Go Mod Cache
30-
uses: actions/cache@v3
34+
uses: actions/cache@v4
3135
with:
3236
path: |
3337
~/.cache/go-build

.github/workflows/release.yml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,39 @@
11
name: Release
22
on:
3-
create:
4-
tags:
5-
- v*
3+
push:
4+
tags: [ "v*.*.*" ]
5+
66
jobs:
77
release:
88
name: Release on GitHub
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Checkout
1212
uses: actions/checkout@v4
13+
14+
- name: Create cache directories
15+
run: |
16+
mkdir -p ~/.cache/go-build
17+
18+
- name: Go Mod Cache
19+
uses: actions/cache@v4
20+
with:
21+
path: |
22+
~/.cache/go-build
23+
key: go-mod-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
24+
restore-keys: |
25+
go-mod-cache-${{ runner.os }}-
26+
go-mod-cache-
27+
28+
1329
- uses: actions/setup-go@v5
1430
with:
1531
go-version-file: 'go.mod'
32+
1633
- name: Run GoReleaser
1734
uses: goreleaser/goreleaser-action@v5
1835
with:
1936
version: latest
2037
args: release --clean
2138
env:
22-
GITHUB_TOKEN: ${{ secrets.TOKEN }}
39+
GITHUB_TOKEN: ${{ secrets.RELEASER_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ kdata
2424
*.pprof
2525
*.log
2626
proto-vendor
27+
.gitconfig

.goreleaser.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
builds:
2-
- main: ./cmds/protoc-gen-go-errors/main.go
2+
- main: ./cmds/protoc-gen-go-errors2/main.go
33
id: protoc-gen-go-errors
44
binary: protoc-gen-go-errors
55
goos:
@@ -9,7 +9,7 @@ builds:
99
goarch:
1010
- amd64
1111
- arm64
12-
- main: ./cmds/protoc-gen-go-enum/main.go
12+
- main: ./cmds/protoc-gen-go-enum2/main.go
1313
id: protoc-gen-go-enum
1414
binary: protoc-gen-go-enum
1515
goos:

component/cloudevent/client.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ func (c *Client) doConsumeHandler(streamName, consumerName string, jobSubjects m
228228
}).
229229
UnwrapOrThrow(&r)
230230
if r.IsErr() {
231-
return
231+
return r
232232
}
233233

234234
// ignore negative delay
@@ -238,7 +238,7 @@ func (c *Client) doConsumeHandler(streamName, consumerName string, jobSubjects m
238238

239239
r = r.WithErr(msg.NakWithDelay(dur))
240240
if r.IsErr() {
241-
return
241+
return r
242242
}
243243

244244
return r.WithValue(true)
@@ -399,8 +399,8 @@ func (c *Client) doHandler(meta *jetstream.MsgMetadata, msg jetstream.Msg, job *
399399
"args": string(msg.Data()),
400400
})
401401
})
402-
if err.ThrowErr(&gErr) {
403-
return
402+
if err.Throw(&gErr) {
403+
return gErr
404404
}
405405
args = &pb
406406

@@ -411,8 +411,8 @@ func (c *Client) doHandler(meta *jetstream.MsgMetadata, msg jetstream.Msg, job *
411411
"args": args,
412412
})
413413
})
414-
if dst.ThrowErr(&gErr) {
415-
return
414+
if dst.Throw(&gErr) {
415+
return gErr
416416
}
417417

418418
ctx = createCtxWithContext(ctx, msgCtx)

env/env.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ func LoadFiles(files ...string) (r result.Error) {
177177
continue
178178
}
179179

180-
if Set(k, v).ThrowErr(&r) {
180+
if Set(k, v).Throw(&r) {
181181
return r
182182
}
183183

result/api.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ func Errorf(msg string, args ...any) Error {
5959
return newError(errors.WrapCaller(fmt.Errorf(msg, args...), 1))
6060
}
6161

62+
func ProxyOf(err *error) ProxyErr { return ErrProxyOf(err) }
6263
func ErrProxyOf(err *error) ProxyErr {
6364
if err == nil {
6465
panicIfError(errors.Errorf("err param is nil"))

result/error.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,14 @@ func (e Error) Err() error { return e.getErr() }
152152

153153
func (e Error) GetErr() error { return e.getErr() }
154154

155+
func (e Error) Unwrap() (void Void) {
156+
if e.IsErr() {
157+
panicIfError(errors.WrapCaller(e.getErr(), 1))
158+
}
159+
160+
return void
161+
}
162+
155163
func (e Error) Must() {
156164
if e.IsOK() {
157165
return
@@ -160,7 +168,11 @@ func (e Error) Must() {
160168
panicIfError(errors.WrapCaller(e.getErr(), 1))
161169
}
162170

163-
func (e Error) ThrowErr(setter ErrSetter, contexts ...context.Context) bool {
171+
func (e Error) ThrowErr(err *error, contexts ...context.Context) bool {
172+
return catchErr(e, nil, err, contexts...)
173+
}
174+
175+
func (e Error) Throw(setter ErrSetter, contexts ...context.Context) bool {
164176
return catchErr(e, setter, nil, contexts...)
165177
}
166178

result/proxy.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ func (e ProxyErr) GetErr() error {
2424
return lo.FromPtr(e.err)
2525
}
2626

27+
func (e ProxyErr) Err() error {
28+
return lo.FromPtr(e.err)
29+
}
30+
2731
func (e ProxyErr) String() string {
2832
if e.IsOK() {
2933
return "OK"

result/proxy_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
func TestProxy(t *testing.T) {
1010
var gErr error
1111
err := ErrProxyOf(&gErr)
12-
Errorf("test proxy error").Log().ThrowErr(&err)
12+
Errorf("test proxy error").Log().Throw(&err)
1313
assert.NotNil(t, gErr)
1414
assert.NotNil(t, err.GetErr())
1515
assert.Equal(t, gErr, err.GetErr())

0 commit comments

Comments
 (0)