Skip to content

Commit

Permalink
chore: build protoc-gen-swift and protoc-gen-grpc-swift from separate…
Browse files Browse the repository at this point in the history
… repos
  • Loading branch information
strophy committed Jan 31, 2025
1 parent c5344b1 commit c2cc19a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 9 deletions.
8 changes: 7 additions & 1 deletion .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,16 @@
},
{
"fileMatch": ["^deps\\.list$"],
"matchStrings": ["GRPC_SWIFT_VERSION=(?<currentValue>.*?)\\n"],
"matchStrings": ["PROTOC_GEN_SWIFT_VERSION=(?<currentValue>.*?)\\n"],
"depNameTemplate": "grpc/grpc-swift",
"datasourceTemplate": "github-releases"
},
{
"fileMatch": ["^deps\\.list$"],
"matchStrings": ["GRPC_SWIFT_VERSION=(?<currentValue>.*?)\\n"],
"depNameTemplate": "grpc/grpc-swift-protobuf",
"datasourceTemplate": "github-releases"
},
{
"fileMatch": ["^deps\\.list$"],
"matchStrings": ["GRPC_WEB_VERSION=(?<currentValue>.*?)\\n"],
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/dockerimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,13 @@ jobs:
PROTOC_GEN_JSONSCHEMA_VERSION=${{ env.PROTOC_GEN_JSONSCHEMA_VERSION }}
PROTOC_GEN_LINT_VERSION=${{ env.PROTOC_GEN_LINT_VERSION }}
PROTOC_GEN_NANOPB_VERSION=${{ env.PROTOC_GEN_NANOPB_VERSION }}
PROTOC_GEN_OPENAPI_VERSION=${{ env.PROTOC_GEN_OPENAPI_VERSION }}
PROTOC_GEN_PBANDK_VERSION=${{ env.PROTOC_GEN_PBANDK_VERSION }}
PROTOC_GEN_RUST_VERSION=${{ env.PROTOC_GEN_RUST_VERSION }}
PROTOC_GEN_SCALA_VERSION=${{ env.PROTOC_GEN_SCALA_VERSION }}
PROTOC_GEN_SWIFT_VERSION=${{ env.PROTOC_GEN_SWIFT_VERSION }}
PROTOC_GEN_TS_VERSION=${{ env.PROTOC_GEN_TS_VERSION }}
PROTOC_GEN_VALIDATE_VERSION=${{ env.PROTOC_GEN_VALIDATE_VERSION }}
PROTOC_GEN_OPENAPI_VERSION=${{ env.PROTOC_GEN_OPENAPI_VERSION }}
RUST_IMAGE_VERSION=${{ env.RUST_IMAGE_VERSION }}
SCALA_SBT_IMAGE_VERSION=${{ env.SCALA_SBT_IMAGE_VERSION }}
SWIFT_IMAGE_VERSION=${{ env.SWIFT_IMAGE_VERSION }}
Expand Down
30 changes: 24 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -282,15 +282,19 @@ RUN install -D /grpc-rust/target/$(xx-cargo --print-target-triple)/release/proto
RUN xx-verify /out/usr/bin/protoc-gen-rust-grpc


FROM --platform=$BUILDPLATFORM swift:${SWIFT_IMAGE_VERSION}-noble AS grpc_swift
ARG GRPC_SWIFT_VERSION SWIFT_IMAGE_VERSION
FROM --platform=$BUILDPLATFORM swift:${SWIFT_IMAGE_VERSION}-noble AS swift_target
ARG SWIFT_IMAGE_VERSION
RUN apt-get update && \
apt-get install -y curl
RUN swift sdk install \
https://download.swift.org/swift-${SWIFT_IMAGE_VERSION}-release/static-sdk/swift-${SWIFT_IMAGE_VERSION}-RELEASE/swift-${SWIFT_IMAGE_VERSION}-RELEASE_static-linux-0.0.1.artifactbundle.tar.gz \
--checksum 67f765e0030e661a7450f7e4877cfe008db4f57f177d5a08a6e26fd661cdd0bd


FROM --platform=$BUILDPLATFORM swift_target AS grpc_gen_swift
ARG PROTOC_GEN_SWIFT_VERSION
RUN mkdir -p /grpc-swift
RUN curl -sSL https://api.github.com/repos/grpc/grpc-swift/tarball/${GRPC_SWIFT_VERSION} | tar xz --strip 1 -C /grpc-swift
RUN curl -sSL https://api.github.com/repos/grpc/grpc-swift/tarball/${PROTOC_GEN_SWIFT_VERSION} | tar xz --strip 1 -C /grpc-swift
WORKDIR /grpc-swift
ARG TARGETOS TARGETARCH
RUN <<EOF
Expand All @@ -300,11 +304,24 @@ RUN <<EOF
*) echo "ERROR: Machine arch ${TARGETARCH} not supported." ;;
esac
swift build -c release --product protoc-gen-swift --swift-sdk $SWIFTARCH-swift-linux-musl
swift build -c release --product protoc-gen-grpc-swift --swift-sdk $SWIFTARCH-swift-linux-musl
install -D /grpc-swift/.build/release/protoc-gen-swift /out/usr/bin/protoc-gen-swift && \
install -D /grpc-swift/.build/release/protoc-gen-grpc-swift /out/usr/bin/protoc-gen-grpc-swift
install -D /grpc-swift/.build/release/protoc-gen-swift /out/usr/bin/protoc-gen-swift
EOF

