Skip to content

Commit 295ddda

Browse files
authored
[FEAT] release workflow and build (#24)
* [FEAT] release workflow and build * cleanup firmwarezip * add bins to release artifact
1 parent 2a58a35 commit 295ddda

File tree

10 files changed

+131
-17
lines changed

10 files changed

+131
-17
lines changed

.github/workflows/release.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v[0-9]+.[0-9]+.[0-9]+"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
16+
- uses: actions/checkout@v3
17+
with:
18+
ref: main
19+
20+
- name: update version in repo
21+
env:
22+
tag: ${{ github.ref_name }}
23+
run: |
24+
tmp=$(mktemp)
25+
jq --arg version "$version" '.versions |= [$version] + .' installer/versions.json > "$tmp" && mv "$tmp" installer/versions.json
26+
git config --global user.name 'Alan Bits'
27+
git config --global user.email '[email protected]'
28+
git commit -am "[CHORE] update version to $tag"
29+
git push
30+
git push --delete origin $tag
31+
git tag -fa $tag -m "update via workflow"
32+
git push --tags
33+
34+
- name: Install Arduino CLI
35+
uses: arduino/setup-arduino-cli@v1
36+
37+
- name: build sketch with arduino cli
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
tag: ${{ github.ref_name }}
41+
run: |
42+
sh build.sh
43+
sh release.sh $tag
44+
45+
- name: Create github release
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
tag: ${{ github.ref_name }}
49+
run: |
50+
gh release create "$tag" --generate-notes ./firmware.zip ./dist/$tag/manifest.json ./dist/$tag/bootloader.bin \
51+
./dist/$tag/boot_app0.bin ./dist/$tag/bitcoinSwitch.ino.bin ./dist/$tag/bitcoinSwitch.ino.partitions.bin
52+
53+
pages:
54+
needs: [ release ]
55+
uses: ./.github/workflows/static.yml

.github/workflows/static.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ on:
99
# Allows you to run this workflow manually from the Actions tab
1010
workflow_dispatch:
1111

12+
# Allows you to run this workflow from other workflows
13+
workflow_call:
14+
1215
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
1316
permissions:
1417
contents: read
@@ -31,7 +34,7 @@ jobs:
3134
- name: Checkout
3235
uses: actions/checkout@v3
3336
- name: copy main assets
34-
run: sh build.sh
37+
run: sh build-webinstaller.sh
3538
- name: Setup Pages
3639
uses: actions/configure-pages@v3
3740
- name: Upload artifact

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,9 @@ installer/main_assets
22
installer/firmware
33
.pio
44
.vscode
5+
dist
6+
build/*
7+
!build/manifest.template.json
8+
!build/boot_app0.bin
9+
!build/bootloader.bin
10+
firmware.zip

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,14 @@ For use with LNURLDevice in LNbits.
5050

5151

5252
### development
53-
fetch main assets from lnbits.github.io
53+
build with arduino-cli
5454
```console
5555
sh build.sh
5656
```
57+
build webinstaller, fetch main assets from lnbits.github.io
58+
```console
59+
sh build-installer.sh
60+
```
5761
start preview
5862
```console
5963
cd installer

build-webinstaller.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
git clone https://github.com/lnbits/lnbits.github.io mainpage
3+
cp -r ./mainpage/assets ./installer/main_assets
4+
rm -rf mainpage
5+
6+
mkdir -p ./installer/firmware/esp32
7+
8+
for version in $(jq -r '.versions[]' ./installer/versions.json); do
9+
rm -f firmware.zip
10+
wget https://github.com/lnbits/bitcoinswitch/releases/download/$version/firmware.zip
11+
unzip firmware.zip -d ./installer/firmware/esp32
12+
rm firmware.zip
13+
done

build.sh

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
#!/bin/sh
2-
git clone https://github.com/lnbits/lnbits.github.io mainpage
3-
cp -r ./mainpage/assets ./installer/main_assets
4-
rm -rf mainpage
5-
6-
mkdir -p ./installer/firmware/esp32
7-
8-
for version in $(jq -r '.versions[]' ./installer/versions.json); do
9-
mkdir -p ./installer/firmware/esp32/$version
10-
wget https://github.com/lnbits/bitcoinswitch/releases/download/$version/firmware.zip
11-
unzip firmware.zip -d ./installer/firmware/esp32
12-
rm firmware.zip
13-
done
2+
command -v arduino-cli >/dev/null 2>&1 || { echo >&2 "arduino-cli not found. Aborting."; exit 1; }
3+
arduino-cli config --additional-urls https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json init
4+
arduino-cli core update-index
5+
arduino-cli lib install WebSockets ArduinoJson
6+
arduino-cli compile --build-path build --fqbn esp32:esp32:esp32 bitcoinSwitch/bitcoinSwitch.ino

build/boot_app0.bin

8 KB
Binary file not shown.

build/bootloader.bin

18.2 KB
Binary file not shown.

build/manifest.template.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "LNbits bitcoinSwitch",
3+
"version": "%version%",
4+
"funding_url": "https://github.com/lnbits/bitcoinSwitch",
5+
"new_install_prompt_erase": true,
6+
"builds": [
7+
{
8+
"chipFamily": "ESP32",
9+
"parts": [
10+
{
11+
"path": "firmware/esp32/%version%/bootloader.bin",
12+
"offset": 4096
13+
},
14+
{
15+
"path": "firmware/esp32/%version%/bitcoinSwitch.ino.partitions.bin",
16+
"offset": 32768
17+
},
18+
{
19+
"path": "firmware/esp32/%version%/boot_app0.bin",
20+
"offset": 57344
21+
},
22+
{
23+
"path": "firmware/esp32/%version%/bitcoinSwitch.ino.bin",
24+
"offset": 65536
25+
}
26+
]
27+
}
28+
]
29+
}

release.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
#!/bin/sh
2-
version=$1
3-
tmp=$(mktemp)
4-
jq --arg version "$version" '.versions |= [$version] + .' installer/versions.json > "$tmp" && mv "$tmp" installer/versions.json
2+
tag=$1
3+
4+
rm -rf dist
5+
mkdir -p dist/$tag
6+
7+
cp build/bitcoinSwitch.ino.bin dist/$tag
8+
cp build/bitcoinSwitch.ino.partitions.bin dist/$tag
9+
cp build/boot_app0.bin dist/$tag
10+
cp build/bootloader.bin dist/$tag
11+
12+
cp build/manifest.template.json dist/$tag/manifest.json
13+
sed -i -e "s/%version%/$tag/g" dist/$tag/manifest.json
14+
15+
zip firmware.zip dist

0 commit comments

Comments
 (0)