{"id":392457,"date":"2024-06-29T10:25:32","date_gmt":"2024-06-29T10:25:32","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=392457"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=392457","title":{"rendered":"<span>Bazel, stamping, remote cache<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/778\/93d\/665\/77893d6653720ade3c581dc6eb61180f.jpg\" width=\"2120\" height=\"1113\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/778\/93d\/665\/77893d6653720ade3c581dc6eb61180f.jpg\" data-blurred=\"true\"\/><\/figure>\n<h2>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 stamping?<\/h2>\n<p>\u0412 Bazel \u0435\u0441\u0442\u044c \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u0430\u044f \u0444\u0438\u0447\u0430, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0430\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0438\u043d\u0432\u0430\u043b\u0438\u0434\u0438\u0440\u0443\u044e\u0442 \u043a\u044d\u0448 \u0441\u0431\u043e\u0440\u043a\u0438.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u044d\u0442\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0439 \u0444\u0430\u0439\u043b \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0442\u043e\u043c, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d \u0431\u044b\u043b \u0441\u043e\u0431\u0440\u0430\u043d \u0438 \u0438\u0437 \u043a\u0430\u043a\u043e\u0439 \u0440\u0435\u0432\u0438\u0437\u0438\u0438. \u0415\u0441\u043b\u0438 \u0434\u043b\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438 \u043d\u043e\u043c\u0435\u0440\u0430 \u0440\u0435\u0432\u0438\u0437\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c stamping, \u0442\u043e, \u043a\u043e\u0433\u0434\u0430 \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0432 \u043a\u044d\u0448\u0435, \u043e\u043d \u043f\u0435\u0440\u0435\u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0431\u0443\u0434\u0435\u0442.<\/p>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<ul>\n<li>\n<p>\u043b\u044e\u0431\u043e\u0435 \u0437\u043d\u0430\u0447\u0438\u043c\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0441\u043e\u0431\u0435\u0440\u0435\u0442 \u0444\u0430\u0439\u043b \u0437\u0430\u043d\u043e\u0432\u043e;<\/p>\n<\/li>\n<li>\n<p>\u0432\u043d\u0443\u0442\u0440\u0438 \u0444\u0430\u0439\u043b\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u0430\u044f \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u0435\u0433\u043e \u043e\u0442\u043b\u0430\u0434\u043a\u043e\u0439 (\u0438\u0437 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u0440\u0435\u0432\u0438\u0437\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u044b\u0439 \u0444\u0430\u0439\u043b);<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u043b\u0438\u0448\u043d\u0435\u0439 \u043f\u0435\u0440\u0435\u0441\u0431\u043e\u0440\u043a\u0438 \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u043e\u043c\u043c\u0438\u0442 \u0438\u0437-\u0437\u0430 \u043d\u0435 \u0432\u043b\u0438\u044f\u044e\u0449\u0438\u0445 \u043d\u0430 \u043d\u0435\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u043e\u043c\u0435\u0440 \u0440\u0435\u0432\u0438\u0437\u0438\u0438 \u043d\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043f\u043e\u0438\u0441\u043a\u0435 \u0432 \u043a\u044d\u0448\u0435.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 GoLang, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0432\u0435\u0440\u0441\u0438\u0438 1.18, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0440\u0435\u0432\u0438\u0437\u0438\u0438, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u044b\u043b \u0441\u043e\u0431\u0440\u0430\u043d \u0444\u0430\u0439\u043b, \u0447\u0435\u0440\u0435\u0437 <a href=\"https:\/\/pkg.go.dev\/runtime\/debug#ReadBuildInfo\"><u>debug.ReadBuildInfo<\/u><\/a>.<\/p>\n<h2>\u041a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c stamping?<\/h2>\n<h3>\u041e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0434\u043b\u044f stamping-\u0430<\/h3>\n<p>\u0414\u043b\u044f \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 stamping-\u0430 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0432\u0435\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0439 \u0444\u0430\u0439\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u0438\u0448\u0435\u0442 \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0432\u044b\u0432\u043e\u0434 \u043f\u0430\u0440\u044b \u043a\u043b\u044e\u0447-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u0431\u0435\u043b \u043f\u043e \u043e\u0434\u043d\u043e\u0439 \u043f\u0430\u0440\u0435 \u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0443.<\/p>\n<p>\u042d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0432 \u043a\u043e\u0440\u043d\u0435 \u0440\u0430\u0431\u043e\u0447\u0435\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"bash\">#!\/bin\/sh echo \"GIT_COMMIT $(git rev-parse HEAD)\" echo \"STABLE_GIT_URL $(git remote get-url origin)\" <\/code><\/pre>\n<p>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0441 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043e\u043c <code>STABLE_<\/code> \u0431\u0443\u0434\u0443\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u043b\u044e\u0447\u0435 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>\u0423\u0447\u0430\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0432 \u043a\u043b\u044e\u0447\u0435 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043f\u043e\u043f\u0430\u0434\u0443\u0442 \u0432 \u0444\u0430\u0439\u043b <code>bazel-out\/stable-status.txt<\/code> , \u0430 \u043d\u0435 \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043f\u043e\u043f\u0430\u0434\u0443\u0442 \u0432 \u0444\u0430\u0439\u043b <code>bazel-out\/volatile-status.txt<\/code>.<\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b Bazel \u0437\u043d\u0430\u043b, \u0433\u0434\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0444\u0430\u0439\u043b, \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0449\u0438\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u0444\u0430\u0439\u043b \u043d\u0443\u0436\u043d\u043e \u0435\u043c\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043a\u043b\u044e\u0447 &#8212;workspace_status_command= (<a href=\"https:\/\/bazel.build\/reference\/command-line-reference#flag--workspace_status_command\">https:\/\/bazel.build\/reference\/command-line-reference#flag&#8212;workspace_status_command<\/a>).<\/p>\n<p>\u041b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u043e, \u043d\u043e \u043f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0430, \u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b, \u0447\u0442\u043e \u0441\u043a\u0440\u0438\u043f\u0442 \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u043d\u044b\u0439 \u0432 \u043a\u043e\u0440\u043d\u0435 \u0440\u0430\u0431\u043e\u0447\u0435\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430, \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<p>\u0423 \u043c\u043d\u043e\u0433\u0438\u0445 \u043f\u0440\u0430\u0432\u0438\u043b stamping \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u0441\u0431\u043e\u0440\u043a\u0435 \u0441 \u0444\u043b\u0430\u0433\u043e\u043c <code>--stamp<\/code>.<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f stamping \u0438 GoLang<\/h3>\n<p><a href=\"https:\/\/github.com\/bozaro\/bazel-stamping\/tree\/golang\"><u>\u041f\u043e\u043b\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043d\u0430 Github<\/u><\/a>.<\/p>\n<h4>\u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0431\u043e\u0447\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e Bazel \u0434\u043b\u044f GoLang<\/h4>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 GoLang \u0432 Bazel, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0440\u0438 \u0444\u0430\u0439\u043b\u0430.<\/p>\n<p>\u041f\u0443\u0441\u0442\u043e\u0439 \u0444\u0430\u0439\u043b <code>BUILD<\/code>.<\/p>\n<p>\u0424\u0430\u0439\u043b <code>WORKSPACE<\/code> (\u044d\u0442\u043e\u0442 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0432\u0437\u044f\u0442 <a href=\"https:\/\/github.com\/bazelbuild\/rules_go\/releases\/tag\/v0.38.1\"><u>\u0437\u0434\u0435\u0441\u044c<\/u><\/a>):<\/p>\n<pre><code class=\"python\">load(\"@bazel_tools\/\/tools\/build_defs\/repo:http.bzl\", \"http_archive\")  http_archive(     name = \"io_bazel_rules_go\",     sha256 = \"dd926a88a564a9246713a9c00b35315f54cbd46b31a26d5d8fb264c07045f05d\",     urls = [         \"https:\/\/mirror.bazel.build\/github.com\/bazelbuild\/rules_go\/releases\/download\/v0.38.1\/rules_go-v0.38.1.zip\",         \"https:\/\/github.com\/bazelbuild\/rules_go\/releases\/download\/v0.38.1\/rules_go-v0.38.1.zip\",     ], )  load(\"@io_bazel_rules_go\/\/go:deps.bzl\", \"go_register_toolchains\", \"go_rules_dependencies\")  go_rules_dependencies()  go_register_toolchains(version = \"1.20.1\")<\/code><\/pre>\n<p>\u0424\u0430\u0439\u043b <code>go.mod<\/code> \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0441 <code>go build<\/code>:<\/p>\n<pre><code class=\"go\">module github.com\/bozaro\/bazel-stamping go 1.19<\/code><\/pre>\n<h4>\u0421\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445<\/h4>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043a\u0440\u0438\u043f\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043b\u043e\u0436\u0438\u0442 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <code>GIT_COMMIT<\/code> \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u0440\u0435\u0432\u0438\u0437\u0438\u044e \u043a\u043e\u0434\u0430 <code>example\/stamping.sh<\/code>:<\/p>\n<pre><code class=\"bash\">#!\/bin\/sh echo \"GIT_COMMIT $(git rev-parse HEAD)\"<\/code><\/pre>\n<p>\u0418, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u043c\u044f \u044d\u0442\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0435 <code>bazel<\/code>, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0433\u043e \u0432 <code>.bazelrc<\/code>:<\/p>\n<pre><code>build --workspace_status_command=example\/stamping.sh<\/code><\/pre>\n<h4>\u0422\u0435\u0441\u0442\u043e\u0432\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430<\/h4>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u043b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0441\u0431\u043e\u0440\u043a\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 <code>example\/main.go<\/code>:<\/p>\n<pre><code class=\"go\">package main  import ( \"fmt\" \"runtime\/debug\" \"strconv\" \"time\" )  var gitCommit string var buildTimestamp string  func main() { fmt.Println(\"Stamping example\") if buildInfo, ok := debug.ReadBuildInfo(); ok { fmt.Println(\"=== Begin build info ===\") fmt.Println(buildInfo) fmt.Println(\"=== End build info ===\") for _, setting := range buildInfo.Settings { if setting.Key == \"vcs.revision\" { fmt.Println(\"Found go build revision:\", setting.Value) } if setting.Key == \"vcs.time\" { fmt.Println(\"Found go build timestamp:\", setting.Value) } } } if gitCommit != \"\" { fmt.Println(\"Found x_defs revision:\", gitCommit) } if buildTimestamp != \"\" { ts, _ := strconv.ParseInt(buildTimestamp, 10, 64) fmt.Println(\"Found x_defs build timestamp:\", time.Unix(ts, 0).UTC().Format(time.RFC3339Nano)) } }<\/code><\/pre>\n<p>\u042d\u0442\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0434\u0435\u043b\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<ul>\n<li>\n<p>\u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 <code>debug.ReadBuildInfo<\/code> \u043a\u0430\u043a \u0435\u0441\u0442\u044c;<\/p>\n<\/li>\n<li>\n<p>\u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>vcs.revision<\/code> \u0438 <code>vcs.time<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 <code>go build<\/code>, \u0435\u0441\u043b\u0438 \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f;<\/p>\n<\/li>\n<li>\n<p>\u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 <code>gitCommit<\/code> \u0438 <code>buildTimestamp<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u043a\u043e\u0434\u0435 \u043d\u0438\u0433\u0434\u0435 \u043d\u0435 \u0437\u0430\u0434\u0430\u044e\u0442\u0441\u044f.<\/p>\n<\/li>\n<\/ul>\n<p>\u0415\u0441\u043b\u0438 \u044d\u0442\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 <code>go build . &amp;&amp; .\/example<\/code> \u0438\u043b\u0438, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 Go 1.20, \u0447\u0435\u0440\u0435\u0437 <code>go run -buildvcs=true .<\/code>, \u0442\u043e \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code>Stamping example === Begin build info === gogo1.20.1 pathgithub.com\/bozaro\/bazel-stamping\/example modgithub.com\/bozaro\/bazel-stamping(devel) build-buildmode=exe build-compiler=gc buildCGO_ENABLED=1 buildCGO_CFLAGS= buildCGO_CPPFLAGS= buildCGO_CXXFLAGS= buildCGO_LDFLAGS= buildGOARCH=amd64 buildGOOS=linux buildGOAMD64=v1 buildvcs=git buildvcs.revision=daa3fb74938a476db8bf4b295b01317226780a75 buildvcs.time=2023-02-10T17:03:08Z buildvcs.modified=true  === End build info === Found go build revision: daa3fb74938a476db8bf4b295b01317226780a75 Found go build timestamp: 2023-02-10T17:03:08Z<\/code><\/pre>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c, \u0432 <code>debug.ReadBuildInfo()<\/code> \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0438\u0437 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0440\u0430\u0431\u043e\u0447\u0435\u0439 \u043a\u043e\u043f\u0438\u0438 Git. <code>gitCommit<\/code> \u0438 <code>buildTimestamp<\/code> \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e \u043f\u0443\u0441\u0442\u044b.<\/p>\n<h4>\u0421\u0431\u043e\u0440\u043a\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/h4>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0441\u0431\u043e\u0440\u043a\u0438 .go-\u0444\u0430\u0439\u043b\u0430 \u0432 <code>example\/BUILD<\/code>:<\/p>\n<pre><code class=\"python\">load(\"@io_bazel_rules_go\/\/go:def.bzl\", \"go_binary\")  go_binary(     name = \"example\",     srcs = [\"main.go\"],     out = \"example\",     pure = \"on\",     visibility = [\"\/\/visibility:public\"],     x_defs = {         \"gitCommit\": \"{GIT_COMMIT}\",         \"buildTimestamp\": \"{BUILD_TIMESTAMP}\",         \"runtime.modinfo\": \"\\n\".join([             \"                \",             \"build\\tvcs.revision={GIT_COMMIT}\",             \"build\\tvcs.time=2023-01-01T00:00:00Z\",             \"                \",         ]),     }, )<\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0435 \u043f\u0440\u0438\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>x_defs<\/code>:<\/p>\n<ul>\n<li>\n<p>\u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <code>gitCommit<\/code> \u0437\u0430\u0434\u0430\u0451\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u0437 stamping-\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>GIT_COMMIT<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <code>buildTimestamp<\/code> \u0437\u0430\u0434\u0430\u0451\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u0437 stamping-\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>BUILD_TIMESTAMP<\/code>.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 <code>x_defs<\/code> \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0430 <code>go_binary<\/code>, \u043d\u043e \u0435\u0433\u043e \u0442\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 <code>go_library<\/code> \u0438 <code>go_test<\/code>.<\/p>\n<p>\u0414\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f <code>debug.ReadBuildInfo()<\/code> Bazel \u0441\u0430\u043c \u043d\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442, \u043d\u043e, \u0435\u0441\u043b\u0438 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0447\u0435\u0442\u0441\u044f, \u0442\u043e \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 <code>runtime.modinfo<\/code>.<\/p>\n<p>\u041f\u0440\u0430\u0432\u0434\u0430, \u0435\u0441\u0442\u044c \u0440\u044f\u0434 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439:<\/p>\n<ul>\n<li>\n<p>\u0432\u0435\u0440\u0441\u0438\u044f Go \u0436\u0438\u0432\u0451\u0442 \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u043c\u0438 <code>modinfo<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u0432 \u0441\u0430\u043c\u043e\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 <code>runtime.modinfo<\/code> \u043f\u043e 16 \u0431\u0430\u0439\u0442 \u0441 \u043a\u0440\u0430\u0451\u0432 \u043e\u0442\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u043d\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0435 \u0437\u0430\u0447\u0438\u0442\u0430\u0442\u044c \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u043d\u0430\u0440\u0443\u0436\u0438 \u0447\u0435\u0440\u0435\u0437 <code>buildinfo.Read<\/code> (<a href=\"https:\/\/pkg.go.dev\/debug\/buildinfo#Read\">https:\/\/pkg.go.dev\/debug\/buildinfo#Read<\/a>).<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c:<\/p>\n<pre><code class=\"bash\">bazel run --stamp \/\/example  Stamping example === Begin build info === gogo1.20.1 X:nocoverageredesign buildvcs.revision=f529d5877d4963ef5964363615b48cf066b8f1ef buildvcs.time=2023-01-01T00:00:00Z  === End build info === Found go build revision: f529d5877d4963ef5964363615b48cf066b8f1ef Found go build timestamp: 2023-01-01T00:00:00Z Found x_defs revision: f529d5877d4963ef5964363615b48cf066b8f1ef Found x_defs build timestamp: 2023-02-27T06:26:16Z<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u0430\u0436\u043d\u043e \u2013 \u0435\u0441\u043b\u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043e\u043c\u043c\u0438\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u0437\u0430\u0442\u0440\u0430\u0433\u0438\u0432\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u0443\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u0442\u043e \u043f\u0435\u0440\u0435\u0441\u0431\u043e\u0440\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442.<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f stamping \u0438 \u0440\u0443\u043a\u043e\u043f\u0438\u0441\u043d\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430<\/h3>\n<p><a href=\"https:\/\/github.com\/bozaro\/bazel-stamping\/tree\/custom\"><u>\u041f\u043e\u043b\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043d\u0430 Github<\/u><\/a>.<\/p>\n<h4>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0440\u0430\u0431\u043e\u0447\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e<\/h4>\n<p>\u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0443\u0441\u0442\u043e\u0439 \u0444\u0430\u0439\u043b <code>WORKSPACE<\/code> (\u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443 \u043d\u0430\u0441 \u043d\u0435\u0442 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439).<\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0432 \u0444\u0430\u0439\u043b <code>example\/stamping.sh<\/code>:<\/p>\n<pre><code class=\"bash\">#!\/bin\/sh echo \"STABLE_GIT_COMMIT $(git rev-parse HEAD)\" echo \"BUILD_TIME $(date --utc --iso-8601=seconds)\"<\/code><\/pre>\n<p>\u0418 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0441\u0431\u043e\u0440\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u0447\u0443\u0442\u044c \u043d\u0438\u0436\u0435 <code>BUILD<\/code>:<\/p>\n<pre><code class=\"python\">load(\"\/\/example:stamping.bzl\", \"stamping\")  stamping(     name = \"hello\",     src = \"hello_template.txt\",     out = \"hello.txt\", )<\/code><\/pre>\n<p>\u042d\u0442\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f stamping-\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0432 \u0448\u0430\u0431\u043b\u043e\u043d <code>hello_template.txt<\/code>:<\/p>\n<pre><code>This file was generated from {STABLE_GIT_COMMIT} revision at {BUILD_TIME}.<\/code><\/pre>\n<h4>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u0430 stamping<\/h4>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0432\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u043c \u043d\u0430 Python <code>example\/stamping.py<\/code>:<\/p>\n<pre><code class=\"python\">#!\/usr\/bin\/env python3 # -*- coding: utf8 -*- import argparse import re   def ParseStampFile(filename):     with open(filename, 'rb') as f:         return ParseStamp(f.read().decode('utf-8'))   def ParseStamp(data):     vars = dict()     for line in data.split(\"\\n\"):         sep = line.find(' ')         if sep >= 0:             vars[line[:sep]] = line[sep + 1:]     return vars   def main():     parser = argparse.ArgumentParser()     parser.add_argument(\"--stamp\", action='append', help='The stamp variables file')     parser.add_argument(\"--template\", help=\"Input file\", type=argparse.FileType('r'))     parser.add_argument(\"--output\", help=\"Output file\", type=argparse.FileType('w'))     args = parser.parse_args()      stamp = dict()     if args.stamp:         for stamp_file in args.stamp:             stamp.update(ParseStampFile(stamp_file))      template = args.template.read()     result = re.sub(r'\\{(\\w+)\\}', lambda m: stamp.get(m.group(1), m.group(0)), template)     args.output.write(result)   if __name__ == '__main__':     main()<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u0441\u043a\u0440\u0438\u043f\u0442:<\/p>\n<ul>\n<li>\n<p>\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0447\u0435\u0440\u0435\u0437 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0444\u0430\u0439\u043b \u0448\u0430\u0431\u043b\u043e\u043d\u0430, \u0444\u0430\u0439\u043b\u044b \u0441\u043e stamping-\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0438 \u0438\u043c\u044f \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430;<\/p>\n<\/li>\n<li>\n<p>\u0437\u0430\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 stamping-\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0432 dict;<\/p>\n<\/li>\n<li>\n<p>\u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442 \u0432 \u0448\u0430\u0431\u043b\u043e\u043d\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0447\u0435\u0440\u0435\u0437 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435;<\/p>\n<\/li>\n<li>\n<p>\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u0444\u0430\u0439\u043b.<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0438\u043a\u0430\u043a\u0438\u0445 python-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u043c\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e Python SDK \u043e\u043d \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442.<\/p>\n<h4>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 stamping<\/h4>\n<p>\u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 <code>stamping<\/code> \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0446\u0435\u043b\u0438 \u0432 <code>example\/BUILD<\/code>:<\/p>\n<pre><code class=\"python\">py_binary(     name = \"stamping\",     srcs = [\"stamping.py\"],     python_version = \"PY3\",     visibility = [\"\/\/visibility:public\"], )  config_setting(     name = \"stamp_detect\",     values = {\"stamp\": \"1\"},     visibility = [\"\/\/visibility:public\"], )<\/code><\/pre>\n<p>\u041e\u043d\u0438 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043d\u0430 Starlark \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b:<\/p>\n<ul>\n<li>\n<p><code>\/\/example:stamping<\/code> \u2013 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 <code>stamping.py<\/code>;<\/p>\n<\/li>\n<li>\n<p><code>\/\/example:stamp_detect<\/code> \u2013 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e bazel-\u0444\u043b\u0430\u0433\u0430 <code>--stamp<\/code> (<a href=\"https:\/\/bazel.build\/reference\/command-line-reference#flag--stamp\">https:\/\/bazel.build\/reference\/command-line-reference#flag&#8212;stamp<\/a>).<\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u0430\u043c\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u043d\u0430 Starlark <code>example\/stamping.bzl<\/code>:<\/p>\n<pre><code class=\"python\">def _stamping_impl(ctx):     args = ctx.actions.args()     args.add(\"--template\", ctx.file.src)     args.add(\"--output\", ctx.outputs.out)     inputs = [ctx.file.src]     if ctx.attr.private_stamp_detect:         args.add(\"--stamp\", ctx.version_file)  # volatile-status.txt         args.add(\"--stamp\", ctx.info_file)  # stable-status.txt         inputs += [             ctx.version_file,             ctx.info_file,         ]     ctx.actions.run(         mnemonic = \"Example\",         inputs = depset(inputs),\u043d         outputs = [ctx.outputs.out],         executable = ctx.executable._stamping_py,         arguments = [args],     )     return [         DefaultInfo(             files = depset([ctx.outputs.out]),         ),     ]  stamping_impl = rule(     implementation = _stamping_impl,     doc = \"Stamping rule example\",     attrs = {         \"src\": attr.label(mandatory = True, allow_single_file = True),         \"out\": attr.output(mandatory = True),         # Is --stamp set on the command line?         \"private_stamp_detect\": attr.bool(default = False),         \"_stamping_py\": attr.label(             default = Label(\"\/\/example:stamping\"),             cfg = \"exec\",             executable = True,             allow_files = True,         ),     }, )  def stamping(name, **kwargs):     stamping_impl(         name = name,         private_stamp_detect = select({             \"\/\/example:stamp_detect\": True,             \"\/\/conditions:default\": False,         }),         **kwargs     )<\/code><\/pre>\n<p>\u041d\u0430 \u0447\u0442\u043e \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435:<\/p>\n<ul>\n<li>\n<p>\u0432\u0441\u0435 stamping-\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0443\u0436\u0435 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u0430;<\/p>\n<\/li>\n<li>\n<p>\u0444\u0430\u0439\u043b\u044b <code>volatile-status.txt<\/code> \u0438 <code>stable-status.txt<\/code>, \u044f\u0432\u043d\u043e \u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u044e\u0442 \u043a\u0430\u043a \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430;<\/p>\n<\/li>\n<li>\n<p>\u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0444\u043b\u0430\u0433\u0430 <code>--stamp<\/code>, \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u0441\u0435\u0434\u0430\u043d\u0438\u044f \u0441 <code>config_setting<\/code>.<\/p>\n<\/li>\n<\/ul>\n<h4>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u0440\u0430\u0432\u0438\u043b\u0430<\/h4>\n<p>\u0414\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u044b:<\/p>\n<pre><code class=\"bash\">$ bazel build \/\/:hello &amp;&amp; cat bazel-bin\/hello.txt  This file was generated from {STABLE_GIT_COMMIT} revision at {BUILD_TIME}.  $ bazel build --stamp \/\/:hello &amp;&amp; cat bazel-bin\/hello.txt  This file was generated from 7b4e16010330195c58158e59d830ed9cfc789637 revision at 2023-02-27T10:03:58+00:00.<\/code><\/pre>\n<h2>Stamping-\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<\/h2>\n<p>\u041f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e stamping \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0440\u044f\u0434 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445:<\/p>\n<ul>\n<li>\n<p><code>BUILD_EMBED_LABEL<\/code> (stable) \u2013 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0444\u043b\u0430\u0433\u0430 <code>--embed_label=...<\/code>;<\/p>\n<\/li>\n<li>\n<p><code>BUILD_HOST<\/code> (stable) \u2013 \u0438\u043c\u044f \u0445\u043e\u0441\u0442\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0441\u0431\u043e\u0440\u043a\u0443;<\/p>\n<\/li>\n<li>\n<p><code>BUILD_USER<\/code> (stable) \u2013 \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043d\u0438\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u043b \u0441\u0431\u043e\u0440\u043a\u0443;<\/p>\n<\/li>\n<li>\n<p><code>BUILD_TIMESTAMP<\/code> (volatile) \u2013 unix time \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0431\u043e\u0440\u043a\u0438.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c, \u0432\u0430\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043d\u0430 \u0444\u0435\u0440\u043c\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u0447\u0430\u0441\u0442\u043e \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u043e\u043b\u044f <code>BUILD_HOST<\/code> \u0438 <code>BUILD_USER<\/code>, \u0438\u043d\u0430\u0447\u0435 \u0441\u043c\u0435\u043d\u0430 \u0445\u043e\u0441\u0442\u0430 \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u043e\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0441\u0431\u043e\u0440\u043a\u0443 \u0448\u0430\u0433\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e stamping.<\/p>\n<h2>Stamping \u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u043a\u044d\u0448\u0430<\/h2>\n<p>\u0412\u0430\u0436\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 stamping \u2013 \u043e\u043d \u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u043a\u044d\u0448\u0430.<\/p>\n<p>\u0423 Bazel \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u044d\u0448\u0435\u0439:<\/p>\n<ul>\n<li>\n<p>\u043a\u044d\u0448 \u0433\u0440\u0430\u0444\u0430 \u0446\u0435\u043b\u0435\u0439 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 Bazel-\u0434\u0435\u043c\u043e\u043d\u0430;<\/p>\n<\/li>\n<li>\n<p>\u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u044d\u0448 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 (<code>$(bazel info output_base)\/action_cache<\/code>);<\/p>\n<\/li>\n<li>\n<p>\u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u043a\u044d\u0448 \u043e\u043f\u0440\u0435\u0430\u0446\u0438\u0439 (<code>--disk_cache<\/code>, <code>--remote_cache<\/code>, \u0441\u0431\u043e\u0440\u043e\u0447\u043d\u0430\u044f \u0444\u0435\u0440\u043c\u0430 \u0438 \u0442.\u043f.).<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0443 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u043a\u044d\u0448\u0430 <strong>\u0440\u0430\u0437\u043d\u044b\u0439<\/strong> \u043a\u043b\u044e\u0447 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u0432\u043d\u0435\u0448\u043d\u0438\u043c \u043a\u044d\u0448\u0435\u043c \u0432 \u043a\u043b\u044e\u0447\u0435 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u044e\u0442 \u0432\u0441\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430, \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b (\u0434\u0435-\u0444\u0430\u043a\u0442\u043e \u043a\u043b\u044e\u0447 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u2013 \u044d\u0442\u043e \u0445\u044d\u0448 \u043e\u0442 protobuf-\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0448\u0430\u0433\u0430 \u0441\u0431\u043e\u0440\u043a\u0438). \u0424\u0430\u0439\u043b <code>bazel-out\/volatile-status.txt<\/code> \u0442\u0430\u043a \u0436\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0445\u043e\u0434\u043d\u044b\u043c \u0444\u0430\u0439\u043b\u043e\u043c \u0438 \u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0432\u043b\u0438\u044f\u0442\u044c \u043d\u0430 \u043a\u043b\u044e\u0447 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u043a\u044d\u0448\u0430 \u0438 stamping-\u0430, \u043c\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u044e\u0447 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f: \u043a\u0430\u0436\u0434\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441\u0431\u043e\u0440\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 stamping, \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u0434\u0451\u0442 \u043c\u0438\u043c\u043e \u043a\u044d\u0448\u0430.<\/p>\n<p>\u041a\u0440\u0430\u0439\u043d\u0435 \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u043e \u0442\u043e, \u0447\u0442\u043e \u043f\u0440\u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043f\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u0435 \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u044d\u0448 \u0438 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u0430\u043a, \u043a\u0430\u043a \u043d\u0443\u0436\u043d\u043e. \u0410 \u043f\u0440\u0438 \u0441\u0431\u043e\u0440\u043a\u0435 \u043d\u0430 \u0444\u0435\u0440\u043c\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0440\u0435\u0437\u043a\u043e \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u0441\u0431\u043e\u0440\u043a\u0443.<\/p>\n<h3>\u041a\u0430\u043a \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043b\u0438 stamping \u0438 remote cache?<\/h3>\n<p>\u0423\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u0438\u043b\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441\u043e stamping \u0438 remote cache \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c:<\/p>\n<ul>\n<li>\n<p>\u0421\u043e\u0431\u0440\u0430\u0442\u044c \u0444\u0430\u0439\u043b \u0441 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u043c <code>--disk_cache<\/code> \u0438 <code>--stamp<\/code>. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u0432 \u0434\u0438\u0441\u043a\u043e\u0432\u044b\u0439 \u043a\u044d\u0448.<br \/>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<br \/><code>bazel run --stamp --disk_cache=\/tmp\/bazel-disk-cache \/\/example<\/code><\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0431\u0440\u0430\u0442\u044c \u0444\u0430\u0439\u043b \u0441 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u043c <code>--disk_cache<\/code> \u0431\u0435\u0437 <code>--stamp<\/code>. \u042d\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0438\u043d\u0432\u0430\u043b\u0438\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u043a\u044d\u0448 Bazel.<br \/>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<br \/><code>bazel run --disk_cache=\/tmp\/bazel-disk-cache \/\/example<\/code><\/p>\n<\/li>\n<li>\n<p>\u0415\u0449\u0435 \u0440\u0430\u0437 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0444\u0430\u0439\u043b \u0441 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u043c <code>--disk_cache<\/code> \u0438 <code>--stamp<\/code>. \u042d\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u0441\u0431\u043e\u0440\u043a\u0438 \u0432\u0437\u044f\u0442\u044c \u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0438\u0437 \u0434\u0438\u0441\u043a\u043e\u0432\u043e\u0433\u043e \u043a\u044d\u0448\u0430.<br \/>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<br \/><code>bazel run --stamp --disk_cache=\/tmp\/bazel-disk-cache \/\/example<\/code><\/p>\n<\/li>\n<\/ul>\n<p>\u0415\u0441\u043b\u0438 \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0438 \u0442\u0440\u0435\u0442\u044c\u0435\u0433\u043e \u0448\u0430\u0433\u0430 \u0431\u0443\u0434\u0435\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u2013 \u0442\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 remote cache \u043d\u0435\u0442. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 (\u0441\u0435\u0439\u0447\u0430\u0441 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f Bazel 6.0.0) \u044d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a, \u0438 \u0442\u0440\u0435\u0442\u0438\u0439 \u0448\u0430\u0433 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e \u043f\u0435\u0440\u0435\u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0439 \u0444\u0430\u0439\u043b.<\/p>\n<h2>\u041a\u0430\u043a \u043f\u043e\u0434\u0440\u0443\u0436\u0438\u0442\u044c stamping \u0438 remote cache?<\/h2>\n<p>\u041d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443 \u0432 Bazel \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u043f\u043e\u0440\u0442\u043e\u0432:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/github.com\/bazelbuild\/bazel\/issues\/10075\">https:\/\/github.com\/bazelbuild\/bazel\/issues\/10075<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/bazelbuild\/bazel\/issues\/16231\">https:\/\/github.com\/bazelbuild\/bazel\/issues\/16231<\/a><\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u043e, \u043a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0432\u043d\u0435\u0441\u0435\u043d\u0438\u044f \u043f\u0440\u0430\u0432\u043e\u043a \u0432\u043e \u0432\u0441\u044e \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u0441\u0431\u043e\u0440\u043a\u0438:<\/p>\n<ul>\n<li>\n<p>\u043d\u0430\u0434\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c <a href=\"https:\/\/github.com\/bazelbuild\/remote-apis\">remote execution protocol<\/a>, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0442\u0443\u0434\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u043b\u0438\u044f\u0442\u044c \u043d\u0430 \u043a\u043b\u044e\u0447 \u043a\u044d\u0448\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f (\u0441\u0435\u0439\u0447\u0430\u0441 \u043a\u043b\u044e\u0447 \u043a\u044d\u0448\u0430 \u2013 \u0445\u044d\u0448 \u043e\u0442 \u0441\u0430\u043c\u043e\u0433\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u043e\u0439 \u0441\u0431\u043e\u0440\u043a\u0438);<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430\u0434\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 \u0432 bazel;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430\u0434\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 \u043d\u0430 \u0444\u0435\u0440\u043c\u0435.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u043a\u0430\u043a \u044f \u043f\u043e\u043d\u0438\u043c\u0430\u044e, \u0438\u0437-\u0437\u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043b\u0438\u0446, \u044d\u0442\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043d\u0435 \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043f\u0440\u043e\u0442\u044f\u0436\u0435\u043d\u0438\u0438 \u0443\u0436\u0435 \u0434\u0432\u0443\u0445 \u043b\u0435\u0442.<\/p>\n<h3>\u041c\u043e\u0436\u043d\u043e \u0432\u044b\u043d\u0435\u0441\u0442\u0438 stamping \u0432\u043e \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u0441\u0435\u0440\u0432\u0438\u0441<\/h3>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0431\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u043b\u043e\u0433\u0438\u043a\u0443 \u0448\u0430\u0433\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0435\u0433\u043e stamping, \u0432\u043e \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u0441\u0435\u0440\u0432\u0438\u0441.<\/p>\n<p>\u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u0438\u0434:<\/p>\n<ul>\n<li>\n<p>\u043d\u0430 \u0432\u0445\u043e\u0434 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c <code>volatile-status.txt<\/code> \u0438 \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u044b \u0434\u043b\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0448\u0430\u0433\u0430;<\/p>\n<\/li>\n<li>\n<p>\u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0445\u044d\u0448 \u043e\u0442 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0434\u043b\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0448\u0430\u0433\u0430 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 (\u043d\u0430\u0437\u043e\u0432\u0451\u043c \u0435\u0433\u043e <code>hash_id<\/code>);<\/p>\n<\/li>\n<li>\n<p>\u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0432\u043e \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 <code>volatile-status.txt<\/code> \u0438 <code>hash_id<\/code>, \u0430 \u044d\u0442\u043e\u0442 \u0441\u0435\u0440\u0432\u0438\u0441 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>volatile-status.txt<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d \u0432 \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e <code>hash_id<\/code>, \u043d\u0430\u0437\u043e\u0432\u0451\u043c \u0435\u0433\u043e <code>first-volatile-status.txt<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0448\u0430\u0433 \u0441 <code>first-volatile-status.txt<\/code> \u0432\u043c\u0435\u0441\u0442\u043e <code>volatile-status.txt<\/code>.<\/p>\n<\/li>\n<\/ul>\n<p>\u0423 \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u0435\u0441\u0442\u044c \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430: \u043e\u043d \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0432\u0441\u0435\u0445 \u043f\u0440\u0430\u0432\u0438\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 stamping. \u0415\u0441\u043b\u0438 \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u0438\u0437 \u043d\u0438\u0445 \u0437\u0430\u0431\u044b\u0442\u044c \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0438\u043b\u0438 \u043e\u0448\u0438\u0431\u0438\u0442\u044c\u0441\u044f \u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0442\u043e \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0430.<\/p>\n<h3>\u041c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0448\u0442\u043e\u043f\u0430\u0442\u044c Bazel<\/h3>\n<p>\u0415\u0449\u0435 \u043e\u0434\u0438\u043d \u0438\u0437 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u043e\u0431\u0445\u043e\u0434\u0430 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b: \u043f\u043e\u0434\u0448\u0442\u043e\u043f\u0430\u0442\u044c bazel, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043f\u0440\u0438 \u043f\u043e\u0434\u0441\u0447\u0435\u0442\u0435 \u043a\u044d\u0448\u0430 \u043d\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u043b volatile-\u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f stamping-\u0430.<\/p>\n<p>\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u044d\u0442\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043d\u0430 \u0444\u0435\u0440\u043c\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u043b\u044c\u0437\u044f, \u043d\u043e \u043d\u0438 \u0447\u0442\u043e \u043d\u0435 \u043c\u0435\u0448\u0430\u0435\u0442 \u0438\u0445 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e.<\/p>\n<p>\u0417\u0430\u043f\u043b\u0430\u0442\u043a\u0443 \u0441 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c Bazel \u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u0437\u0434\u0435\u0441\u044c:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/github.com\/bazelbuild\/bazel\/pull\/16240\">https:\/\/github.com\/bazelbuild\/bazel\/pull\/16240<\/a><\/p>\n<\/li>\n<\/ul>\n<p>\u042d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u0442\u043e \u0436\u0435 \u043d\u0435 \u0431\u0435\u0437 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0430: \u0443 bazel-\u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043f\u0440\u0430\u0432\u0430 \u0437\u0430\u043b\u0438\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043a\u044d\u0448 \u0441\u0431\u043e\u0440\u043a\u0438.<\/p>\n<p>\u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0431\u0435\u0437 \u043e\u0441\u043e\u0431\u044b\u0445 \u043d\u0430\u0440\u0435\u043a\u0430\u043d\u0438\u0439.<\/p>\n<h2>\u0418 \u044d\u0442\u043e \u0435\u0449\u0435 \u043d\u0435 \u0432\u0441\u0435!<\/h2>\n<p>\u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043f\u043e\u0441\u0442\u0435 \u043f\u0440\u043e Bazel \u043c\u044b \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u043c \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043c\u044b \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043b\u0438 stacktrace \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 CI \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u043a \u0443\u0434\u043e\u0431\u043d\u043e\u043c\u0443 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0432\u0438\u0434\u0443.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/720792\/\"> https:\/\/habr.com\/ru\/articles\/720792\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><\/figure>\n<h2>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 stamping?<\/h2>\n<p>\u0412 Bazel \u0435\u0441\u0442\u044c \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u0430\u044f \u0444\u0438\u0447\u0430, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0430\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0438\u043d\u0432\u0430\u043b\u0438\u0434\u0438\u0440\u0443\u044e\u0442 \u043a\u044d\u0448 \u0441\u0431\u043e\u0440\u043a\u0438.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u044d\u0442\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0439 \u0444\u0430\u0439\u043b \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0442\u043e\u043c, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d \u0431\u044b\u043b \u0441\u043e\u0431\u0440\u0430\u043d \u0438 \u0438\u0437 \u043a\u0430\u043a\u043e\u0439 \u0440\u0435\u0432\u0438\u0437\u0438\u0438. \u0415\u0441\u043b\u0438 \u0434\u043b\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438 \u043d\u043e\u043c\u0435\u0440\u0430 \u0440\u0435\u0432\u0438\u0437\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c stamping, \u0442\u043e, \u043a\u043e\u0433\u0434\u0430 \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0432 \u043a\u044d\u0448\u0435, \u043e\u043d \u043f\u0435\u0440\u0435\u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0431\u0443\u0434\u0435\u0442.<\/p>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<ul>\n<li>\n<p>\u043b\u044e\u0431\u043e\u0435 \u0437\u043d\u0430\u0447\u0438\u043c\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0441\u043e\u0431\u0435\u0440\u0435\u0442 \u0444\u0430\u0439\u043b \u0437\u0430\u043d\u043e\u0432\u043e;<\/p>\n<\/li>\n<li>\n<p>\u0432\u043d\u0443\u0442\u0440\u0438 \u0444\u0430\u0439\u043b\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u0430\u044f \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u0435\u0433\u043e \u043e\u0442\u043b\u0430\u0434\u043a\u043e\u0439 (\u0438\u0437 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u0440\u0435\u0432\u0438\u0437\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u044b\u0439 \u0444\u0430\u0439\u043b);<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u043b\u0438\u0448\u043d\u0435\u0439 \u043f\u0435\u0440\u0435\u0441\u0431\u043e\u0440\u043a\u0438 \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u043e\u043c\u043c\u0438\u0442 \u0438\u0437-\u0437\u0430 \u043d\u0435 \u0432\u043b\u0438\u044f\u044e\u0449\u0438\u0445 \u043d\u0430 \u043d\u0435\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u043e\u043c\u0435\u0440 \u0440\u0435\u0432\u0438\u0437\u0438\u0438 \u043d\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043f\u043e\u0438\u0441\u043a\u0435 \u0432 \u043a\u044d\u0448\u0435.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 GoLang, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u0432\u0435\u0440\u0441\u0438\u0438 1.18, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0440\u0435\u0432\u0438\u0437\u0438\u0438, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u044b\u043b \u0441\u043e\u0431\u0440\u0430\u043d \u0444\u0430\u0439\u043b, \u0447\u0435\u0440\u0435\u0437 <a href=\"https:\/\/pkg.go.dev\/runtime\/debug#ReadBuildInfo\"><u>debug.ReadBuildInfo<\/u><\/a>.<\/p>\n<h2>\u041a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c stamping?<\/h2>\n<h3>\u041e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0434\u043b\u044f stamping-\u0430<\/h3>\n<p>\u0414\u043b\u044f \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 stamping-\u0430 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0432\u0435\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0439 \u0444\u0430\u0439\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u0438\u0448\u0435\u0442 \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0432\u044b\u0432\u043e\u0434 \u043f\u0430\u0440\u044b \u043a\u043b\u044e\u0447-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u0431\u0435\u043b \u043f\u043e \u043e\u0434\u043d\u043e\u0439 \u043f\u0430\u0440\u0435 \u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0443.<\/p>\n<p>\u042d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0432 \u043a\u043e\u0440\u043d\u0435 \u0440\u0430\u0431\u043e\u0447\u0435\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"bash\">#!\/bin\/sh echo \"GIT_COMMIT $(git rev-parse HEAD)\" echo \"STABLE_GIT_URL $(git remote get-url origin)\" <\/code><\/pre>\n<p>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0441 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u043e\u043c <code>STABLE_<\/code> \u0431\u0443\u0434\u0443\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u043b\u044e\u0447\u0435 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>\u0423\u0447\u0430\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0432 \u043a\u043b\u044e\u0447\u0435 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043f\u043e\u043f\u0430\u0434\u0443\u0442 \u0432 \u0444\u0430\u0439\u043b <code>bazel-out\/stable-status.txt<\/code> , \u0430 \u043d\u0435 \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043f\u043e\u043f\u0430\u0434\u0443\u0442 \u0432 \u0444\u0430\u0439\u043b <code>bazel-out\/volatile-status.txt<\/code>.<\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b Bazel \u0437\u043d\u0430\u043b, \u0433\u0434\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0444\u0430\u0439\u043b, \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0449\u0438\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u0444\u0430\u0439\u043b \u043d\u0443\u0436\u043d\u043e \u0435\u043c\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043a\u043b\u044e\u0447 &#8212;workspace_status_command= (<a href=\"https:\/\/bazel.build\/reference\/command-line-reference#flag--workspace_status_command\">https:\/\/bazel.build\/reference\/command-line-reference#flag&#8212;workspace_status_command<\/a>).<\/p>\n<p>\u041b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u043e, \u043d\u043e \u043f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0430, \u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b, \u0447\u0442\u043e \u0441\u043a\u0440\u0438\u043f\u0442 \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u043d\u044b\u0439 \u0432 \u043a\u043e\u0440\u043d\u0435 \u0440\u0430\u0431\u043e\u0447\u0435\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430, \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<p>\u0423 \u043c\u043d\u043e\u0433\u0438\u0445 \u043f\u0440\u0430\u0432\u0438\u043b stamping \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u0441\u0431\u043e\u0440\u043a\u0435 \u0441 \u0444\u043b\u0430\u0433\u043e\u043c <code>--stamp<\/code>.<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f stamping \u0438 GoLang<\/h3>\n<p><a href=\"https:\/\/github.com\/bozaro\/bazel-stamping\/tree\/golang\"><u>\u041f\u043e\u043b\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043d\u0430 Github<\/u><\/a>.<\/p>\n<h4>\u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0431\u043e\u0447\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e Bazel \u0434\u043b\u044f GoLang<\/h4>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 GoLang \u0432 Bazel, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0440\u0438 \u0444\u0430\u0439\u043b\u0430.<\/p>\n<p>\u041f\u0443\u0441\u0442\u043e\u0439 \u0444\u0430\u0439\u043b <code>BUILD<\/code>.<\/p>\n<p>\u0424\u0430\u0439\u043b <code>WORKSPACE<\/code> (\u044d\u0442\u043e\u0442 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0432\u0437\u044f\u0442 <a href=\"https:\/\/github.com\/bazelbuild\/rules_go\/releases\/tag\/v0.38.1\"><u>\u0437\u0434\u0435\u0441\u044c<\/u><\/a>):<\/p>\n<pre><code class=\"python\">load(\"@bazel_tools\/\/tools\/build_defs\/repo:http.bzl\", \"http_archive\")  http_archive(     name = \"io_bazel_rules_go\",     sha256 = \"dd926a88a564a9246713a9c00b35315f54cbd46b31a26d5d8fb264c07045f05d\",     urls = [         \"https:\/\/mirror.bazel.build\/github.com\/bazelbuild\/rules_go\/releases\/download\/v0.38.1\/rules_go-v0.38.1.zip\",         \"https:\/\/github.com\/bazelbuild\/rules_go\/releases\/download\/v0.38.1\/rules_go-v0.38.1.zip\",     ], )  load(\"@io_bazel_rules_go\/\/go:deps.bzl\", \"go_register_toolchains\", \"go_rules_dependencies\")  go_rules_dependencies()  go_register_toolchains(version = \"1.20.1\")<\/code><\/pre>\n<p>\u0424\u0430\u0439\u043b <code>go.mod<\/code> \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0441 <code>go build<\/code>:<\/p>\n<pre><code class=\"go\">module github.com\/bozaro\/bazel-stamping go 1.19<\/code><\/pre>\n<h4>\u0421\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445<\/h4>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0441\u043a\u0440\u0438\u043f\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043b\u043e\u0436\u0438\u0442 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <code>GIT_COMMIT<\/code> \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u0440\u0435\u0432\u0438\u0437\u0438\u044e \u043a\u043e\u0434\u0430 <code>example\/stamping.sh<\/code>:<\/p>\n<pre><code class=\"bash\">#!\/bin\/sh echo \"GIT_COMMIT $(git rev-parse HEAD)\"<\/code><\/pre>\n<p>\u0418, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u043c\u044f \u044d\u0442\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0435 <code>bazel<\/code>, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0433\u043e \u0432 <code>.bazelrc<\/code>:<\/p>\n<pre><code>build --workspace_status_command=example\/stamping.sh<\/code><\/pre>\n<h4>\u0422\u0435\u0441\u0442\u043e\u0432\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430<\/h4>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u043b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0441\u0431\u043e\u0440\u043a\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 <code>example\/main.go<\/code>:<\/p>\n<pre><code class=\"go\">package main  import ( \"fmt\" \"runtime\/debug\" \"strconv\" \"time\" )  var gitCommit string var buildTimestamp string  func main() { fmt.Println(\"Stamping example\") if buildInfo, ok := debug.ReadBuildInfo(); ok { fmt.Println(\"=== Begin build info ===\") fmt.Println(buildInfo) fmt.Println(\"=== End build info ===\") for _, setting := range buildInfo.Settings { if setting.Key == \"vcs.revision\" { fmt.Println(\"Found go build revision:\", setting.Value) } if setting.Key == \"vcs.time\" { fmt.Println(\"Found go build timestamp:\", setting.Value) } } } if gitCommit != \"\" { fmt.Println(\"Found x_defs revision:\", gitCommit) } if buildTimestamp != \"\" { ts, _ := strconv.ParseInt(buildTimestamp, 10, 64) fmt.Println(\"Found x_defs build timestamp:\", time.Unix(ts, 0).UTC().Format(time.RFC3339Nano)) } }<\/code><\/pre>\n<p>\u042d\u0442\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0434\u0435\u043b\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<ul>\n<li>\n<p>\u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 <code>debug.ReadBuildInfo<\/code> \u043a\u0430\u043a \u0435\u0441\u0442\u044c;<\/p>\n<\/li>\n<li>\n<p>\u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <code>vcs.revision<\/code> \u0438 <code>vcs.time<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 <code>go build<\/code>, \u0435\u0441\u043b\u0438 \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f;<\/p>\n<\/li>\n<li>\n<p>\u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 <code>gitCommit<\/code> \u0438 <code>buildTimestamp<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432 \u043a\u043e\u0434\u0435 \u043d\u0438\u0433\u0434\u0435 \u043d\u0435 \u0437\u0430\u0434\u0430\u044e\u0442\u0441\u044f.<\/p>\n<\/li>\n<\/ul>\n<p>\u0415\u0441\u043b\u0438 \u044d\u0442\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 <code>go build . &amp;&amp; .\/example<\/code> \u0438\u043b\u0438, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 Go 1.20, \u0447\u0435\u0440\u0435\u0437 <code>go run -buildvcs=true .<\/code>, \u0442\u043e \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code>Stamping example === Begin build info === gogo1.20.1 pathgithub.com\/bozaro\/bazel-stamping\/example modgithub.com\/bozaro\/bazel-stamping(devel) build-buildmode=exe build-compiler=gc buildCGO_ENABLED=1 buildCGO_CFLAGS= buildCGO_CPPFLAGS= buildCGO_CXXFLAGS= buildCGO_LDFLAGS= buildGOARCH=amd64 buildGOOS=linux buildGOAMD64=v1 buildvcs=git buildvcs.revision=daa3fb74938a476db8bf4b295b01317226780a75 buildvcs.time=2023-02-10T17:03:08Z buildvcs.modified=true  === End build info === Found go build revision: daa3fb74938a476db8bf4b295b01317226780a75 Found go build timestamp: 2023-02-10T17:03:08Z<\/code><\/pre>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c, \u0432 <code>debug.ReadBuildInfo()<\/code> \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0438\u0437 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0440\u0430\u0431\u043e\u0447\u0435\u0439 \u043a\u043e\u043f\u0438\u0438 Git. <code>gitCommit<\/code> \u0438 <code>buildTimestamp<\/code> \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e \u043f\u0443\u0441\u0442\u044b.<\/p>\n<h4>\u0421\u0431\u043e\u0440\u043a\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/h4>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0441\u0431\u043e\u0440\u043a\u0438 .go-\u0444\u0430\u0439\u043b\u0430 \u0432 <code>example\/BUILD<\/code>:<\/p>\n<pre><code class=\"python\">load(\"@io_bazel_rules_go\/\/go:def.bzl\", \"go_binary\")  go_binary(     name = \"example\",     srcs = [\"main.go\"],     out = \"example\",     pure = \"on\",     visibility = [\"\/\/visibility:public\"],     x_defs = {         \"gitCommit\": \"{GIT_COMMIT}\",         \"buildTimestamp\": \"{BUILD_TIMESTAMP}\",         \"runtime.modinfo\": \"\\n\".join([             \"                \",             \"build\\tvcs.revision={GIT_COMMIT}\",             \"build\\tvcs.time=2023-01-01T00:00:00Z\",             \"                \",         ]),     }, )<\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0435 \u043f\u0440\u0438\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>x_defs<\/code>:<\/p>\n<ul>\n<li>\n<p>\u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <code>gitCommit<\/code> \u0437\u0430\u0434\u0430\u0451\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u0437 stamping-\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>GIT_COMMIT<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <code>buildTimestamp<\/code> \u0437\u0430\u0434\u0430\u0451\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u0437 stamping-\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>BUILD_TIMESTAMP<\/code>.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 <code>x_defs<\/code> \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0430 <code>go_binary<\/code>, \u043d\u043e \u0435\u0433\u043e \u0442\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 <code>go_library<\/code> \u0438 <code>go_test<\/code>.<\/p>\n<p>\u0414\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f <code>debug.ReadBuildInfo()<\/code> Bazel \u0441\u0430\u043c \u043d\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442, \u043d\u043e, \u0435\u0441\u043b\u0438 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0447\u0435\u0442\u0441\u044f, \u0442\u043e \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 <code>runtime.modinfo<\/code>.<\/p>\n<p>\u041f\u0440\u0430\u0432\u0434\u0430, \u0435\u0441\u0442\u044c \u0440\u044f\u0434 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439:<\/p>\n<ul>\n<li>\n<p>\u0432\u0435\u0440\u0441\u0438\u044f Go \u0436\u0438\u0432\u0451\u0442 \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u043c\u0438 <code>modinfo<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u0432 \u0441\u0430\u043c\u043e\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 <code>runtime.modinfo<\/code> \u043f\u043e 16 \u0431\u0430\u0439\u0442 \u0441 \u043a\u0440\u0430\u0451\u0432 \u043e\u0442\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u043d\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0435 \u0437\u0430\u0447\u0438\u0442\u0430\u0442\u044c \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u043d\u0430\u0440\u0443\u0436\u0438 \u0447\u0435\u0440\u0435\u0437 <code>buildinfo.Read<\/code> (<a href=\"https:\/\/pkg.go.dev\/debug\/buildinfo#Read\">https:\/\/pkg.go.dev\/debug\/buildinfo#Read<\/a>).<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c:<\/p>\n<pre><code class=\"bash\">bazel run --stamp \/\/example  Stamping example === Begin build info === gogo1.20.1 X:nocoverageredesign buildvcs.revision=f529d5877d4963ef5964363615b48cf066b8f1ef buildvcs.time=2023-01-01T00:00:00Z  === End build info === Found go build revision: f529d5877d4963ef5964363615b48cf066b8f1ef Found go build timestamp: 2023-01-01T00:00:00Z Found x_defs revision: f529d5877d4963ef5964363615b48cf066b8f1ef Found x_defs build timestamp: 2023-02-27T06:26:16Z<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u0430\u0436\u043d\u043e \u2013 \u0435\u0441\u043b\u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043e\u043c\u043c\u0438\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u0437\u0430\u0442\u0440\u0430\u0433\u0438\u0432\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u0443\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u0442\u043e \u043f\u0435\u0440\u0435\u0441\u0431\u043e\u0440\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442.<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f stamping \u0438 \u0440\u0443\u043a\u043e\u043f\u0438\u0441\u043d\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430<\/h3>\n<p><a href=\"https:\/\/github.com\/bozaro\/bazel-stamping\/tree\/custom\"><u>\u041f\u043e\u043b\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043d\u0430 Github<\/u><\/a>.<\/p>\n<h4>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0440\u0430\u0431\u043e\u0447\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e<\/h4>\n<p>\u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0443\u0441\u0442\u043e\u0439 \u0444\u0430\u0439\u043b <code>WORKSPACE<\/code> (\u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443 \u043d\u0430\u0441 \u043d\u0435\u0442 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439).<\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0432 \u0444\u0430\u0439\u043b <code>example\/stamping.sh<\/code>:<\/p>\n<pre><code class=\"bash\">#!\/bin\/sh echo \"STABLE_GIT_COMMIT $(git rev-parse HEAD)\" echo \"BUILD_TIME $(date --utc --iso-8601=seconds)\"<\/code><\/pre>\n<p>\u0418 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0441\u0431\u043e\u0440\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u0447\u0443\u0442\u044c \u043d\u0438\u0436\u0435 <code>BUILD<\/code>:<\/p>\n<pre><code class=\"python\">load(\"\/\/example:stamping.bzl\", \"stamping\")  stamping(     name = \"hello\",     src = \"hello_template.txt\",     out = \"hello.txt\", )<\/code><\/pre>\n<p>\u042d\u0442\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f stamping-\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0432 \u0448\u0430\u0431\u043b\u043e\u043d <code>hello_template.txt<\/code>:<\/p>\n<pre><code>This file was generated from {STABLE_GIT_COMMIT} revision at {BUILD_TIME}.<\/code><\/pre>\n<h4>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u0430 stamping<\/h4>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0432\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u043c \u043d\u0430 Python <code>example\/stamping.py<\/code>:<\/p>\n<pre><code class=\"python\">#!\/usr\/bin\/env python3 # -*- coding: utf8 -*- import argparse import re   def ParseStampFile(filename):     with open(filename, 'rb') as f:         return ParseStamp(f.read().decode('utf-8'))   def ParseStamp(data):     vars = dict()     for line in data.split(\"\\n\"):         sep = line.find(' ')         if sep >= 0:             vars[line[:sep]] = line[sep + 1:]     return vars   def main():     parser = argparse.ArgumentParser()     parser.add_argument(\"--stamp\", action='append', help='The stamp variables file')     parser.add_argument(\"--template\", help=\"Input file\", type=argparse.FileType('r'))     parser.add_argument(\"--output\", help=\"Output file\", type=argparse.FileType('w'))     args = parser.parse_args()      stamp = dict()     if args.stamp:         for stamp_file in args.stamp:             stamp.update(ParseStampFile(stamp_file))      template = args.template.read()     result = re.sub(r'\\{(\\w+)\\}', lambda m: stamp.get(m.group(1), m.group(0)), template)     args.output.write(result)   if __name__ == '__main__':     main()<\/code><\/pre>\n<p>\u042d\u0442\u043e\u0442 \u0441\u043a\u0440\u0438\u043f\u0442:<\/p>\n<ul>\n<li>\n<p>\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0447\u0435\u0440\u0435\u0437 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0444\u0430\u0439\u043b \u0448\u0430\u0431\u043b\u043e\u043d\u0430, \u0444\u0430\u0439\u043b\u044b \u0441\u043e stamping-\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0438 \u0438\u043c\u044f \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430;<\/p>\n<\/li>\n<li>\n<p>\u0437\u0430\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 stamping-\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0432 dict;<\/p>\n<\/li>\n<li>\n<p>\u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442 \u0432 \u0448\u0430\u0431\u043b\u043e\u043d\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0447\u0435\u0440\u0435\u0437 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435;<\/p>\n<\/li>\n<li>\n<p>\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u0444\u0430\u0439\u043b.<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0438\u043a\u0430\u043a\u0438\u0445 python-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u043c\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e Python SDK \u043e\u043d \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442.<\/p>\n<h4>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 stamping<\/h4>\n<p>\u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 <code>stamping<\/code> \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0446\u0435\u043b\u0438 \u0432 <code>example\/BUILD<\/code>:<\/p>\n<pre><code class=\"python\">py_binary(     name = \"stamping\",     srcs = [\"stamping.py\"],     python_version = \"PY3\",     visibility = [\"\/\/visibility:public\"], )  config_setting(     name = \"stamp_detect\",     values = {\"stamp\": \"1\"},     visibility = [\"\/\/visibility:public\"], )<\/code><\/pre>\n<p>\u041e\u043d\u0438 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043d\u0430 Starlark \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b:<\/p>\n<ul>\n<li>\n<p><code>\/\/example:stamping<\/code> \u2013 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 <code>stamping.py<\/code>;<\/p>\n<\/li>\n<li>\n<p><code>\/\/example:stamp_detect<\/code> \u2013 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e bazel-\u0444\u043b\u0430\u0433\u0430 <code>--stamp<\/code> (<a href=\"https:\/\/bazel.build\/reference\/command-line-reference#flag--stamp\">https:\/\/bazel.build\/reference\/command-lin<\/a><\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-392457","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/392457","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=392457"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/392457\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=392457"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=392457"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=392457"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}