Skip to content

Commit f4372ea

Browse files
authored
Merge pull request #49 from adafruit/improve-ci
Enhance CI to use with Arduino IDE
2 parents 64168cd + c27ec17 commit f4372ea

File tree

2 files changed

+83
-110
lines changed

2 files changed

+83
-110
lines changed

.github/workflows/nightly-release.yml

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

.github/workflows/rust.yml

Lines changed: 83 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,121 @@ name: Rust
22

33
on:
44
push:
5-
branches: [ main ]
65
paths:
76
- "Cargo.toml"
87
- "src/**"
98
- "devices/**"
109
- "!**.md"
10+
- ".github/workflows/rust.yml"
1111
pull_request:
1212
branches: [ main ]
1313
paths:
1414
- "Cargo.toml"
1515
- "src/**"
1616
- "devices/**"
1717
- "!**.md"
18+
- ".github/workflows/rust.yml"
1819
workflow_dispatch:
20+
release:
21+
types:
22+
- created
23+
schedule: # Every day at the 2 P.M. (UTC) we run a scheduled nightly build
24+
- cron: "0 14 * * *"
25+
26+
concurrency:
27+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
28+
cancel-in-progress: true
1929

2030
env:
2131
CARGO_TERM_COLOR: always
2232

2333
jobs:
2434
build:
25-
name: build (${{ matrix.config.os }})
35+
name: build (${{ matrix.config.arch }})
2636
strategy:
2737
matrix:
2838
config:
2939
- os: windows-latest
40+
arch: win-x64
3041
- os: ubuntu-latest
42+
arch: linux-x64
3143
- os: macos-latest
44+
arch: macos-arm64
45+
- os: macos-12
46+
arch: macos-x64
3247
runs-on: ${{ matrix.config.os }}
3348

3449
steps:
35-
- uses: actions/checkout@v3
50+
- uses: actions/checkout@v4
3651
- name: Build
3752
run: cargo build --release
3853
- name: Run tests
3954
run: cargo test
4055
- name: Run help
4156
run: cargo run -- --help
42-
- uses: actions/upload-artifact@v3
57+
58+
- name: Prepare artifacts
59+
run: |
60+
if [[ "${{ runner.os }}" == "Windows" ]]; then
61+
WCHISP_EXE="wchisp.exe"
62+
else
63+
WCHISP_EXE="wchisp"
64+
fi
65+
66+
mkdir wchisp-${{ matrix.config.arch }}
67+
cp target/release/$WCHISP_EXE wchisp-${{ matrix.config.arch }}
68+
cp README.md wchisp-${{ matrix.config.arch }}
69+
shell: bash
70+
- uses: actions/upload-artifact@v4
71+
with:
72+
name: wchisp-${{ matrix.config.arch }}
73+
path: wchisp-${{ matrix.config.arch }}
74+
75+
- name: Prepare Release Asset
76+
if: github.event_name == 'release'
77+
run: |
78+
if [[ "${{ runner.os }}" == "Windows" ]]; then
79+
7z a -tzip wchisp-${{ github.event.release.tag_name }}-${{ matrix.config.arch }}.zip wchisp-${{ matrix.config.arch }}
80+
else
81+
zip -r wchisp-${{ github.event.release.tag_name }}-${{ matrix.config.arch }}.zip wchisp-${{ matrix.config.arch }}
82+
fi
83+
shell: bash
84+
- name: Upload Release Asset
85+
uses: softprops/action-gh-release@v1
86+
if: github.event_name == 'release'
4387
with:
44-
name: wchisp-${{ matrix.config.os }}
45-
path: target/debug/wchisp*
88+
files: |
89+
wchisp-${{ github.event.release.tag_name }}-${{ matrix.config.arch }}.zip
90+
91+
nightly-release:
92+
needs: build
93+
runs-on: ubuntu-latest
94+
if: github.event_name == 'schedule'
95+
steps:
96+
- name: Download Artifacts
97+
uses: actions/download-artifact@v4
98+
with:
99+
path: ./
100+
101+
- name: Prepare Nightly Asset
102+
run: |
103+
ls -R ./
104+
for f in wchisp-*; do
105+
echo "Compressing $f with zip -r $f.zip $f"
106+
zip -r $f.zip $f
107+
done
108+
ls ./
109+
110+
- name: Update Nightly Release
111+
uses: andelf/nightly-release@main
112+
env:
113+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
114+
with:
115+
tag_name: nightly
116+
name: "wchisp nightly release $$"
117+
draft: false
118+
prerelease: true
119+
body: |
120+
This is a nightly binary release of the wchisp command line tool.
121+
files: |
122+
wchisp-*.zip

0 commit comments

Comments
 (0)