Skip to content

Commit 183d766

Browse files
committed
Add release workflow
1 parent 2abf0b0 commit 183d766

File tree

9 files changed

+131
-78
lines changed

9 files changed

+131
-78
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
mode:
18-
- cgo
19-
- wazero
2017
os:
2118
- macos-12
2219
- ubuntu-22.04
@@ -26,9 +23,9 @@ jobs:
2623
with:
2724
fetch-depth: 0
2825

29-
- uses: actions/setup-go@v4
26+
- uses: actions/setup-go@v5
3027
with:
31-
go-version: '^1.21'
28+
go-version-file: go.work
3229

3330
- name: run checks
3431
run: go run mage check

.github/workflows/release.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: "Release"
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
8+
jobs:
9+
build:
10+
name: Release
11+
runs-on: ubuntu-22.04
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
17+
- uses: actions/setup-go@v5
18+
with:
19+
go-version-file: go.work
20+
21+
- run: go run mage release
22+
env:
23+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.idea
22
.vscode
3-
build
3+
build
4+
dist

.goreleaser.yaml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
builds:
2+
- main: ./cmd/protoc-gen-grpc_cpp
3+
id: cpp
4+
binary: protoc-gen-grpc_cpp
5+
env:
6+
- CGO_ENABLED=0
7+
targets:
8+
- linux_amd64
9+
- linux_arm64
10+
- darwin_amd64
11+
- darwin_arm64
12+
- windows_amd64
13+
- main: ./cmd/protoc-gen-grpc_csharp
14+
id: csharp
15+
binary: protoc-gen-grpc_csharp
16+
env:
17+
- CGO_ENABLED=0
18+
targets:
19+
- linux_amd64
20+
- linux_arm64
21+
- darwin_amd64
22+
- darwin_arm64
23+
- windows_amd64
24+
- main: ./cmd/protoc-gen-grpc_node
25+
id: node
26+
binary: protoc-gen-grpc_node
27+
env:
28+
- CGO_ENABLED=0
29+
targets:
30+
- linux_amd64
31+
- linux_arm64
32+
- darwin_amd64
33+
- darwin_arm64
34+
- windows_amd64
35+
- main: ./cmd/protoc-gen-grpc_objective_c
36+
id: objective_c
37+
binary: protoc-gen-grpc_objective_c
38+
env:
39+
- CGO_ENABLED=0
40+
targets:
41+
- linux_amd64
42+
- linux_arm64
43+
- darwin_amd64
44+
- darwin_arm64
45+
- windows_amd64
46+
- main: ./cmd/protoc-gen-grpc_php
47+
id: php
48+
binary: protoc-gen-grpc_php
49+
env:
50+
- CGO_ENABLED=0
51+
targets:
52+
- linux_amd64
53+
- linux_arm64
54+
- darwin_amd64
55+
- darwin_arm64
56+
- windows_amd64
57+
- main: ./cmd/protoc-gen-grpc_python
58+
id: python
59+
binary: protoc-gen-grpc_python
60+
env:
61+
- CGO_ENABLED=0
62+
targets:
63+
- linux_amd64
64+
- linux_arm64
65+
- darwin_amd64
66+
- darwin_arm64
67+
- windows_amd64
68+
- main: ./cmd/protoc-gen-grpc_ruby
69+
id: ruby
70+
binary: protoc-gen-grpc_ruby
71+
env:
72+
- CGO_ENABLED=0
73+
targets:
74+
- linux_amd64
75+
- linux_arm64
76+
- darwin_amd64
77+
- darwin_arm64
78+
- windows_amd64
79+
archives:
80+
- format_overrides:
81+
- goos: windows
82+
format: zip
83+
release:
84+
mode: append
85+
checksum:
86+
name_template: 'checksums.txt'
87+
snapshot:
88+
name_template: "{{ incpatch .Version }}-next"

go.work

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
go 1.19
1+
go 1.21
22

