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.
This commit is contained in:
Jeff Epler 2021-12-29 14:33:45 -06:00
parent cd7e879f30
commit 23022a5a7f
No known key found for this signature in database
GPG Key ID: D5BF15AB975AB4DE
6 changed files with 25 additions and 20 deletions

View File

@ -38,8 +38,8 @@ jobs:
run: python tools/ci_fetch_deps.py test ${{ github.sha }} run: python tools/ci_fetch_deps.py test ${{ github.sha }}
- name: CircuitPython version - name: CircuitPython version
run: | run: |
git describe --dirty --tags || git log --parents HEAD~4.. tools/describe || git log --parents HEAD~4..
echo >>$GITHUB_ENV CP_VERSION=$(git describe --dirty --tags) echo >>$GITHUB_ENV CP_VERSION=$(tools/describe)
- name: Install dependencies - name: Install dependencies
run: | run: |
sudo apt-get update sudo apt-get update
@ -144,8 +144,8 @@ jobs:
run: python tools/ci_fetch_deps.py mpy-cross-mac ${{ github.sha }} run: python tools/ci_fetch_deps.py mpy-cross-mac ${{ github.sha }}
- name: CircuitPython version - name: CircuitPython version
run: | run: |
git describe --dirty --tags tools/describe || git log --parents HEAD~4..
echo >>$GITHUB_ENV CP_VERSION=$(git describe --dirty --tags) echo >>$GITHUB_ENV CP_VERSION=$(tools/describe)
- name: Install dependencies - name: Install dependencies
run: | run: |
brew install gettext brew install gettext
@ -200,8 +200,8 @@ jobs:
run: python tools/ci_fetch_deps.py docs ${{ github.sha }} run: python tools/ci_fetch_deps.py docs ${{ github.sha }}
- name: CircuitPython version - name: CircuitPython version
run: | run: |
git describe --dirty --tags tools/describe || git log --parents HEAD~4..
echo >>$GITHUB_ENV CP_VERSION=$(git describe --dirty --tags) echo >>$GITHUB_ENV CP_VERSION=$(tools/describe)
- name: Set up Python 3 - name: Set up Python 3
uses: actions/setup-python@v2 uses: actions/setup-python@v2
with: with:
@ -375,7 +375,9 @@ jobs:
- name: Get CP deps - name: Get CP deps
run: python tools/ci_fetch_deps.py ${{ matrix.board }} ${{ github.sha }} run: python tools/ci_fetch_deps.py ${{ matrix.board }} ${{ github.sha }}
- name: CircuitPython version - name: CircuitPython version
run: git describe --dirty --tags run: |
tools/describe || git log --parents HEAD~4..
echo >>$GITHUB_ENV CP_VERSION=$(tools/describe)
- uses: actions/cache@v2 - uses: actions/cache@v2
name: Fetch IDF tool cache name: Fetch IDF tool cache
id: idf-cache id: idf-cache

View File

@ -34,7 +34,9 @@ jobs:
gcc --version gcc --version
python3 --version python3 --version
- name: CircuitPython version - name: CircuitPython version
run: git describe --dirty --tags run: |
tools/describe || git log --parents HEAD~4..
echo >>$GITHUB_ENV CP_VERSION=$(tools/describe)
- name: Website - name: Website
run: python3 build_board_info.py run: python3 build_board_info.py
working-directory: tools working-directory: tools

View File

@ -73,8 +73,8 @@ jobs:
run: python tools/ci_fetch_deps.py windows ${{ github.sha }} run: python tools/ci_fetch_deps.py windows ${{ github.sha }}
- name: CircuitPython version - name: CircuitPython version
run: | run: |
git describe --dirty --tags tools/describe || git log --parents HEAD~4..
echo >>$GITHUB_ENV CP_VERSION=$(git describe --dirty --tags) echo >>$GITHUB_ENV CP_VERSION=$(tools/describe)
- name: build mpy-cross - name: build mpy-cross
run: make -j2 -C mpy-cross run: make -j2 -C mpy-cross

View File

@ -24,12 +24,15 @@ import subprocess
import sys import sys
import urllib.parse import urllib.parse
import time import time
import pathlib
from collections import defaultdict from collections import defaultdict
from sphinx.transforms import SphinxTransform from sphinx.transforms import SphinxTransform
from docutils import nodes from docutils import nodes
from sphinx import addnodes from sphinx import addnodes
tools_describe = (pathlib.Path(__file__).parent / "tools/describe").str()
# If extensions (or modules to document with autodoc) are in another directory, # If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the # add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here. # documentation root, use os.path.abspath to make it absolute, like shown here.
@ -129,7 +132,7 @@ copyright = f'2014-{current_date.tm_year}, MicroPython & CircuitPython contribut
final_version = "" final_version = ""
git_describe = subprocess.run( git_describe = subprocess.run(
["git", "describe", "--dirty", "--tags"], [tools_describe],
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, stderr=subprocess.STDOUT,
encoding="utf-8" encoding="utf-8"

View File

@ -1,29 +1,25 @@
""" """
Generate header file with macros defining MicroPython version info. Generate header file with macros defining MicroPython version info.
This script works with Python 2.6, 2.7, 3.3 and 3.4. This script works with Python 3.7 and newer
""" """
from __future__ import print_function from __future__ import print_function
import sys import sys
import os import os
import pathlib
import datetime import datetime
import subprocess import subprocess
tools_describe = str(pathlib.Path(__file__).parent.parent / "tools/describe")
def get_version_info_from_git(): def get_version_info_from_git():
# Python 2.6 doesn't have check_output, so check for that
try:
subprocess.check_output
subprocess.check_call
except AttributeError:
return None
# Note: git describe doesn't work if no tag is available # Note: git describe doesn't work if no tag is available
try: try:
git_tag = subprocess.check_output( git_tag = subprocess.check_output(
["git", "describe", "--tags", "--dirty", "--always", "--match", "[1-9].*"], [tools_describe],
stderr=subprocess.STDOUT, stderr=subprocess.STDOUT,
universal_newlines=True, universal_newlines=True,
).strip() ).strip()

2
tools/describe Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
git describe --dirty --tags --always --match "[1-9].*"