FROM --platform=$BUILDPLATFORM swift_target AS grpc_swift
ARG GRPC_SWIFT_VERSION
RUN mkdir -p /grpc-swift-protobuf
RUN curl -sSL https://api.github.com/repos/grpc/grpc-swift-protobuf/tarball/${GRPC_SWIFT_VERSION} | tar xz --strip 1 -C /grpc-swift-protobuf
WORKDIR /grpc-swift-protobuf
ARG TARGETOS TARGETARCH
RUN <<EOF
case ${TARGETARCH} in
"amd64") SWIFTARCH=x86_64 ;;
"arm64") SWIFTARCH=aarch64 ;;
*) echo "ERROR: Machine arch ${TARGETARCH} not supported." ;;
esac
swift build -c release --product protoc-gen-grpc-swift --swift-sdk $SWIFTARCH-swift-linux-musl
install -D /grpc-swift-protobuf/.build/release/protoc-gen-grpc-swift /out/usr/bin/protoc-gen-grpc-swift
EOF

FROM --platform=$BUILDPLATFORM alpine:${ALPINE_IMAGE_VERSION} AS alpine_host
COPY --from=xx / /
Expand Down Expand Up @@ -394,6 +411,7 @@ RUN curl -sSL https://github.com/upx/upx/releases/download/v${UPX_VERSION}/upx-$
RUN install -D /upx/upx /usr/local/bin/upx
COPY --from=googleapis /out/ /out/
COPY --from=grpc_gateway /out/ /out/
COPY --from=grpc_gen_swift /out/ /out/
COPY --from=grpc_rust /out/ /out/
COPY --from=grpc_swift /out/ /out/
COPY --from=grpc_web /out/ /out/
Expand Down
3 changes: 2 additions & 1 deletion deps.list
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ GO_IMAGE_VERSION=1.23.4-alpine3.21
GOOGLE_API_VERSION=d57f2c114b2d1d3db7fa71a1333d72129f8fd1ae
GRPC_GATEWAY_VERSION=v2.26.0
GRPC_RUST_VERSION=v0.8.3
GRPC_SWIFT_VERSION=2.0.0
GRPC_SWIFT_VERSION=1.0.0
GRPC_WEB_VERSION=1.5.0
NODE_IMAGE_VERSION=22.12.0-alpine3.21
PROTOC_GEN_BQ_SCHEMA_VERSION=v3.0
Expand All @@ -15,6 +15,7 @@ PROTOC_GEN_GO_VERSION=v1.36.4
PROTOC_GEN_GOGO_VERSION=v1.3.2
PROTOC_GEN_GORM_VERSION=v1.1.4
PROTOC_GEN_GOTEMPLATE_VERSION=v1.11.3
PROTOC_GEN_SWIFT_VERSION=2.0.0
PROTOC_GEN_GOVALIDATORS_VERSION=v0.3.2
PROTOC_GEN_GQL_VERSION=v0.10.0
PROTOC_GEN_JSONSCHEMA_VERSION=1.4.1
Expand Down

0 comments on commit c2cc19a

Please sign in to comment.