33
use (
44
.

internal/runner/runner.go

Lines changed: 1 addition & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package runner
33
import (
44
"context"
55
"crypto/rand"
6-
"io/fs"
76
"log"
87
"os"
98
"strings"
@@ -12,8 +11,6 @@ import (
1211
wazero "github.com/wasilibs/wazerox"
1312
"github.com/wasilibs/wazerox/api"
1413
"github.com/wasilibs/wazerox/experimental"
15-
"github.com/wasilibs/wazerox/experimental/sys"
16-
"github.com/wasilibs/wazerox/experimental/sysfs"
1714
"github.com/wasilibs/wazerox/imports/wasi_snapshot_preview1"
1815
wzsys "github.com/wasilibs/wazerox/sys"
1916
)
@@ -29,9 +26,6 @@ func Run(name string, wasm []byte) {
2926
args := []string{name}
3027
args = append(args, os.Args[1:]...)
3128

32-
fsCfg := wazero.NewFSConfig().(sysfs.FSConfig).WithSysFSMount(cmdFS{cwd: sysfs.DirFS("."), root: sysfs.DirFS("/")}, "/")
33-
fsCfg = fsCfg.(sysfs.FSConfig).WithRawPaths()
34-
3529
cfg := wazero.NewModuleConfig().
3630
WithSysNanosleep().
3731
WithSysNanotime().
@@ -40,8 +34,7 @@ func Run(name string, wasm []byte) {
4034
WithStdout(os.Stdout).
4135
WithStdin(os.Stdin).
4236
WithRandSource(rand.Reader).
43-
WithArgs(args...).
44-
WithFSConfig(fsCfg)
37+
WithArgs(args...)
4538
for _, env := range os.Environ() {
4639
k, v, _ := strings.Cut(env, "=")
4740
cfg = cfg.WithEnv(k, v)
@@ -55,63 +48,3 @@ func Run(name string, wasm []byte) {
5548
log.Fatal(err)
5649
}
5750
}
58-
59-
type cmdFS struct {
60-
cwd sys.FS
61-
root sys.FS
62-
}
63-
64-
func (fs cmdFS) OpenFile(path string, flag sys.Oflag, perm fs.FileMode) (sys.File, sys.Errno) {
65-
return fs.fs(path).OpenFile(path, flag, perm)
66-
}
67-
68-
func (fs cmdFS) Lstat(path string) (wzsys.Stat_t, sys.Errno) {
69-
return fs.fs(path).Lstat(path)
70-
}
71-
72-
func (fs cmdFS) Stat(path string) (wzsys.Stat_t, sys.Errno) {
73-
return fs.fs(path).Stat(path)
74-
}
75-
76-
func (fs cmdFS) Mkdir(path string, perm fs.FileMode) sys.Errno {
77-
return fs.fs(path).Mkdir(path, perm)
78-
}
79-
80-
func (fs cmdFS) Chmod(path string, perm fs.FileMode) sys.Errno {
81-
return fs.fs(path).Chmod(path, perm)
82-
}
83-
84-
func (fs cmdFS) Rename(from string, to string) sys.Errno {
85-
return fs.fs(from).Rename(from, to)
86-
}
87-
88-
func (fs cmdFS) Rmdir(path string) sys.Errno {
89-
return fs.fs(path).Rmdir(path)
90-
}
91-
92-
func (fs cmdFS) Unlink(path string) sys.Errno {
93-
return fs.fs(path).Unlink(path)
94-
}
95-
96-
func (fs cmdFS) Link(oldPath string, newPath string) sys.Errno {
97-
return fs.fs(oldPath).Link(oldPath, newPath)
98-
}
99-
100-
func (fs cmdFS) Symlink(oldPath string, linkName string) sys.Errno {
101-
return fs.fs(oldPath).Symlink(oldPath, linkName)
102-
}
103-
104-
func (fs cmdFS) Readlink(path string) (string, sys.Errno) {
105-
return fs.fs(path).Readlink(path)
106-
}
107-
108-
func (fs cmdFS) Utimens(path string, atim int64, mtim int64) sys.Errno {
109-
return fs.fs(path).Utimens(path, atim, mtim)
110-
}
111-
112-
func (fs cmdFS) fs(path string) sys.FS {
113-
if len(path) > 0 && path[0] != '/' {
114-
return fs.cwd
115-
}
116-
return fs.root
117-
}

magefiles/magefile.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
package main
22

33
import (
4+
"fmt"
5+
6+
"github.com/magefile/mage/sh"
47
"github.com/wasilibs/magefiles" // mage:import
58
)
69

710
func init() {
811
magefiles.SetLibraryName("protoc_gen_grpc")
912
}
13+
14+
func Snapshot() error {
15+
return sh.RunV("go", "run", fmt.Sprintf("github.com/goreleaser/goreleaser@%s", verGoReleaser), "release", "--snapshot", "--clean")
16+
}
17+
18+
func Release() error {
19+
return sh.RunV("go", "run", fmt.Sprintf("github.com/goreleaser/goreleaser@%s", verGoReleaser), "release", "--clean")
20+
}

magefiles/versions.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package main
2+
3+
const verGoReleaser = "v1.22.1"

testdata/protoc.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)