Skip to content

Commit 4c8af34

Browse files
authored
feat(ci): create release with zip and to install the app into the board with one-line comand (#14)
* wip. task create zip * Update sketch.yaml to specify commit for Arduino_Modulino to avoid build issues with ArduinoLedMatrix * chore: update .gitignore and README for task adjustments; remove obsolete build ignore * feat: add GitHub Actions workflow for automated release process * fix: update release workflow to include workflow_dispatch and correct step name for zip creation * fix: correct Go version specification in release workflow * refactor: simplify task execution in release workflow by removing Go tool commands * fix: correct command execution context for npm install and build in scratch:init task * feat: add installer script for scratch-arduino-app and update release workflow to set environment variables * fix: uncomment zip creation step and correct syntax for artifact name in release workflow * fix: correct environment variable reference for artifact name in release workflow * fix * fix * fix: update installation paths to use HOME variable for consistency * fix: remove commented-out zip creation step in release workflow * fix: update release workflow to create zip and upload artifacts * fix: add missing newline and correct indentation in release workflow * fix: simplify download command in installer script * fix: correct token variable name in release workflow * fix: update token reference in release workflow and remove unnecessary newline * fix: streamline zip creation process and enhance versioning in Taskfile * fix: simplify installer script by removing unnecessary checks and using latest release download * fix: update installation instructions and improve download process in installer script * fix: remove redundant installation messages and streamline script execution * fix: remove redundant cleanup step in installation script * fix: add error handling for missing zip file in installation script * fix: clarify download directory in installation script
1 parent 8b3a938 commit 4c8af34

File tree

14 files changed

+2357
-51
lines changed

14 files changed

+2357
-51
lines changed

.github/workflows/release.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags:
7+
- "v[0-9]+.[0-9]+.[0-9]+*"
8+
9+
jobs:
10+
release:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v5
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Show tag info
19+
run: echo "Building release for tag ${{ github.ref_name }}"
20+
21+
- name: Install Go
22+
uses: actions/setup-go@v5
23+
with:
24+
go-version: 1.25
25+
26+
- name: Set up Node.js
27+
uses: actions/setup-node@v6
28+
with:
29+
node-version: '18'
30+
31+
- name: Install Task
32+
uses: arduino/setup-task@v2
33+
34+
- name: Scratch init
35+
run: |
36+
task scratch:init
37+
38+
- name: Create build
39+
run: |
40+
task app:build
41+
42+
- name: Create zip
43+
run: task app:zip
44+
env:
45+
APP_VERSION: ${{ github.ref_name }}
46+
47+
- uses: ncipollo/release-action@v1
48+
with:
49+
artifacts: "build/scratch-arduino-app*.zip"
50+
allowUpdates: true
51+
token: ${{ github.token }}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
scratch-editor
2-
Arduino_Modulino
2+
build/

README.md

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
# Scratch for Arduino Uno Q
22

3-
Getting started:
4-
1. Connect the Arduino Uno Q board
5-
2. Upload the `scratch-arduino-app` into the board:
6-
``` sh
7-
task app:upload
8-
```
9-
3. Start the App
10-
- via the ArduinoAppLab
11-
- via command line `arduino-app-cli app start user:scratch-arduino-app`
3+
## Installation
124

13-
4. Open the `<IP_OR_BOARD_NAME>:7000`
5+
- Connect to the board using `adb` following https://docs.arduino.cc/software/app-lab/tutorials/cli/ and open the `adb shell`
6+
- From inside the board, Install the latest `scratch-arduino-app` into the board running the command:
7+
```
8+
curl -sSL https://raw.githubusercontent.com/dido18/scratch-arduino-app/main/install.sh | bash
9+
```
10+
- Open the `ArduinoAppLab` and start the app
11+
- Visit the `<IP_OR_BOARD_NAME>:7000` to open the Scratch App.
1412

15-
### Local dev
13+
### Local development
1614
- `task scratch:init`
17-
- `task scratch:patch`
18-
- `task scratch:start`
15+
- `task scratch:local:start`
1916
- change the `const wsServerURL = `<YOUR_IP>:7000`;` in the `index.js`
2017
- Open local scratch on http://localhost:8601/

Taskfile.yaml

Lines changed: 50 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,71 @@
11
version: "3"
22
vars:
33
SCRATCH_EDITOR_VERSION: v12.0.1
4-
ARDUINO_APP_BASE_PATH: /home/arduino/ArduinoApps/scratch-arduino-app
54

65
tasks:
7-
app:upload:
8-
desc: "Upload app files to the Arduino Board"
9-
cmds:
10-
- adb push ./app.yaml {{ .ARDUINO_APP_BASE_PATH }}/app.yaml
11-
- task: modulino:patch
12-
- adb push ./sketch {{ .ARDUINO_APP_BASE_PATH }}/
13-
- adb push ./python/ {{ .ARDUINO_APP_BASE_PATH }}/
14-
- adb push ./assets/ {{ .ARDUINO_APP_BASE_PATH }}/
15-
16-
modulino:patch:
17-
desc: "Patch Arduino Modulino and put it in the sketch folder"
18-
cmds:
19-
# See https://github.com/arduino-libraries/Arduino_Modulino/pull/42
20-
# Any Version<0.6.0 the build fails if Both modulino and ArduinoLedMatrix are used in the UnoQ
21-
- rm -rf sketch/Arduino_Modulino && mkdir -p sketch/Arduino_Modulino
22-
- git clone --depth 1 git@github.com:arduino-libraries/Arduino_Modulino.git sketch/Arduino_Modulino
23-
- cd sketch/Arduino_Modulino && git checkout 480e9d183a3b3dede0c68170e469410a6d710bee
24-
256
scratch:init:
267
cmds:
8+
- rm -rf scratch-editor
279
- git clone --depth 1 --branch {{ .SCRATCH_EDITOR_VERSION }} https://github.com/scratchfoundation/scratch-editor.git
28-
- task: scratch:install
29-
30-
scratch:install:
31-
dir: scratch-editor
32-
cmds:
33-
- npm install
34-
- npm run build
10+
- cd scratch-editor && npm install
11+
- cd scratch-editor && npm run build
12+
- task scratch:patch
3513

3614
scratch:patch:
3715
cmds:
3816
- cd scratch-editor/packages/scratch-gui && node ../../../scratch-arduino-extensions/scripts/patch-gui.js
3917

40-
scratch:start:
18+
scratch:local:start:
4119
dir: scratch-editor
4220
cmds:
4321
- npm start --workspace @scratch/scratch-gui
4422

45-
scratch:clean:
23+
app:build:
24+
desc: "Copy app files (python, assets, app.yaml) to a build directory"
4625
cmds:
47-
- rm -rf scratch-editor
48-
49-
scratch:assets:
50-
desc: "Build Scratch GUI files and copy to the assets folder"
26+
- mkdir -p build/scratch-arduino-app
27+
- cp ./app.yaml build/scratch-arduino-app/app.yaml
28+
- cp -r ./sketch/ build/scratch-arduino-app/sketch
29+
- cp -r ./python/ build/scratch-arduino-app/python
30+
- task scratch:build
31+
- mkdir -p build/scratch-arduino-app/assets
32+
- cp scratch-editor/packages/scratch-gui/build/index.html build/scratch-arduino-app/assets/index.html
33+
- cp scratch-editor/packages/scratch-gui/build/gui.js build/scratch-arduino-app/assets/gui.js
34+
- mkdir -p build/scratch-arduino-app/assets/static
35+
- cp -r scratch-editor/packages/scratch-gui/build/static/blocks-media build/scratch-arduino-app/assets/static/blocks-media
36+
37+
scratch:build:
38+
desc: "Build Scratch GUI files"
5139
dir: scratch-editor/packages/scratch-gui
5240
cmds:
5341
- npm run build:dev --workspace @scratch/scratch-gui
54-
- cp build/index.html ../../../assets/index.html
55-
- cp build/gui.js ../../../assets/gui.js
56-
## copy (some) of the static files
57-
- mkdir -p ../../../assets/static/blocks-media && cp -r build/static/blocks-media ../../../assets/static/
42+
43+
board:app:upload:
44+
desc: "Upload zip file to Arduino board, unzip and deploy to /home/arduino/ArduinoApps"
45+
cmds:
46+
- task app:zip
47+
- |
48+
ZIP_FILE=$(ls -t build/scratch-arduino-app-*.zip 2>/dev/null | head -n1)
49+
if [ -z "$ZIP_FILE" ]; then
50+
echo "No zip file found. Run 'task app:zip' first."
51+
exit 1
52+
fi
53+
adb push "$ZIP_FILE" /tmp/
54+
ZIP_BASENAME=$(basename "$ZIP_FILE")
55+
adb shell "cd /tmp && unzip -o $ZIP_BASENAME && mkdir -p /home/arduino/ArduinoApps && rm -rf /home/arduino/ArduinoApps/scratch-arduino-app && mv scratch-arduino-app /home/arduino/ArduinoApps/ && rm $ZIP_BASENAME"
56+
echo "App deployed to /home/arduino/ArduinoApps/scratch-arduino-app"
57+
58+
app:zip:
59+
desc: "Create a zip file with version (defaults to git commit hash)"
60+
vars:
61+
APP_VERSION:
62+
sh: echo "${APP_VERSION:-$(git rev-parse --short HEAD 2>/dev/null || echo 'unknown')}"
63+
cmds:
64+
- |
65+
if [ ! -d "build/scratch-arduino-app" ]; then
66+
echo "Build folder does not exist. Run 'task app:build' first."
67+
exit 1
68+
fi
69+
- echo "Creating zip with version {{.APP_VERSION}}"
70+
- cd build && zip -r scratch-arduino-app-{{.APP_VERSION}}.zip scratch-arduino-app && cd ..
71+

app.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: scratch-arduino-app
2-
description: Controll the Uno-Q borad using Scractch blocks
2+
description: Control the Uno-Q board using Scratch blocks
33
ports:
44
- 7000
55
bricks:

install.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
3+
set -e # Exit immediately if any command fails
4+
5+
# Get latest release zip URL and download
6+
ZIP_URL=$(curl -s "https://api.github.com/repos/dido18/scratch-arduino-app/releases/latest" | \
7+
grep '"browser_download_url": "[^"]*\.zip"' | \
8+
cut -d'"' -f4 | head -n1)
9+
10+
if [ -z "$ZIP_URL" ]; then
11+
echo "Error: No zip file found in latest release"
12+
exit 1
13+
fi
14+
15+
ZIP_NAME=$(basename "$ZIP_URL")
16+
echo "Downloading: $ZIP_NAME"
17+
18+
# Download to /tmp directory
19+
cd /tmp
20+
curl -sL "$ZIP_URL" -o app.zip
21+
22+
unzip -q app.zip
23+
rm -rf $HOME/ArduinoApps/scratch-arduino-app
24+
mv -f scratch-arduino-app $HOME/ArduinoApps/
25+
rm -f app.zip
26+
27+
echo "Installation completed: $ZIP_NAME installed at $HOME/ArduinoApps/scratch-arduino-app"

0 commit comments

Comments
 (0)