-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (63 loc) · 1.95 KB
/
rust_ci.yml
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
name: Continuous Integration
on:
push:
branches: ["master"]
tags: ["v*"]
pull_request:
branches: ["master"]
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Enable caching
uses: Swatinem/rust-cache@v2
- name: Run fmt command
run: cargo fmt --all -- --check --color always
- name: Run clippy command
run: cargo clippy --all-targets --all-features --workspace -- -D warnings
deploy:
if: github.ref_type == 'tag'
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
env:
PACKAGE_NAME: ${{github.event.repository.name}}-${{matrix.chip}}-${{github.ref_name}}
strategy:
matrix:
chip: ["nrf52840"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Validate version
run: |
export CARGO_VERSION=v$(awk '/^version/ {print $3}' Cargo.toml | head -1 | tr -d '"')
export GIT_VERSION=${{github.ref_name}}
echo "Cargo version: $CARGO_VERSION"
echo "Git version: $GIT_VERSION"
if [[ "${CARGO_VERSION}" != "$GIT_VERSION" ]]; then
echo "Tag version and Cargo.toml version don't match" 1>&2
exit 1
fi
- name: Enable caching
uses: Swatinem/rust-cache@v2
- name: Run build command
env:
DEFMT_LOG: info
run: cargo build --release
- name: Package
run: |
mkdir $PACKAGE_NAME
cp target/thumbv7em-none-eabihf/release/tempsys-firmware ${PACKAGE_NAME}/
cp -r README.md LICENSE $PACKAGE_NAME/
tar -czvf ${PACKAGE_NAME}.tar.gz $PACKAGE_NAME
- name: Publish release
uses: ghalactic/github-release-from-tag@v5
with:
generateReleaseNotes: "true"
assets: |
- path: ${{env.PACKAGE_NAME}}.tar.gz