|
1 | | -name: Release ESP32 Rust Binaries |
| 1 | +name: Release |
2 | 2 |
|
3 | 3 | on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*.*.*' |
4 | 7 | 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: '' |
14 | 8 |
|
15 | 9 | jobs: |
16 | | - get_release: |
17 | | - name: Get release |
| 10 | + release: |
18 | 11 | runs-on: ubuntu-latest |
19 | | - outputs: |
20 | | - upload_url: ${{ steps.get_upload_url.outputs.url }} |
21 | 12 | 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 |
24 | 18 | 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 |
32 | 23 | 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 |
37 | 27 |
|
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 |
46 | 29 | 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 }} |
53 | 38 | env: |
54 | 39 | 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 |
64 | 40 |
|
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 }} |
89 | 49 |
|
| 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 }} |
0 commit comments