-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (125 loc) · 3.84 KB
/
ci.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: CI
on:
push:
paths:
- .github/workflows/ci.yaml
- "firmware/**"
pull_request:
paths:
- .github/workflows/ci.yaml
- "firmware/**"
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: riscv32imc-unknown-none-elf
components: clippy, rustfmt
- name: Check out repository
uses: actions/checkout@v4
- name: Cache cargo data
uses: actions/cache@v4
with:
path: |
~/.cargo/git
~/.cargo/registry
# intentionally not caching `target` here yet
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Check formatting
run: cargo fmt --all --check
working-directory: firmware
- name: Clippy
run: cargo clippy --workspace --all-targets -- --deny warnings --allow deprecated
working-directory: firmware
build:
name: Build
needs: [check]
runs-on: ubuntu-latest
steps:
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: riscv32imc-unknown-none-elf
- name: Check out repository
uses: actions/checkout@v4
- name: Cache cargo data
uses: actions/cache@v4
with:
path: |
~/.cargo/git
~/.cargo/registry
# intentionally not caching `target` here yet
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build everything
run: cargo build --workspace --all-targets --release
working-directory: firmware
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: touch-n-drink-elf
path: |
firmware/target/riscv32imc-unknown-none-elf/release/touch-n-drink
if-no-files-found: error
image:
name: Image
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Cache espflash
id: cache-espflash
uses: actions/cache@v4
with:
path: ~/.cargo/bin/espflash
key: ${{ runner.os }}-espflash
- name: Install dependencies
if: steps.cache-espflash.outputs.cache-hit != 'true'
run: sudo apt-get update && sudo apt-get install pkg-config libudev-dev
- name: Install espflash
if: steps.cache-espflash.outputs.cache-hit != 'true'
run: cargo install espflash
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: touch-n-drink-elf
- name: Generate ESP32 image
run: espflash save-image --chip esp32c3 --merge --skip-padding touch-n-drink touch-n-drink-esp32c3.bin
- name: Generate SHA-256 checksum
run: shasum -a 256 touch-n-drink-esp32c3.bin >touch-n-drink-esp32c3.sha256
- name: Upload image artifact
uses: actions/upload-artifact@v4
with:
name: touch-n-drink-esp32c3
path: |
touch-n-drink-esp32c3*
if-no-files-found: error
release:
name: Release
permissions:
contents: write
needs: [image]
if: github.repository == 'zargony/touch-n-drink' && startsWith(github.ref, 'refs/tags/firmware-')
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
sparse-checkout: |
firmware/CHANGELOG.md
- name: Download image artifact
uses: actions/download-artifact@v4
with:
name: touch-n-drink-esp32c3
- name: Release
uses: softprops/action-gh-release@v2
with:
body_path: firmware/CHANGELOG.md
draft: true
files: |
touch-n-drink*
fail_on_unmatched_files: true