From cc7250d1e8bddf67aecd748fc827d674f173dc62 Mon Sep 17 00:00:00 2001 From: Kimura Yu <33382781+KimuraYu45z@users.noreply.github.com> Date: Thu, 26 Aug 2021 12:38:40 +0900 Subject: [PATCH 1/6] feat: http_archive --- bazel/repositories.bzl | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index 166c354..7f618f6 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -1,13 +1,33 @@ -protobuf_commit = "099d99759101c295244c24d8954ec85b8ac65ce3" - -protobuf_sha256 = "c0ab1b088e220c1d56446f34001f0178e590270efdef1c46a77da4b9faa9d7b0" - +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") def protobuf_rules_gen_repositories(): if "com_google_protobuf" not in native.existing_rules(): - native.http_archive( + http_archive( + name = "rules_python", + url = "https://github.com/bazelbuild/rules_python/releases/download/0.3.0/rules_python-0.3.0.tar.gz", + sha256 = "934c9ceb552e84577b0faf1e5a2f0450314985b4d8712b2b70717dc679fdc01b", + ) + http_archive( + name = "bazel_skylib", + urls = [ + "https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz", + ], + sha256 = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c", + ) + http_archive( + name = "zlib", + build_file = "@com_google_protobuf//:third_party/zlib.BUILD", + sha256 = "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1", + strip_prefix = "zlib-1.2.11", + urls = [ + "https://mirror.bazel.build/zlib.net/zlib-1.2.11.tar.gz", + "https://zlib.net/zlib-1.2.11.tar.gz", + ], + ) + http_archive( name = "com_google_protobuf", - sha256 = protobuf_sha256, - strip_prefix = "protobuf-" + protobuf_commit, - url = "https://github.com/google/protobuf/archive/" + protobuf_commit + ".tar.gz", + sha256 = "528927e398f4e290001886894dac17c5c6a2e5548f3fb68004cfb01af901b53a", + strip_prefix = "protobuf-3.17.3", + urls = ["https://github.com/google/protobuf/archive/v3.17.3.zip"], ) From 071dc09776211340cd5483ff4baf7e212d566568 Mon Sep 17 00:00:00 2001 From: Kimura Yu <33382781+KimuraYu45z@users.noreply.github.com> Date: Thu, 26 Aug 2021 14:52:55 +0900 Subject: [PATCH 2/6] feat: gen_cc --- bazel/defs.bzl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bazel/defs.bzl b/bazel/defs.bzl index 8ab3e92..8a48855 100644 --- a/bazel/defs.bzl +++ b/bazel/defs.bzl @@ -56,7 +56,7 @@ def firestore_rules_proto_library( **kargs: other keyword arguments that are passed to ts_library. """ - outs = _outputs(srcs, ".rules") + outs = _outputs(srcs, ".cc") includes = [] if include != None: @@ -75,6 +75,7 @@ def firestore_rules_proto_library( plugin = plugin, plugin_language = "protoc-gen-firebase_rules", plugin_options = ["bazel"], + gen_cc = True ) firestore_rules_library( From 594ee14bab25b8212147e2fc03d79f0410c791fc Mon Sep 17 00:00:00 2001 From: Kimura Yu <33382781+KimuraYu45z@users.noreply.github.com> Date: Thu, 26 Aug 2021 15:42:08 +0900 Subject: [PATCH 3/6] feat: actions --- .github/workflows/binary.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/binary.yml diff --git a/.github/workflows/binary.yml b/.github/workflows/binary.yml new file mode 100644 index 0000000..80a9c09 --- /dev/null +++ b/.github/workflows/binary.yml @@ -0,0 +1,30 @@ +name: Binary + +on: + release: + types: + - created + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + arch: [amd64, arm64] + targetos: [windows, darwin, linux] + name: ${{ matrix.arch }}-${{ matrix.targetos }} + steps: + - uses: actions/checkout@v2 + - run: | + sudo apt install apt-transport-https curl gnupg + curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel.gpg + sudo mv bazel.gpg /etc/apt/trusted.gpg.d/ + echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list + - run: | + bazel build @com_google_protobuf//:protoc + bazel build //firebase_rules_generator:protoc-gen-firebase_rules --platforms=//:${{ matrix.targetos }}-${{ matrix.arch }} + + - uses: actions/upload-artifact@v2 + with: + name: protoc-gen-firebase_rules-${{ matrix.targetos }}-${{ matrix.arch }} + path: bazel-bin/firebase_rules_generator/protoc-gen-firebase_rules From a88fa2d59e07d46cb0a73a573eba1fa7a56fae48 Mon Sep 17 00:00:00 2001 From: Kimura Yu <33382781+KimuraYu45z@users.noreply.github.com> Date: Thu, 26 Aug 2021 16:05:18 +0900 Subject: [PATCH 4/6] feat: platforms configurations --- BUILD | 43 +++++++++++++++++++++++++++++++++++++++++++ bazel/BUILD | 1 - 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/BUILD b/BUILD index 39a336f..6adb8d0 100644 --- a/BUILD +++ b/BUILD @@ -30,3 +30,46 @@ py_test( "@com_google_protobuf//:timestamp_proto", ], ) + +platform( + name = "windows-amd64", + constraint_values = [ + "@platforms//os:windows", + "@platforms//cpu:x86_64", + ], +) +platform( + name = "windows-arm64", + constraint_values = [ + "@platforms//os:windows", + "@platforms//cpu:arm64", + ], +) +platform( + name = "darwin-amd64", + constraint_values = [ + "@platforms//os:macos", + "@platforms//cpu:x86_64", + ], +) +platform( + name = "darwin-arm64", + constraint_values = [ + "@platforms//os:macos", + "@platforms//cpu:arm64", + ], +) +platform( + name = "linux-amd64", + constraint_values = [ + "@platforms//os:linux", + "@platforms//cpu:x86_64", + ], +) +platform( + name = "linux-arm64", + constraint_values = [ + "@platforms//os:linux", + "@platforms//cpu:arm64", + ], +) diff --git a/bazel/BUILD b/bazel/BUILD index 8b13789..e69de29 100644 --- a/bazel/BUILD +++ b/bazel/BUILD @@ -1 +0,0 @@ - From 92bc8f422944666652de68e2adc94fee8d5335da Mon Sep 17 00:00:00 2001 From: Kimura Yu <33382781+KimuraYu45z@users.noreply.github.com> Date: Sat, 28 Aug 2021 13:57:13 +0900 Subject: [PATCH 5/6] fix: nitpicks --- bazel/repositories.bzl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index 7f618f6..e1e2564 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -4,16 +4,16 @@ def protobuf_rules_gen_repositories(): if "com_google_protobuf" not in native.existing_rules(): http_archive( name = "rules_python", - url = "https://github.com/bazelbuild/rules_python/releases/download/0.3.0/rules_python-0.3.0.tar.gz", sha256 = "934c9ceb552e84577b0faf1e5a2f0450314985b4d8712b2b70717dc679fdc01b", + url = "https://github.com/bazelbuild/rules_python/releases/download/0.3.0/rules_python-0.3.0.tar.gz", ) http_archive( name = "bazel_skylib", + sha256 = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c", urls = [ "https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz", "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz", ], - sha256 = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c", ) http_archive( name = "zlib", @@ -29,5 +29,5 @@ def protobuf_rules_gen_repositories(): name = "com_google_protobuf", sha256 = "528927e398f4e290001886894dac17c5c6a2e5548f3fb68004cfb01af901b53a", strip_prefix = "protobuf-3.17.3", - urls = ["https://github.com/google/protobuf/archive/v3.17.3.zip"], + url = "https://github.com/google/protobuf/archive/v3.17.3.zip", ) From cb19e42646cb15262eebfdbfecc3b8e77a088e73 Mon Sep 17 00:00:00 2001 From: Kimura Yu <33382781+KimuraYu45z@users.noreply.github.com> Date: Sat, 28 Aug 2021 13:59:06 +0900 Subject: [PATCH 6/6] fix: actions --- .github/workflows/binary.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/binary.yml b/.github/workflows/binary.yml index 80a9c09..4b06654 100644 --- a/.github/workflows/binary.yml +++ b/.github/workflows/binary.yml @@ -19,7 +19,7 @@ jobs: sudo apt install apt-transport-https curl gnupg curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel.gpg sudo mv bazel.gpg /etc/apt/trusted.gpg.d/ - echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list + sudo echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" > /etc/apt/sources.list.d/bazel.list - run: | bazel build @com_google_protobuf//:protoc bazel build //firebase_rules_generator:protoc-gen-firebase_rules --platforms=//:${{ matrix.targetos }}-${{ matrix.arch }}