From bcbd174512ec45acd0b7708862415be24ce1b26b Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Sat, 26 Mar 2022 23:26:42 +0100 Subject: [PATCH] update build action --- .github/workflows/build_check.yml | 6 ++++- .github/workflows/release.yml | 45 +++++++++---------------------- scripts/create_version_tag.py | 21 +++++++++++++++ 3 files changed, 38 insertions(+), 34 deletions(-) create mode 100755 scripts/create_version_tag.py diff --git a/.github/workflows/build_check.yml b/.github/workflows/build_check.yml index 3694829..efa3945 100644 --- a/.github/workflows/build_check.yml +++ b/.github/workflows/build_check.yml @@ -1,6 +1,10 @@ name: Integreation Tests -on: [push, pull_request] +on: + push: + branches: + - '*' + - '!master' jobs: version_check: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1ccc28a..a1e50e4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,46 +1,25 @@ +name: Upload Release Assets + on: push: - tags: - - 'v*' - -name: Upload Release Assets + branches: + - 'master' jobs: build: name: Upload Release Assets runs-on: ubuntu-latest steps: + - uses: actions/checkout@v2 - run: sudo apt-get install python3-setuptools python3-wheel - run: pip3 install platformio - run: echo "$HOME/.local/bin" >> $GITHUB_PATH - - uses: actions/checkout@v2 - with: - submodules: 'recursive' - run: platformio run - - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - run: echo "VERSION=$(echo ./scripts/create_version_tag.py)" >> $GITHUB_ENV + - uses: ncipollo/release-action@v1 with: - tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} - draft: false - prerelease: false - # upload firmware bin - - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: .pio/build/lora_board/firmware.bin - asset_name: lora_board.bin - asset_content_type: application/bin - # upload json file - - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: data/is-cfg.json - asset_name: is-cfg.json - asset_content_type: application/json \ No newline at end of file + tag: ${{ env.VERSION }} + commit: Release ${{ env.VERSION }} + generateReleaseNotes: true + artifacts: ".pio/build/lora_board/firmware.bin,data/is-cfg.json" + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/scripts/create_version_tag.py b/scripts/create_version_tag.py new file mode 100755 index 0000000..5b37c82 --- /dev/null +++ b/scripts/create_version_tag.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 + +from datetime import date + +today = date.today() + +current_year = int(str(today.isocalendar()[0])[2:]) +current_week = int(today.isocalendar()[1]) + +version = None +with open("src/LoRa_APRS_iGate.cpp") as f: + for line in f: + if line.startswith("#define VERSION"): + version = line.strip().split(" ")[-1].replace('"', "") + +version_split = version.split(".") +version_year = int(version_split[0]) +version_week = int(version_split[1]) +version_vers = int(version_split[2]) + +print(f"v{version_year}.{version_week}.{version_vers}")