Skip to content

Commit

Permalink
github: use CI build number as git tag
Browse files Browse the repository at this point in the history
This fixes dirty builds changing reported firmware size on CI and allows
verifying the build number of a firmware at runtime. It uses a new
feature in the MicroPython 1.20 makeversionheader.py script that looks
at environment variables to override the versions instead of using
`git describe`.

Fixes: https://github.com/pybricks/pybricks-micropython/issues/123
  • Loading branch information
dlech committed May 2, 2023
1 parent 01e9242 commit a044e59
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/build-each-commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@

PYBRICKS_PATH = os.environ.get("PYBRICKS_PATH", ".")

GITHUB_RUN_NUMBER = os.environ.get("GITHUB_RUN_NUMBER")

if GITHUB_RUN_NUMBER:
os.putenv("MICROPY_GIT_TAG", f"ci-build-{GITHUB_RUN_NUMBER}")


parser = argparse.ArgumentParser()
parser.add_argument("hub", metavar="<hub>")
Expand Down Expand Up @@ -45,6 +50,7 @@
):
print("Checking out", commit.hexsha[:8], f'"{commit.summary}"', flush=True)
pybricks.git.checkout(commit.hexsha)
os.putenv("MICROPY_GIT_HASH", commit.hexsha[:8])

# update only required submodules
pybricks.git.submodule("update", "--init", "micropython")
Expand Down
6 changes: 6 additions & 0 deletions .github/build-missing-commits.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@

HUBS = ["movehub", "cityhub", "technichub", "primehub", "essentialhub", "nxt"]

GITHUB_RUN_NUMBER = os.environ.get("GITHUB_RUN_NUMBER")

if GITHUB_RUN_NUMBER:
os.putenv("MICROPY_GIT_TAG", f"ci-build-{GITHUB_RUN_NUMBER}")

print("Building commits...")

try:
Expand Down Expand Up @@ -66,6 +71,7 @@
# Checkout the Pybricks MicroPython commit for processing
print("Checking out:", commit.hexsha)
pybricks.git.checkout(commit.hexsha)
os.putenv("MICROPY_GIT_HASH", commit.hexsha[:8])

# update required submodules
print("Checking out submodules")
Expand Down

0 comments on commit a044e59

Please sign in to comment.