linux.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. import os
  10. from pathlib import Path
  11. from ci import tarball_uploader
  12. from ci.deploy.deploy_util import rust_version
  13. from materialize import mzbuild, spawn, ui
  14. from materialize.mz_version import MzLspServerVersion
  15. from materialize.rustc_flags import Sanitizer
  16. from . import deploy_util
  17. from .deploy_util import MZ_LSP_SERVER_VERSION
  18. def main() -> None:
  19. bazel = ui.env_is_truthy("CI_BAZEL_BUILD")
  20. bazel_remote_cache = os.getenv("CI_BAZEL_REMOTE_CACHE")
  21. bazel_lto = ui.env_is_truthy("CI_BAZEL_LTO")
  22. repo = mzbuild.Repository(
  23. Path("."),
  24. coverage=False,
  25. sanitizer=Sanitizer.none,
  26. bazel=bazel,
  27. bazel_remote_cache=bazel_remote_cache,
  28. bazel_lto=bazel_lto,
  29. )
  30. target = f"{repo.rd.arch}-unknown-linux-gnu"
  31. print("--- Checking version")
  32. assert (
  33. MzLspServerVersion.parse_without_prefix(
  34. repo.rd.cargo_workspace.crates["mz-lsp-server"].version_string
  35. )
  36. == MZ_LSP_SERVER_VERSION
  37. )
  38. print("--- Building mz-lsp-server")
  39. # The bin/ci-builder uses target-xcompile as the volume and
  40. # is where the binary release will be available.
  41. path = Path("target-xcompile") / "release" / "mz-lsp-server"
  42. spawn.runv(
  43. ["cargo", "build", "--bin", "mz-lsp-server", "--release"],
  44. env=dict(os.environ, RUSTUP_TOOLCHAIN=rust_version()),
  45. )
  46. mzbuild.chmod_x(path)
  47. print(f"--- Uploading {target} binary tarball")
  48. uploader = tarball_uploader.TarballUploader(
  49. package_name="mz-lsp-server",
  50. version=deploy_util.MZ_LSP_SERVER_VERSION,
  51. )
  52. uploader.deploy_tarball(target, path)
  53. if __name__ == "__main__":
  54. main()