Skip to content

Commit 776770e

Browse files
committed
Update font version on CI
1 parent d172396 commit 776770e

File tree

3 files changed

+34
-19
lines changed

3 files changed

+34
-19
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
steps:
77
- uses: actions/checkout@v2
88
- run: echo ${GITHUB_REF#refs/heads/}
9-
- run: echo "version=$(git rev-parse --short $GITHUB_SHA)" >> $GITHUB_ENV
9+
- run: echo "version=$(./script/update_version.py)" >> $GITHUB_ENV
1010
- run: ./script/build.sh
1111
- uses: actions/upload-artifact@v2
1212
with:

script/update_version.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#! /usr/bin/env python3
2+
3+
import os, re, subprocess, sys
4+
5+
def version():
6+
desc = subprocess.check_output(["git", "describe", "--tags"], cwd = os.path.dirname(__file__)).decode("utf-8")
7+
match = re.match(r"([0-9]+)\.([0-9]+)-([0-9]+)-([a-z0-9]+)", desc)
8+
if match:
9+
major = int(match.group(1))
10+
minor = int(match.group(2)) + int(match.group(3))
11+
sha = match.group(4)
12+
return (major, minor, sha)
13+
else:
14+
raise Exception("Can’t parse version from: " + desc)
15+
16+
def update_version(major, minor, src, dst):
17+
with open(src, 'r') as f:
18+
contents = f.read()
19+
contents = re.sub(r"versionMajor\s+=\s+\d+;",
20+
f"versionMajor = {major};",
21+
contents)
22+
contents = re.sub(r"versionMinor\s+=\s+\d+;",
23+
f"versionMinor = {minor};",
24+
contents)
25+
with open(dst, 'w') as f:
26+
f.write(contents)
27+
28+
if __name__ == '__main__':
29+
os.chdir(os.path.abspath(os.path.dirname(__file__) + '/..'))
30+
(major, minor, sha) = version()
31+
update_version(major, minor, 'FiraCode.glyphs', 'FiraCode.glyphs')
32+
print(f"{major}.{minor}-{sha}")
33+
sys.exit(0)

script/version.py

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)