Skip to content

Commit

Permalink
[FEAT] release workflow and build (#24)
Browse files Browse the repository at this point in the history
* [FEAT] release workflow and build
* cleanup firmwarezip
* add bins to release artifact
  • Loading branch information
dni authored Sep 22, 2023
1 parent 2a58a35 commit 295ddda
Show file tree
Hide file tree
Showing 10 changed files with 131 additions and 17 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: release

on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"

permissions:
contents: write

jobs:
release:
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v3
with:
ref: main

- name: update version in repo
env:
tag: ${{ github.ref_name }}
run: |
tmp=$(mktemp)
jq --arg version "$version" '.versions |= [$version] + .' installer/versions.json > "$tmp" && mv "$tmp" installer/versions.json
git config --global user.name 'Alan Bits'
git config --global user.email '[email protected]'
git commit -am "[CHORE] update version to $tag"
git push
git push --delete origin $tag
git tag -fa $tag -m "update via workflow"
git push --tags
- name: Install Arduino CLI
uses: arduino/setup-arduino-cli@v1

- name: build sketch with arduino cli
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
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 ./firmware.zip ./dist/$tag/manifest.json ./dist/$tag/bootloader.bin \
./dist/$tag/boot_app0.bin ./dist/$tag/bitcoinSwitch.ino.bin ./dist/$tag/bitcoinSwitch.ino.partitions.bin
pages:
needs: [ release ]
uses: ./.github/workflows/static.yml
5 changes: 4 additions & 1 deletion .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Allows you to run this workflow from other workflows
workflow_call:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
Expand All @@ -31,7 +34,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- name: copy main assets
run: sh build.sh
run: sh build-webinstaller.sh
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Upload artifact
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@ installer/main_assets
installer/firmware
.pio
.vscode
dist
build/*
!build/manifest.template.json
!build/boot_app0.bin
!build/bootloader.bin
firmware.zip
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,14 @@ For use with LNURLDevice in LNbits.


### development
fetch main assets from lnbits.github.io
build with arduino-cli
```console
sh build.sh
```
build webinstaller, fetch main assets from lnbits.github.io
```console
sh build-installer.sh
```
start preview
```console
cd installer
Expand Down
13 changes: 13 additions & 0 deletions build-webinstaller.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh
git clone https://github.com/lnbits/lnbits.github.io mainpage
cp -r ./mainpage/assets ./installer/main_assets
rm -rf mainpage

mkdir -p ./installer/firmware/esp32

for version in $(jq -r '.versions[]' ./installer/versions.json); do
rm -f firmware.zip
wget https://github.com/lnbits/bitcoinswitch/releases/download/$version/firmware.zip
unzip firmware.zip -d ./installer/firmware/esp32
rm firmware.zip
done
17 changes: 5 additions & 12 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
#!/bin/sh
git clone https://github.com/lnbits/lnbits.github.io mainpage
cp -r ./mainpage/assets ./installer/main_assets
rm -rf mainpage

mkdir -p ./installer/firmware/esp32

for version in $(jq -r '.versions[]' ./installer/versions.json); do
mkdir -p ./installer/firmware/esp32/$version
wget https://github.com/lnbits/bitcoinswitch/releases/download/$version/firmware.zip
unzip firmware.zip -d ./installer/firmware/esp32
rm firmware.zip
done
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 lib install WebSockets ArduinoJson
arduino-cli compile --build-path build --fqbn esp32:esp32:esp32 bitcoinSwitch/bitcoinSwitch.ino
Binary file added build/boot_app0.bin
Binary file not shown.
Binary file added build/bootloader.bin
Binary file not shown.
29 changes: 29 additions & 0 deletions build/manifest.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "LNbits bitcoinSwitch",
"version": "%version%",
"funding_url": "https://github.com/lnbits/bitcoinSwitch",
"new_install_prompt_erase": true,
"builds": [
{
"chipFamily": "ESP32",
"parts": [
{
"path": "firmware/esp32/%version%/bootloader.bin",
"offset": 4096
},
{
"path": "firmware/esp32/%version%/bitcoinSwitch.ino.partitions.bin",
"offset": 32768
},
{
"path": "firmware/esp32/%version%/boot_app0.bin",
"offset": 57344
},
{
"path": "firmware/esp32/%version%/bitcoinSwitch.ino.bin",
"offset": 65536
}
]
}
]
}
17 changes: 14 additions & 3 deletions release.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
#!/bin/sh
version=$1
tmp=$(mktemp)
jq --arg version "$version" '.versions |= [$version] + .' installer/versions.json > "$tmp" && mv "$tmp" installer/versions.json
tag=$1

rm -rf dist
mkdir -p dist/$tag

cp build/bitcoinSwitch.ino.bin dist/$tag
cp build/bitcoinSwitch.ino.partitions.bin dist/$tag
cp build/boot_app0.bin dist/$tag
cp build/bootloader.bin dist/$tag

cp build/manifest.template.json dist/$tag/manifest.json
sed -i -e "s/%version%/$tag/g" dist/$tag/manifest.json

zip firmware.zip dist

0 comments on commit 295ddda

Please sign in to comment.