diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..f732a0b2 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +bin +include diff --git a/.github/workflows/python-release.yml b/.github/workflows/python-release.yml index 6f4da8d7..63977ee4 100644 --- a/.github/workflows/python-release.yml +++ b/.github/workflows/python-release.yml @@ -27,7 +27,7 @@ jobs: pip --version - name: Install Poetry run: | - pipx install --pip-args=--constraint=.github/workflows/constraints.txt poetry + pipx install --pip-args=--constraint=${{ github.workspace }}/.github/workflows/constraints.txt poetry poetry --version - name: Check version working-directory: clients/python diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 08ffd056..a653cde3 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -40,13 +40,14 @@ jobs: with open(os.environ["GITHUB_ENV"], mode="a") as io: print(f"VIRTUALENV_PIP={pip.__version__}", file=io) - name: Install Poetry + # use absolute path as recommended with: https://github.com/pypa/pipx/issues/1331 run: | - pipx install --pip-args=--constraint=.github/workflows/constraints.txt poetry + pipx install --pip-args=--constraint=${{ github.workspace }}/.github/workflows/constraints.txt poetry poetry --version - name: Install Nox run: | - pipx install --pip-args=--constraint=.github/workflows/constraints.txt nox - pipx inject --pip-args=--constraint=.github/workflows/constraints.txt nox nox-poetry + pipx install --pip-args=--constraint=${{ github.workspace }}/.github/workflows/constraints.txt nox + pipx inject --pip-args=--constraint=${{ github.workspace }}/.github/workflows/constraints.txt nox nox-poetry nox --version - name: Run Nox working-directory: clients/python diff --git a/.gitignore b/.gitignore index 0d0c4601..01ceb11b 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,7 @@ log.html output.xml report.html __pycache__ + +# Protoc files +include/ +readme.txt diff --git a/Dockerfile b/Dockerfile index 7c771dc6..59809409 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,6 +19,7 @@ RUN yum install -y nodejs npm java-11 # Copy the go source COPY ["Makefile", "main.go", ".openapi-generator-ignore", "openapitools.json", "./"] + # Download protoc compiler v24.3 RUN set -ex\ ; ARCH=$(uname -m) ; echo $ARCH \ @@ -33,15 +34,18 @@ RUN set -ex\ RUN make deps # Copy rest of the source -COPY bin/ bin/ +COPY .git/ .git/ COPY cmd/ cmd/ COPY api/ api/ COPY internal/ internal/ -COPY pkg/ pkg/ COPY scripts/ scripts/ +COPY pkg/ pkg/ COPY patches/ patches/ COPY templates/ templates/ +# Download tools +RUN make deps + # Build USER root RUN CGO_ENABLED=1 GOOS=linux make clean model-registry diff --git a/Makefile b/Makefile index 923d09fb..a227ee84 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) PROJECT_PATH := $(patsubst %/,%,$(dir $(MKFILE_PATH))) PROJECT_BIN := $(PROJECT_PATH)/bin +GO := $(PROJECT_BIN)/go1.19 # add tools bin directory PATH := $(PROJECT_BIN):$(PATH) @@ -56,7 +57,7 @@ api/grpc/ml_metadata/proto/metadata_store_service.proto: sed -i 's#syntax = "proto[23]";#&\noption go_package = "github.com/kubeflow/model-registry/internal/ml_metadata/proto";#' metadata_store_service.proto internal/ml_metadata/proto/%.pb.go: api/grpc/ml_metadata/proto/%.proto - protoc -I./api/grpc --go_out=./internal --go_opt=paths=source_relative \ + bin/protoc -I./api/grpc --go_out=./internal --go_opt=paths=source_relative \ --go-grpc_out=./internal --go-grpc_opt=paths=source_relative $< .PHONY: gen/grpc @@ -76,8 +77,8 @@ openapi/validate: bin/openapi-generator-cli # generate the openapi server implementation .PHONY: gen/openapi-server gen/openapi-server: bin/openapi-generator-cli openapi/validate - @if git diff --cached --name-only | grep -q "api/openapi/model-registry.yaml" || \ - git diff --name-only | grep -q "api/openapi/model-registry.yaml" || \ + @if git diff --exit-code --name-only | grep -q "api/openapi/model-registry.yaml" || \ + git diff --exit-code --name-only | grep -q "api/openapi/model-registry.yaml" || \ [ -n "${FORCE_SERVER_GENERATION}" ]; then \ ROOT_FOLDER="." ./scripts/gen_openapi_server.sh; \ else \ @@ -97,7 +98,7 @@ pkg/openapi/client.go: bin/openapi-generator-cli api/openapi/model-registry.yaml .PHONY: vet vet: - go vet ./... + ${GO} vet ./... .PHONY: clean clean: @@ -107,14 +108,21 @@ clean: clean/odh: rm -Rf ./model-registry +bin/go: + GOBIN=$(PROJECT_BIN) go install golang.org/dl/go1.19@latest + $(PROJECT_BIN)/go1.19 download + +bin/protoc: + ./scripts/install_protoc.sh + bin/go-enum: - GOBIN=$(PROJECT_BIN) go install github.com/searKing/golang/tools/go-enum@v1.2.97 + GOBIN=$(PROJECT_BIN) ${GO} install github.com/searKing/golang/tools/go-enum@v1.2.97 bin/protoc-gen-go: - GOBIN=$(PROJECT_BIN) go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.31.0 + GOBIN=$(PROJECT_BIN) ${GO} install google.golang.org/protobuf/cmd/protoc-gen-go@v1.31.0 bin/protoc-gen-go-grpc: - GOBIN=$(PROJECT_BIN) go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3.0 + GOBIN=$(PROJECT_BIN) ${GO} install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3.0 GOLANGCI_LINT ?= ${PROJECT_BIN}/golangci-lint bin/golangci-lint: @@ -122,7 +130,7 @@ bin/golangci-lint: GOVERTER ?= ${PROJECT_BIN}/goverter bin/goverter: - GOBIN=$(PROJECT_PATH)/bin go install github.com/jmattheis/goverter/cmd/goverter@v1.1.1 + GOBIN=$(PROJECT_PATH)/bin ${GO} install github.com/jmattheis/goverter/cmd/goverter@v1.1.1 OPENAPI_GENERATOR ?= ${PROJECT_BIN}/openapi-generator-cli NPM ?= "$(shell which npm)" @@ -147,23 +155,23 @@ clean/deps: rm -Rf bin/* .PHONY: deps -deps: bin/go-enum bin/protoc-gen-go bin/protoc-gen-go-grpc bin/golangci-lint bin/goverter bin/openapi-generator-cli +deps: bin/go bin/protoc bin/go-enum bin/protoc-gen-go bin/protoc-gen-go-grpc bin/golangci-lint bin/goverter bin/openapi-generator-cli .PHONY: vendor vendor: - go mod vendor + ${GO} mod vendor .PHONY: build build: gen vet lint - go build + ${GO} build -buildvcs=false .PHONY: build/odh build/odh: vet - go build + ${GO} build -buildvcs=false .PHONY: gen gen: deps gen/grpc gen/openapi gen/openapi-server gen/converter - go generate ./... + ${GO} generate ./... # golanci lint takes more time while running under qemu and facing timeout issue "level=error msg="Timeout exceeded: try increasing it by passing --timeout option" .PHONY: lint @@ -173,20 +181,20 @@ lint: .PHONY: test test: gen - go test ./internal/... ./pkg/... + ${GO} test ./internal/... ./pkg/... .PHONY: test-nocache test-nocache: gen - go test ./internal/... ./pkg/... -count=1 + ${GO} test ./internal/... ./pkg/... -count=1 .PHONY: test-cover test-cover: gen - go test ./internal/... ./pkg/... -coverprofile=coverage.txt - go tool cover -html=coverage.txt -o coverage.html + ${GO} test ./internal/... ./pkg/... -coverprofile=coverage.txt + ${GO} tool cover -html=coverage.txt -o coverage.html .PHONY: run/proxy run/proxy: gen - go run main.go proxy --logtostderr=true + ${GO} run main.go proxy --logtostderr=true .PHONY: proxy proxy: build diff --git a/clients/python/poetry.lock b/clients/python/poetry.lock index e09d8338..b5197b00 100644 --- a/clients/python/poetry.lock +++ b/clients/python/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. [[package]] name = "absl-py" @@ -487,13 +487,13 @@ typing = ["types-PyYAML", "types-requests", "types-simplejson", "types-toml", "t [[package]] name = "idna" -version = "3.6" +version = "3.7" description = "Internationalized Domain Names in Applications (IDNA)" optional = false python-versions = ">=3.5" files = [ - {file = "idna-3.6-py3-none-any.whl", hash = "sha256:c05567e9c24a6b9faaa835c4821bad0590fbb9d5779e7caa6e1cc4978e7eb24f"}, - {file = "idna-3.6.tar.gz", hash = "sha256:9ecdbbd083b06798ae1e86adcbfe8ab1479cf864e4ee30fe4e46a003d12491ca"}, + {file = "idna-3.7-py3-none-any.whl", hash = "sha256:82fee1fc78add43492d3a1898bfa6d8a904cc97d8427f683ed8e798d07761aa0"}, + {file = "idna-3.7.tar.gz", hash = "sha256:028ff3aadf0609c1fd278d8ea3089299412a7a8b9bd005dd08b9f8285bcb5cfc"}, ] [[package]] @@ -982,6 +982,7 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, + {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, diff --git a/docker-compose-local.yaml b/docker-compose-local.yaml index 52b7601f..eeeac8a5 100644 --- a/docker-compose-local.yaml +++ b/docker-compose-local.yaml @@ -1,4 +1,4 @@ -version: '3' +version: '3.4' services: mlmd-server: image: gcr.io/tfx-oss-public/ml_metadata_store_server:1.14.0 @@ -13,8 +13,9 @@ services: build: context: . dockerfile: Dockerfile - command: ["proxy", "--mlmd-hostname", "localhost", "--mlmd-port", "9090"] + command: ["proxy", "--hostname", "0.0.0.0", "--mlmd-hostname", "mlmd-server", "--mlmd-port", "8080"] container_name: model-registry - network_mode: host + ports: + - "8080:8080" depends_on: - mlmd-server diff --git a/docker-compose.yaml b/docker-compose.yaml index 4f8e2d98..34d8f624 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -11,8 +11,9 @@ services: - ./test/config/ml-metadata:/tmp/shared model-registry: image: quay.io/opendatahub/model-registry:latest - command: ["proxy", "--mlmd-hostname", "localhost", "--mlmd-port", "9090"] + command: ["proxy", "--hostname", "0.0.0.0", "--mlmd-hostname", "mlmd-server", "--mlmd-port", "8080"] container_name: model-registry - network_mode: host + ports: + - "8080:8080" depends_on: - mlmd-server diff --git a/go.mod b/go.mod index 62910805..10f101a3 100644 --- a/go.mod +++ b/go.mod @@ -5,13 +5,13 @@ go 1.19 require ( github.com/go-chi/chi/v5 v5.0.12 github.com/go-chi/cors v1.2.1 - github.com/golang/glog v1.2.0 + github.com/golang/glog v1.2.1 github.com/spf13/cobra v1.8.0 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.18.2 github.com/stretchr/testify v1.9.0 github.com/testcontainers/testcontainers-go v0.26.0 - google.golang.org/grpc v1.62.1 + google.golang.org/grpc v1.63.2 google.golang.org/protobuf v1.33.0 ) @@ -32,7 +32,6 @@ require ( github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/go-ole/go-ole v1.2.6 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/protobuf v1.5.3 // indirect github.com/google/uuid v1.6.0 github.com/hashicorp/hcl v1.0.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect @@ -67,11 +66,11 @@ require ( go.uber.org/multierr v1.9.0 // indirect golang.org/x/exp v0.0.0-20230905200255-921286631fa9 golang.org/x/mod v0.12.0 // indirect - golang.org/x/net v0.20.0 // indirect - golang.org/x/sys v0.16.0 // indirect + golang.org/x/net v0.21.0 // indirect + golang.org/x/sys v0.17.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.13.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index c7bed18f..f33b5f3d 100644 --- a/go.sum +++ b/go.sum @@ -40,12 +40,8 @@ github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/glog v1.2.0 h1:uCdmnmatrKCgMBlM4rMuJZWOkPDqdbZPnrMXDY4gI68= -github.com/golang/glog v1.2.0/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/golang/glog v1.2.1 h1:OptwRhECazUx5ix5TTWC3EZhsZEHWcYWY4FQHTIubm4= +github.com/golang/glog v1.2.1/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= @@ -155,8 +151,8 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= -golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= +golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -171,8 +167,8 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= -golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= +golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= @@ -188,12 +184,10 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 h1:AjyfHzEPEFp/NpvfN5g+KDla3EMojjhRVZc1i7cj+oM= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80/go.mod h1:PAREbraiVEVGVdTZsVWjSbbTtSyGbAgIIvni8a8CD5s= -google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk= -google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de h1:cZGRis4/ot9uVm639a+rHCUaG0JJHEsdyzSQTMX+suY= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:H4O17MA/PE9BsGx3w+a+W2VOLLD1Qf7oJneAoU6WktY= +google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM= +google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/scripts/install_protoc.sh b/scripts/install_protoc.sh new file mode 100755 index 00000000..b7b165e5 --- /dev/null +++ b/scripts/install_protoc.sh @@ -0,0 +1,22 @@ +#! /bin/bash +set -euxo pipefail + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +VERSION="24.3" +OS="linux" +if [[ "$OSTYPE" == "darwin"* ]]; then + # Mac OSX + OS="osx" +fi +ARCH="x86_64" +if [[ "$(uname -m)" == "arm"* ]]; then + ARCH="aarch_64" +fi + +mkdir -p ${SCRIPT_DIR}/../bin + +wget -q https://github.com/protocolbuffers/protobuf/releases/download/v${VERSION}/protoc-${VERSION}-${OS}-${ARCH}.zip -O ${SCRIPT_DIR}/../protoc.zip && \ + unzip -qo ${SCRIPT_DIR}/../protoc.zip -d ${SCRIPT_DIR}/.. && \ + bin/protoc --version && \ + rm ${SCRIPT_DIR}/../protoc.zip