Skip to content

Commit 70767d7

Browse files
committed
wasm: format
1 parent 0ab211f commit 70767d7

File tree

5 files changed

+120
-156
lines changed

5 files changed

+120
-156
lines changed

.github/workflows/release.yml

Lines changed: 40 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,55 @@
1-
name: Release ESP32 Rust Binaries
1+
name: Release
22

33
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
47
workflow_dispatch:
5-
inputs:
6-
release_tag:
7-
description: "Upload to specific release"
8-
required: true
9-
default: 'v0.1.0'
10-
skip_projects:
11-
description: "Skip projects during build (e.g. esp32-c3-devkit-rust)"
12-
required: false
13-
default: ''
148

159
jobs:
16-
get_release:
17-
name: Get release
10+
release:
1811
runs-on: ubuntu-latest
19-
outputs:
20-
upload_url: ${{ steps.get_upload_url.outputs.url }}
2112
steps:
22-
- uses: octokit/request-action@v2.x
23-
id: get_release
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Rust
17+
uses: actions-rs/toolchain@v1
2418
with:
25-
route: GET /repos/{owner}/{repo}/releases/tags/${{ github.event.inputs.release_tag }}
26-
owner: georgik
27-
repo: esp32-conways-game-of-life-rs
28-
env:
29-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30-
- name: get upload url
31-
id: get_upload_url
19+
toolchain: stable
20+
override: true
21+
22+
- name: Build ESP32 Projects
3223
run: |
33-
url=$(echo "$response" | jq -r '.upload_url' | sed 's/{?name,label}//')
34-
echo "::set-output name=url::$url"
35-
env:
36-
response: ${{ steps.get_release.outputs.data }}
24+
for dir in esp32-c3-lcdkit esp32-c6-waveshare-1_47 esp32-s3-box-3 esp32-s3-box-3-minimal; do
25+
cd $dir && cargo build --release && cd ..
26+
done
3727
38-
build:
39-
runs-on: ubuntu-20.04
40-
container:
41-
image: espressif/idf-rust:all_1.73.0.1
42-
options: --user esp --workdir /home/esp
43-
needs: get_release
44-
steps:
45-
- name: Clone repository with specific branch
28+
- name: Build WASM Package
4629
run: |
47-
export HOME=/home/esp
48-
cd /home/esp
49-
curl -L https://wokwi.com/ci/install.sh | sh
50-
pwd
51-
git clone --depth 1 --branch ${{ github.ref_name }} https://github.com/georgik/esp32-conways-game-of-life-rs.git project
52-
- name: Build and upload binaries
30+
cd wasm
31+
wasm-pack build --target web --release
32+
33+
- name: Create GitHub Release
34+
id: create_release
35+
uses: softprops/action-gh-release@v1
36+
with:
37+
tag_name: ${{ github.ref }}
5338
env:
5439
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55-
WOKWI_CLI_TOKEN: ${{ secrets.WOKWI_CLI_TOKEN }}
56-
run: |
57-
# Workaround GitHub issue with setting HOME in container https://github.com/actions/runner/issues/863
58-
export HOME=/home/esp
59-
cd /home/esp
60-
. /home/esp/.bashrc
61-
. /home/esp/export-esp.sh
62-
# Upload loop for each binary
63-
cd project
6440

