-
Notifications
You must be signed in to change notification settings - Fork 1
137 lines (129 loc) · 4.09 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
131
132
133
134
135
136
137
name: Continuous Integration
on:
push:
branches: [main]
tags: ['v*']
pull_request:
jobs:
format:
name: Format
runs-on: ubuntu-latest
steps:
- name: Debug
run: |
echo "github.ref = ${{ github.ref }}"
echo "github.event_name = ${{ github.event_name }}"
- name: Checkout source
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
targets: thumbv7em-none-eabihf
components: rustfmt
- name: Check format
run: cargo fmt --all -- --check
check:
name: Check
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Cache Rust
uses: swatinem/rust-cache@v2
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
targets: thumbv7em-none-eabihf
- run: cargo install flip-link
- run: cargo check
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
targets: thumbv7em-none-eabihf
components: clippy
- name: Check clippy
run: cargo clippy --all-features --locked -- -D warnings
release:
name: Release
runs-on: ubuntu-latest
needs: [check, format, clippy]
if: startsWith(github.ref, 'refs/tags/v')
outputs:
version: ${{ steps.get-version.outputs.filename }}
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Cache Rust
uses: swatinem/rust-cache@v2
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
targets: thumbv7em-none-eabihf
- run: cargo install flip-link
- run: cargo install cargo-binutils
- run: |
# required by binutils
rustup component add llvm-tools-preview
- name: Get tag version
id: get-tag
run: |
# Remove 'v' prefix from tag
TAG_VERSION=${GITHUB_REF#refs/tags/v}
echo "tag_version=${TAG_VERSION}" >> $GITHUB_OUTPUT
- name: Get Cargo.toml version
id: get-cargo-version
run: |
CARGO_VERSION=$(grep -m1 '^version\s*=' Cargo.toml | cut -d'"' -f2)
echo "cargo_version=${CARGO_VERSION}" >> $GITHUB_OUTPUT
- name: Compare versions
id: get-version
run: |
TAG_VERSION="${{ steps.get-tag.outputs.tag_version }}"
CARGO_VERSION="${{ steps.get-cargo-version.outputs.cargo_version }}"
if [ "$TAG_VERSION" != "$CARGO_VERSION" ]; then
echo "Error: Version mismatch!"
echo "Tag version: $TAG_VERSION"
echo "Cargo.toml version: $CARGO_VERSION"
exit 1
fi
echo "version=${TAG_VERSION}" >> $GITHUB_OUTPUT
echo "Versions match: ${TAG_VERSION}"
echo "filename=umi-adapter-v${TAG_VERSION}.bin" >> $GITHUB_OUTPUT
- run: cargo objcopy --release -- -O binary ${{ steps.get-version.outputs.filename }}
- name: Install dfu-utils
run: sudo apt-get install -y dfu-util
- run: dfu-suffix --vid 1209 --pid 2323 --add ${{ steps.get-version.outputs.filename }}
- uses: actions/upload-artifact@v4
with:
name: ${{ steps.get-version.outputs.filename }}
path: ${{ steps.get-version.outputs.filename }}
if-no-files-found: error
announce:
name: Announce
runs-on: ubuntu-latest
permissions:
contents: write
needs: [release]
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout source
uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Create GitHub release
uses: ncipollo/release-action@v1
with:
artifacts: "artifacts/*"