From 64df6854f2dd5f25f3e5bbe19f4107d7ab84cd4d Mon Sep 17 00:00:00 2001 From: mate <67105053+mate-dev@users.noreply.github.com> Date: Thu, 14 Dec 2023 13:42:23 +0100 Subject: [PATCH] Update main.yml --- .github/workflows/main.yml | 53 ++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 13 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0f2889e..80e870d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,27 +14,42 @@ jobs: - name: Set up Python 3 uses: actions/setup-python@v2 with: - python-version: 3.x + python-version: '3.x' - name: Install dependencies run: | sudo apt-get update - sudo apt-get -y install wget g++ zip ca-certificates + sudo apt-get -y install wget g++ zip ca-certificates jq pip install --upgrade pip pip install platformio - - - name: Clone Meshtastic repository and compile firmware + + - name: Download last known tag if available + id: download-tag + uses: actions/download-artifact@v2 + with: + name: last-known-tag + path: . + + - name: Check for new Meshtastic firmware release + id: check-release run: | - git clone https://github.com/meshtastic/firmware --recurse-submodules /tmp/firmware - cd /tmp/firmware - chmod +x ./bin/build-native.sh - ./bin/build-native.sh - # Extract tag from version.properties - TAG=$(curl -s https://raw.githubusercontent.com/meshtastic/firmware/master/version.properties | sed -nE 's/major = ([0-9]+)/\1./p; s/minor = ([0-9]+)/\1./p; s/build = ([0-9]+)/\1/p' | tr -d '\n'; echo) - echo "TAG=amd64-v$TAG" >> $GITHUB_ENV # Set variable for next steps - + if [ -f "last_known_tag.txt" ]; then + LAST_KNOWN_TAG=$(cat last_known_tag.txt) + else + LAST_KNOWN_TAG="" + fi + LATEST_TAG=$(curl -s https://api.github.com/repos/meshtastic/firmware/releases/latest | jq -r .tag_name) + echo "Latest tag is $LATEST_TAG" + echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV + if [ "$LATEST_TAG" != "$LAST_KNOWN_TAG" ]; then + echo "A new release is available, proceeding with the build." + else + echo "No new release found, skipping the build." + exit 0 + + # ... rest of your original steps to build the firmware ... + - name: Upload firmware to release - id: upload-release uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} @@ -43,3 +58,15 @@ jobs: tag: ${{ env.TAG }} overwrite: true body: "Meshtastic amd64 firmware" + + - name: Update and upload last known tag + if: success() + run: | + echo "$LATEST_TAG" > last_known_tag.txt + echo "Updating last known tag to $LATEST_TAG" + + - name: Upload new last known tag as artifact + uses: actions/upload-artifact@v2 + with: + name: last-known-tag + path: last_known_tag.txt