Skip to content

Commit

Permalink
Update main.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
mate71pl authored Dec 14, 2023
1 parent 6ccd3f1 commit 64df685
Showing 1 changed file with 40 additions and 13 deletions.
53 changes: 40 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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

0 comments on commit 64df685

Please sign in to comment.