From 9f20c126a2d03dcc333a91c58e6b1f8e45654cfc Mon Sep 17 00:00:00 2001 From: lucas lelievre Date: Sat, 16 Nov 2024 22:02:30 +0100 Subject: [PATCH] CI: Actually working firmware version detection (#365) * Fix firmware version detection * Fix ci * remove release workflow --- .github/workflows/actions.yml | 23 ++++++++++++++--------- .github/workflows/release.yml | 20 -------------------- scripts/get_git_commit.py | 16 +++++----------- 3 files changed, 19 insertions(+), 40 deletions(-) delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 03f844834..6dbc0ccef 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -4,6 +4,8 @@ on: push: branches: - main + tags: + - "*" pull_request: workflow_dispatch: create: @@ -17,15 +19,15 @@ jobs: with: clang-format-version: "17" fallback-style: google -# Disable clang-tidy for now -# - name: Get clang-tidy -# run: | -# apt-get update -# apt-get install -y clang-tidy -# - uses: ZehMatt/clang-tidy-annotations@v1.0.0 -# with: -# build_dir: 'build' -# cmake_args: '-G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++' + # Disable clang-tidy for now + # - name: Get clang-tidy + # run: | + # apt-get update + # apt-get install -y clang-tidy + # - uses: ZehMatt/clang-tidy-annotations@v1.0.0 + # with: + # build_dir: 'build' + # cmake_args: '-G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++' build: runs-on: ubuntu-20.04 @@ -39,6 +41,9 @@ jobs: ~/.platformio/.cache key: ${{ runner.os }}-pio + - name: Get tags + run: git fetch --tags origin --recurse-submodules=no --force + - name: Set up Python uses: actions/setup-python@v5 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 553f1b86d..000000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Releases - -on: - push: - tags: - - '*' - -jobs: - - build: - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - uses: actions/checkout@v4 - - uses: ncipollo/release-action@v1 - with: - artifacts: "./build/*.bin" - draft: true - token: ${{ secrets.GITHUB_TOKEN }} diff --git a/scripts/get_git_commit.py b/scripts/get_git_commit.py index 3e0179222..d78073695 100644 --- a/scripts/get_git_commit.py +++ b/scripts/get_git_commit.py @@ -18,13 +18,7 @@ tag = "" try: - tag = ( - subprocess.check_output(["git", "--no-pager", "tag", "--sort", "-taggerdate", "--points-at" , "HEAD"]) - .split("\n")[0] - .strip() - .decode("utf-8") - ) - + tag = subprocess.check_output(["git", "--no-pager", "tag", "--sort", "-taggerdate", "--points-at" , "HEAD"]).strip().decode("utf-8") if tag.startswith("v"): tag = tag[1:] except Exception: @@ -40,13 +34,13 @@ except Exception: branch = "" -output = f"'-DGIT_REV=\"{revision}\"'" +output = f"-DGIT_REV='\"{revision}\"'" if tag != "": - output += f" '-DFIRMWARE_VERSION=\"{tag}\"'" + output += f" -DFIRMWARE_VERSION='\"{tag}\"'" elif branch != "": - output += f" '-DFIRMWARE_VERSION=\"{branch}\"'" + output += f" -DFIRMWARE_VERSION='\"{branch}\"'" else: - output += f" '-DFIRMWARE_VERSION=\"git-{revision}\"'" + output += f" -DFIRMWARE_VERSION='\"git-{revision}\"'" print(output)