-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathversion.bzl
38 lines (33 loc) · 1.07 KB
/
version.bzl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Copyright 2023 ReSim, Inc.
#
# Use of this source code is governed by an MIT-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/MIT.
"""Repository rule to get the version of open core passed into the release workflow."""
def _resim_version_impl(repository_ctx):
version = repository_ctx.os.environ.get("RESIM_VERSION", default = "0.0.0")
if version.startswith("v"):
version = version[1:]
repository_ctx.file("BUILD.bazel", executable = False)
repository_ctx.file(
"defs.bzl.tpl",
content = "RESIM_VERSION = \"{RESIM_VERSION}\"\n",
executable = False,
)
repository_ctx.template(
"defs.bzl",
"defs.bzl.tpl",
substitutions = {"{RESIM_VERSION}": version},
executable = False,
)
resim_version = repository_rule(
environ = [
"RESIM_VERSION",
],
implementation = _resim_version_impl,
)
def _extension_impl(_):
resim_version(name = "resim_version")
resim_version_extension = module_extension(
implementation = _extension_impl,
)