From 4b0f966fb4fc629d42147c784343094be78863c6 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sat, 2 Dec 2023 13:08:39 -0700 Subject: fetch tags on CI checkout, so 'git describe' can work --- .github/workflows/compile.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index 893eb41..e695a3a 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -14,6 +14,9 @@ jobs: - name: Checkout uses: actions/checkout@master + # allow 'git describe' to work, by fetching tags + with: + fetch-tags: true - name: Stop committing version.h # reject commit if version.h was changed -- cgit v1.2.3 From 1ca7e77cec953cb4cce5868336c24042ec3cf800 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sat, 2 Dec 2023 13:09:08 -0700 Subject: run CI on all branches, not just on trunk --- .github/workflows/compile.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index e695a3a..3f03c40 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -1,10 +1,13 @@ name: build all on: - push: - branches: [ "trunk" ] - pull_request: - branches: [ "trunk" ] + # all branches: + [ push, pull_request ] + # trunk only: + #push: + # branches: [ "trunk" ] + #pull_request: + # branches: [ "trunk" ] jobs: compile: -- cgit v1.2.3 From dcbacb61bb3e04872927008a394524ed9208c740 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sat, 2 Dec 2023 13:30:42 -0700 Subject: build-all: handle the case where "git describe" can't get any tags Resulting revision is "$MODEL-0.$HASH" where the hash is the commit short ID --- bin/build-all.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bin/build-all.sh b/bin/build-all.sh index 444809e..f239217 100755 --- a/bin/build-all.sh +++ b/bin/build-all.sh @@ -88,6 +88,11 @@ function make-version-h { # strip rev hash (git won't give "commits since tag" without the rev hash) REV="${REV/-g[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]/}" REV="${REV/-dirty/.1}" # convert '-dirty' to '.1' + # handle an empty name (happens during github action runs) + if [[ -z "$REV" ]]; then + HASH=$(git describe --always) + REV="0.$HASH" + fi # save the version name to version.h mkdir -p ".build/$UI" echo '#define VERSION_NUMBER "'"$REV"'"' > ".build/$UI/version.h" -- cgit v1.2.3 From 73d1f3e156296642bdc35aed2ffa16458e321d2d Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sat, 2 Dec 2023 13:35:59 -0700 Subject: github CI: fetch history too, to allow detection of version tags It needs history to determine which tag precedes the current commit. This could be expensive on large repos, but for Anduril it seems to only increase the checkout size by about 40% or so. (11 MiB -> 15 MiB) --- .github/workflows/compile.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index 3f03c40..2ba771f 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -17,8 +17,9 @@ jobs: - name: Checkout uses: actions/checkout@master - # allow 'git describe' to work, by fetching tags + # allow 'git describe' to work, by fetching tags and history with: + fetch-depth: 0 fetch-tags: true - name: Stop committing version.h -- cgit v1.2.3