...
1#!/usr/bin/env python
2
3from __future__ import print_function, unicode_literals
4from subprocess import Popen, PIPE
5from sys import exit
6
7
8def run(*cmd):
9 process = Popen(cmd, stdout=PIPE)
10 output, err = process.communicate()
11 if process.wait():
12 exit(1)
13 return output.strip().decode()
14
15
16def main():
17 tags = run("git", "describe", "--tags")
18 version = tags.lstrip('v')
19 print("STABLE_buildVersion", version)
20
21 # rules_nodejs expects to read from volatile-status.txt
22 print("BUILD_SCM_VERSION", version)
23
24 revision = run("git", "rev-parse", "HEAD")
25 print("STABLE_buildScmRevision", revision)
26
27
28if __name__ == "__main__":
29 main()
View as plain text