From f4b5dec4d7d2c15b4db2214e2ae69847a163d013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dni=20=E2=9A=A1?= Date: Tue, 31 Oct 2023 10:56:56 +0100 Subject: [PATCH] fixup workflows and build scripts --- .github/workflows/arduino.yml | 17 +++++++++------- .github/workflows/release.yml | 11 +++------- .github/workflows/static.yml | 14 ++++++++++--- build-webinstaller.sh | 38 ++++++++++++++++++++--------------- build.sh | 3 +-- config.js | 35 ++++++++++++++++++++++++++++++++ versions.json | 9 +++++++++ 7 files changed, 91 insertions(+), 36 deletions(-) create mode 100644 config.js create mode 100644 versions.json diff --git a/.github/workflows/arduino.yml b/.github/workflows/arduino.yml index 3a28cd8..876d97b 100644 --- a/.github/workflows/arduino.yml +++ b/.github/workflows/arduino.yml @@ -7,9 +7,9 @@ jobs: strategy: matrix: fqbn: - - esp32:esp32:esp32 - - esp32:esp32:esp32s3 - - esp32:esp32:esp32c3 + - esp32:esp32:ttgo-lora32 + # - esp32:esp32:esp32s3 + # - esp32:esp32:esp32c3 # future bluetooth chips #- esp32:esp32:esp32c2 #- esp32:esp32:esp32c6 @@ -26,12 +26,15 @@ jobs: - name: esp32:esp32 source-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json sketch-paths: | - - bitcoinSwitch - libraries: | - - name: WebSockets - - name: ArduinoJson + - snsd cli-compile-flags: | - --warnings="none" + libraries: | + - name: ArduinoJson + - name: QRCode + - name: TFT_eSPI + - name: uBitcoin + # - name: tiny-AES-c - uses: actions/upload-artifact@v2 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c2a943e..8f2fe8b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,7 +25,7 @@ jobs: tag: ${{ github.ref_name }} run: | tmp=$(mktemp) - jq --arg version $tag '.versions |= [$version] + .' installer/versions.json > "$tmp" && mv "$tmp" installer/versions.json + jq --arg version $tag '.versions |= [$version] + .' versions.json > "$tmp" && mv "$tmp" versions.json git config --global user.name 'Alan Bits' git config --global user.email 'alan@lnbits.com' git commit -am "[CHORE] update version to $tag" @@ -43,16 +43,11 @@ jobs: tag: ${{ github.ref_name }} run: | sh build.sh - sh release.sh $tag - name: Create github release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} tag: ${{ github.ref_name }} run: | - gh release create "$tag" --generate-notes ./dist/$tag/manifest.json ./dist/$tag/bootloader.bin \ - ./dist/$tag/boot_app0.bin ./dist/$tag/snsd.ino.bin ./dist/$tag/snsd.ino.partitions.bin - - pages: - needs: [ release ] - uses: ./.github/workflows/static.yml + gh release create "$tag" --generate-notes ./build/snsd.ino.bootloader.bin \ + ./build/snsd.ino.bin ./build/snsd.ino.partitions.bin diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 4e2e7ef..322237a 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -33,14 +33,22 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - name: copy main assets - run: sh build-webinstaller.sh + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: '16.x' + - name: build webinstaller + run: | + sh build-webinstaller.sh + cd hardware-installer + npm install + npx vite build - name: Setup Pages uses: actions/configure-pages@v3 - name: Upload artifact uses: actions/upload-pages-artifact@v1 with: - path: "installer" + path: "hardware-installer/dist" - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v2 diff --git a/build-webinstaller.sh b/build-webinstaller.sh index 5adeaac..b8164bf 100644 --- a/build-webinstaller.sh +++ b/build-webinstaller.sh @@ -1,20 +1,26 @@ #!/bin/sh -git clone https://github.com/lnbits/lnbits.github.io mainpage -cp -r ./mainpage/assets ./installer/main_assets -rm -rf mainpage +PROJECT_NAME=snsd +RELEASE=https://github.com/lnbits/nostr-signing-device/releases/download +INSTALLER_REPO=https://github.com/lnbits/hardware-installer +INSTALLER_PATH=./hardware-installer/public/firmware -mkdir -p ./installer/firmware/esp32 +git clone $INSTALLER_REPO -for version in $(jq -r '.versions[]' ./installer/versions.json); do - mkdir -p ./installer/firmware/esp32/$version - wget https://github.com/lnbits/nostr-signing-device/releases/download/$version/manifest.json - mv manifest.json ./installer/firmware/esp32/$version - wget https://github.com/lnbits/nostr-signing-device/releases/download/$version/bootloader.bin - mv bootloader.bin ./installer/firmware/esp32/$version - wget https://github.com/lnbits/nostr-signing-device/releases/download/$version/boot_app0.bin - mv boot_app0.bin ./installer/firmware/esp32/$version - wget https://github.com/lnbits/nostr-signing-device/releases/download/$version/snsd.ino.bin - mv snsd.ino.bin ./installer/firmware/esp32/$version - wget https://github.com/lnbits/nostr-signing-device/releases/download/$version/snsd.ino.partitions.bin - mv snsd.ino.partitions.bin ./installer/firmware/esp32/$version +cp README.md ./hardware-installer/public/README.md +cp versions.json ./hardware-installer/src/versions.json +cp config.js ./hardware-installer/src/config.js + +sed -i "s/%title%/$PROJECT_NAME/g" ./hardware-installer/index.html + +mkdir -p $INSTALLER_PATH +for device in $(jq -r '.devices[]' ./hardware-installer/src/versions.json); do + for version in $(jq -r '.versions[]' ./hardware-installer/src/versions.json); do + mkdir -p $INSTALLER_PATH/$device/$version + wget $RELEASE/$version/$PROJECT_NAME.ino.bin + wget $RELEASE/$version/$PROJECT_NAME.ino.partitions.bin + wget $RELEASE/$version/$PROJECT_NAME.ino.bootloader.bin + mv $PROJECT_NAME.ino.bin $INSTALLER_PATH/$device/$version + mv $PROJECT_NAME.ino.partitions.bin $INSTALLER_PATH/$device/$version + mv $PROJECT_NAME.ino.bootloader.bin $INSTALLER_PATH/$device/$version + done done diff --git a/build.sh b/build.sh index 5546172..00d1b7d 100644 --- a/build.sh +++ b/build.sh @@ -1,8 +1,7 @@ -#!/bin/sh command -v arduino-cli >/dev/null 2>&1 || { echo >&2 "arduino-cli not found. Aborting."; exit 1; } arduino-cli config --additional-urls https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json init arduino-cli core update-index arduino-cli core install esp32:esp32 arduino-cli upgrade arduino-cli lib install ArduinoJson QRCode TFT_eSPI uBitcoin # tiny-AES-c -arduino-cli compile --build-path build --fqbn esp32:esp32:esp32 snsd/snsd.ino +arduino-cli compile --build-path build --fqbn esp32:esp32:ttgo-lora32 snsd diff --git a/config.js b/config.js new file mode 100644 index 0000000..f0817f8 --- /dev/null +++ b/config.js @@ -0,0 +1,35 @@ +export const addressesAndFiles = [ + { + address: "0x1000", + fileName: "snsd.ino.bootloader.bin", + }, + { + address: "0x8000", + fileName: "snsd.ino.partitions.bin", + }, + { + address: "0xE000", + fileName: "boot_app0.bin", + }, + { + address: "0x10000", + fileName: "snsd.ino.bin", + }, +]; + +export const configPath = "elements.json"; + +export const elements = [ + { + name: "config_ssid", + value: "", + label: "WiFi SSID", + type: "text", + }, + { + name: "config_password", + value: "", + label: "WiFi password", + type: "text", + } +]; diff --git a/versions.json b/versions.json new file mode 100644 index 0000000..ff5b74d --- /dev/null +++ b/versions.json @@ -0,0 +1,9 @@ +{ + "name": "snsd", + "devices": [ + "esp32" + ], + "versions": [ + "v0.0.0" + ] +}