65-
VERSION=$(grep '^version =' Cargo.toml | cut -d '"' -f2)
66-
CHIP=$(grep 'hal = { package =' Cargo.toml | cut -d '"' -f2 | cut -d '-' -f1)
67-
68-
cargo espflash save-image --chip ${CHIP} --release --merge --skip-padding esp32-conways-game-of-life-rs.bin
69-
70-
/home/esp/bin/wokwi-cli --timeout 5000 --timeout-exit-code 0 --screenshot-part "lcd1" --screenshot-time 5000 --screenshot-file "screenshot.png" "."
71-
72-
asset_path="/home/esp/project/esp32-conways-game-of-life-rs.bin"
73-
asset_name="esp32-conways-game-of-life-rs-${{ github.event.inputs.release_tag }}.bin"
74-
curl \
75-
--request POST \
76-
--header "authorization: Bearer $GITHUB_TOKEN" \
77-
--header "Content-Type: application/octet-stream" \
78-
--data-binary "@$asset_path" \
79-
--url "${{ needs.get_release.outputs.upload_url }}?name=${asset_name}"
80-
81-
asset_path="/home/esp/project/screenshot.png"
82-
asset_name="esp32-conways-game-of-life-rs-${{ github.event.inputs.release_tag }}.png"
83-
curl \
84-
--request POST \
85-
--header "authorization: Bearer $GITHUB_TOKEN" \
86-
--header "Content-Type: application/octet-stream" \
87-
--data-binary "@$asset_path" \
88-
--url "${{ needs.get_release.outputs.upload_url }}?name=${asset_name}"
41+
- name: Upload WASM Assets to Release
42+
uses: softprops/action-gh-release@v1
43+
with:
44+
files: |
45+
wasm/pkg/*.wasm
46+
wasm/pkg/*.js
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8949

50+
- name: Deploy WASM to GitHub Pages
51+
uses: JamesIves/github-pages-deploy-action@v4
52+
with:
53+
branch: gh-pages
54+
folder: wasm/pkg
55+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/rust_ci.yml

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,62 @@ env:
1212
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1313

1414
jobs:
15-
rust-checks:
16-
name: Rust Checks
15+
esp32-checks:
16+
name: ESP32 Checks
1717
runs-on: ubuntu-latest
1818
strategy:
1919
fail-fast: false
2020
matrix:
21+
project: [ "esp32-c3-lcdkit", "esp32-c6-waveshare-1_47", "esp32-s3-box-3", "esp32-s3-box-3-minimal" ]
2122
action:
22-
- command: build
23-
args: --release
24-
- command: fmt
25-
args: --all -- --check --color always
26-
- command: clippy
27-
args: --all-features --workspace -- -D warnings
23+
- { command: build, args: "--release" }
24+
- { command: fmt, args: "--all -- --check --color always" }
25+
- { command: clippy, args: "--all-features --workspace -- -D warnings" }
2826
steps:
2927
- name: Checkout repository
3028
uses: actions/checkout@v4
29+
3130
- name: Enable caching
3231
uses: Swatinem/rust-cache@v2
33-
- name: Setup Rust
32+
33+
- name: Setup Rust for ESP32
3434
uses: esp-rs/xtensa-toolchain@v1.5
3535
with:
3636
default: true
3737
buildtargets: esp32s3
3838
ldproxy: false
39+
40+
- name: Change directory to project
41+
run: cd ${{ matrix.project }}
42+
43+
- name: Run command
44+
run: cargo ${{ matrix.action.command }} ${{ matrix.action.args }}
45+
46+
wasm-checks:
47+
name: WASM Checks
48+
runs-on: ubuntu-latest
49+
strategy:
50+
fail-fast: false
51+
matrix:
52+
action:
53+
- { command: build, args: "--target wasm32-unknown-unknown --release" }
54+
- { command: fmt, args: "--all -- --check --color always" }
55+
- { command: clippy, args: "--all-features --workspace -- -D warnings" }
56+
steps:
57+
- name: Checkout repository
58+
uses: actions/checkout@v4
59+
60+
- name: Enable caching
61+
uses: Swatinem/rust-cache@v2
62+
63+
- name: Setup Rust for WASM
64+
uses: actions-rs/toolchain@v1
65+
with:
66+
toolchain: stable
67+
target: wasm32-unknown-unknown
68+
69+
- name: Change directory to wasm
70+
run: cd wasm
71+
3972
- name: Run command
4073
run: cargo ${{ matrix.action.command }} ${{ matrix.action.args }}

scripts/build.sh

Lines changed: 0 additions & 18 deletions
This file was deleted.

scripts/flash.sh

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)