# Fetch the latest release data release_data=$(curl -s "https://git.btclock.dev/api/v1/repos/btclock/btclock_v3/releases" | jq '.[0]') # Extract and write published_at date echo $release_data | jq -r '.published_at' > firmware_v3/date.txt # Get the tag name tag_name=$(echo $release_data | jq -r '.tag_name') # Fetch the commit hash from the tag's API endpoint commit_hash=$(curl -s "https://git.btclock.dev/api/v1/repos/btclock/btclock_v3/tags/$tag_name" | jq -r '.commit.sha') # Write the commit hash to commit.sh echo $commit_hash > firmware_v3/commit.txt echo $tag_name > firmware_v3/tag.txt # Download and distribute littlefs files littlefs_url=$(echo $release_data | jq -r '.assets[] | select(.name=="littlefs.bin") | .browser_download_url') littlefs_sha_url=$(echo $release_data | jq -r '.assets[] | select(.name=="littlefs.bin.sha256") | .browser_download_url') for dir in firmware_v3/build-btclock_rev_b-213epd firmware_v3/build-lolin_s3_mini-29epd firmware_v3/build-lolin_s3_mini-213epd; do curl -sSL $littlefs_url -o "$dir/littlefs.bin" curl -sSL $littlefs_sha_url -o "$dir/littlefs.bin.sha256" done # Function to download and distribute board-specific files download_board_files() { local board=$1 local dir=$2 local files=("${@:3}") for file in "${files[@]}"; do url=$(echo $release_data | jq -r ".assets[] | select(.name==\"$file\") | .browser_download_url") echo "Downloading $url to $dir/$file" curl -sSL -o "$dir/$file" $url done } # Download btclock_rev_b_213epd files download_board_files "btclock_rev_b_213epd" "firmware_v3/build-btclock_rev_b-213epd" \ "btclock_rev_b_213epd.bin" \ "btclock_rev_b_213epd.bin.sha256" \ "btclock_rev_b_213epd_firmware.bin" \ "btclock_rev_b_213epd_firmware.bin.sha256" # Download lolin_s3_mini_29epd files download_board_files "lolin_s3_mini_29epd" "firmware_v3/build-lolin_s3_mini-29epd" \ "lolin_s3_mini_29epd.bin" \ "lolin_s3_mini_29epd.bin.sha256" \ "lolin_s3_mini_29epd_firmware.bin" \ "lolin_s3_mini_29epd_firmware.bin.sha256" # Download lolin_s3_mini_213epd files download_board_files "lolin_s3_mini_213epd" "firmware_v3/build-lolin_s3_mini-213epd" \ "lolin_s3_mini_213epd.bin" \ "lolin_s3_mini_213epd.bin.sha256" \ "lolin_s3_mini_213epd_firmware.bin" \ "lolin_s3_mini_213epd_firmware.bin.sha256"