diff --git a/.gitignore b/.gitignore index c2b1247..29366a4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ grpcox log -*.out \ No newline at end of file +*.out +dist/ diff --git a/core/resource.go b/core/resource.go index c2ac7cd..f3de08d 100644 --- a/core/resource.go +++ b/core/resource.go @@ -49,7 +49,7 @@ func (r *Resource) openDescriptor() error { return nil } - protoPath := filepath.Join(BasePath, r.clientConn.Target()) + protoPath := strings.ReplaceAll(filepath.Join(BasePath, r.clientConn.Target()),":", "_") // make list of protos name to be used as descriptor protos := make([]string, 0, len(r.protos)) @@ -266,7 +266,7 @@ func (r *Resource) exit(code int) { // proto files will be persisted in /tmp/grpcox/127.0.0.1:8888 // if the directory is already there, remove it first func (r *Resource) AddProtos(protos []Proto) error { - protoPath := filepath.Join(BasePath, r.clientConn.Target()) + protoPath := strings.ReplaceAll(filepath.Join(BasePath, r.clientConn.Target()),":", "_") err := os.MkdirAll(protoPath, 0777) if os.IsExist(err) { os.RemoveAll(protoPath) diff --git a/go-executable-build.sh b/go-executable-build.sh new file mode 100755 index 0000000..3d31022 --- /dev/null +++ b/go-executable-build.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +package_name=grpcox +version=1.0.0 + +platforms=("windows/amd64" "windows/386" "darwin/amd64" "linux/amd64") +mkdir -p dist/log +rm -fr dist/index && cp -r index dist/index +rm -fr dist/LICENSE && cp -r LICENSE dist/LICENSE + +for platform in "${platforms[@]}" +do + platform_split=(${platform//\// }) + GOOS=${platform_split[0]} + GOARCH=${platform_split[1]} + output_name=$package_name'-'$version'-'$GOOS'-'$GOARCH + ext="" + if [ $GOOS = "windows" ]; then + ext='.exe' + fi + + env GOOS=$GOOS GOARCH=$GOARCH go build -o dist/$package_name$ext + if [ $? -ne 0 ]; then + echo 'An error has occurred! Aborting the script execution...' + exit 1 + fi + (cd dist; rm -f $output_name.zip; zip -r $output_name.zip $package_name$ext log index LICENSE) + rm -f dist/$package_name$ext +done + +rm -fr dist/index +rm -fr dist/LICENSE