Skip to content

Commit 23022a5

Browse files
committed
Add, use tools/describe script
This isn't intended to make any overt behavioral change, but there is a slight one in the value of CP_VERSION that will be used during CI, because it will now include `--always --match "..."`, so there could be a change to the uploaded name of the mpy-cross artifacts on s3.
1 parent cd7e879 commit 23022a5

File tree

6 files changed

+25
-20
lines changed

6 files changed

+25
-20
lines changed

.github/workflows/build.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ jobs:
3838
run: python tools/ci_fetch_deps.py test ${{ github.sha }}
3939
- name: CircuitPython version
4040
run: |
41-
git describe --dirty --tags || git log --parents HEAD~4..
42-
echo >>$GITHUB_ENV CP_VERSION=$(git describe --dirty --tags)
41+
tools/describe || git log --parents HEAD~4..
42+
echo >>$GITHUB_ENV CP_VERSION=$(tools/describe)
4343
- name: Install dependencies
4444
run: |
4545
sudo apt-get update
@@ -144,8 +144,8 @@ jobs:
144144
run: python tools/ci_fetch_deps.py mpy-cross-mac ${{ github.sha }}
145145
- name: CircuitPython version
146146
run: |
147-
git describe --dirty --tags
148-
echo >>$GITHUB_ENV CP_VERSION=$(git describe --dirty --tags)
147+
tools/describe || git log --parents HEAD~4..
148+
echo >>$GITHUB_ENV CP_VERSION=$(tools/describe)
149149
- name: Install dependencies
150150
run: |
151151
brew install gettext
@@ -200,8 +200,8 @@ jobs:
200200
run: python tools/ci_fetch_deps.py docs ${{ github.sha }}
201201
- name: CircuitPython version
202202
run: |
203-
git describe --dirty --tags
204-
echo >>$GITHUB_ENV CP_VERSION=$(git describe --dirty --tags)
203+
tools/describe || git log --parents HEAD~4..
204+
echo >>$GITHUB_ENV CP_VERSION=$(tools/describe)
205205
- name: Set up Python 3
206206
uses: actions/setup-python@v2
207207
with:
@@ -375,7 +375,9 @@ jobs:
375375
- name: Get CP deps
376376
run: python tools/ci_fetch_deps.py ${{ matrix.board }} ${{ github.sha }}
377377
- name: CircuitPython version
378-
run: git describe --dirty --tags
378+
run: |
379+
tools/describe || git log --parents HEAD~4..
380+
echo >>$GITHUB_ENV CP_VERSION=$(tools/describe)
379381
- uses: actions/cache@v2
380382
name: Fetch IDF tool cache
381383
id: idf-cache

.github/workflows/create_website_pr.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ jobs:
3434
gcc --version
3535
python3 --version
3636
- name: CircuitPython version
37-
run: git describe --dirty --tags
37+
run: |
38+
tools/describe || git log --parents HEAD~4..
39+
echo >>$GITHUB_ENV CP_VERSION=$(tools/describe)
3840
- name: Website
3941
run: python3 build_board_info.py
4042
working-directory: tools

.github/workflows/ports_windows.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ jobs:
7373
run: python tools/ci_fetch_deps.py windows ${{ github.sha }}
7474
- name: CircuitPython version
7575
run: |
76-
git describe --dirty --tags
77-
echo >>$GITHUB_ENV CP_VERSION=$(git describe --dirty --tags)
76+
tools/describe || git log --parents HEAD~4..
77+
echo >>$GITHUB_ENV CP_VERSION=$(tools/describe)
7878
7979
- name: build mpy-cross
8080
run: make -j2 -C mpy-cross

conf.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,15 @@
2424
import sys
2525
import urllib.parse
2626
import time
27+
import pathlib
2728
from collections import defaultdict
2829

2930
from sphinx.transforms import SphinxTransform
3031
from docutils import nodes
3132
from sphinx import addnodes
3233

34+
tools_describe = (pathlib.Path(__file__).parent / "tools/describe").str()
35+
3336
# If extensions (or modules to document with autodoc) are in another directory,
3437
# add these directories to sys.path here. If the directory is relative to the
3538
# documentation root, use os.path.abspath to make it absolute, like shown here.
@@ -129,7 +132,7 @@ def autoapi_prepare_jinja_env(jinja_env):
129132

130133
final_version = ""
131134
git_describe = subprocess.run(
132-
["git", "describe", "--dirty", "--tags"],
135+
[tools_describe],
133136
stdout=subprocess.PIPE,
134137
stderr=subprocess.STDOUT,
135138
encoding="utf-8"

py/makeversionhdr.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,25 @@
11
"""
22
Generate header file with macros defining MicroPython version info.
33
4-
This script works with Python 2.6, 2.7, 3.3 and 3.4.
4+
This script works with Python 3.7 and newer
55
"""
66

77
from __future__ import print_function
88

99
import sys
1010
import os
11+
import pathlib
1112
import datetime
1213
import subprocess
1314

15+
tools_describe = str(pathlib.Path(__file__).parent.parent / "tools/describe")
1416

15-
def get_version_info_from_git():
16-
# Python 2.6 doesn't have check_output, so check for that
17-
try:
18-
subprocess.check_output
19-
subprocess.check_call
20-
except AttributeError:
21-
return None
2217

18+
def get_version_info_from_git():
2319
# Note: git describe doesn't work if no tag is available
2420
try:
2521
git_tag = subprocess.check_output(
26-
["git", "describe", "--tags", "--dirty", "--always", "--match", "[1-9].*"],
22+
[tools_describe],
2723
stderr=subprocess.STDOUT,
2824
universal_newlines=True,
2925
).strip()

tools/describe

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
git describe --dirty --tags --always --match "[1-9].*"

0 commit comments

Comments
 (0)