-
Notifications
You must be signed in to change notification settings - Fork 5
145 lines (120 loc) · 4.02 KB
/
rust.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
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
138
139
140
141
142
143
144
145
name: Rust
on: [push]
env:
CARGO_TERM_COLOR: always
jobs:
# check and build
build:
strategy:
fail-fast: false
matrix:
job:
- target: x86_64-unknown-linux-gnu
os: linux
runs-on: ubuntu-latest
- target: x86_64-pc-windows-gnu
os: windows
runs-on: windows-latest
- target: aarch64-apple-darwin
os: macos
runs-on: macos-latest
runs-on: ${{ matrix.job.runs-on }}
env:
DEBIAN_FRONTEND: noninteractive
steps:
- uses: actions/checkout@v4
- uses: mitoma/sver-actions/setup@v2
with:
os: ${{ matrix.job.os }}
# Use libudev-dev if OS is linux
- name: install libudev-dev
if: matrix.job.os == 'linux'
run: sudo apt-get install libudev-dev
# ci phase
- name: check all
uses: mitoma/sver-actions/exec@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
phase: check-${{ matrix.job.target }}
command: |
cargo fmt --all -- --check
cargo clippy --tests --examples -- -D clippy::all
cargo build
cargo test
cache_save_enable: true
cache_key: ${{ matrix.job.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
cache_restore-keys: ${{ matrix.job.target }}-cargo-
cache_path: |
~/.cargo/registry
~/.cargo/git
# build and upload artifact
build_artifact:
# run on branch [main] or tag [v*]
if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) }}
needs: [build]
strategy:
fail-fast: false
matrix:
job:
- target: x86_64-unknown-linux-gnu
os: linux
runs-on: ubuntu-latest
- target: x86_64-pc-windows-gnu
os: windows
runs-on: windows-latest
- target: aarch64-apple-darwin
os: macos
runs-on: macos-latest
runs-on: ${{ matrix.job.runs-on }}
steps:
- uses: actions/checkout@v4
- uses: mitoma/sver-actions/setup@v2
with:
os: ${{ matrix.job.os }}
# Use libudev-dev if OS is linux
- name: install libudev-dev
if: matrix.job.os == 'linux'
run: sudo apt-get install libudev-dev
# artifact phase
- name: build artifact
uses: mitoma/sver-actions/exec@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
phase: artifact-${{ matrix.job.target }}
command: |
rustup target add "${{ matrix.job.target }}"
# release build for create artifact
cargo build --bin kashikishi --release --target=${{ matrix.job.target }}
mkdir artifact
cd artifact
cp ../LICENSE .
cp ../README.md .
if [[ "${{ matrix.job.os }}" == windows ]]; then
cp ../target/${{ matrix.job.target }}/release/kashikishi.exe .
else
cp ../target/${{ matrix.job.target }}/release/kashikishi .
fi
cache_key: kashikishi-${{ matrix.job.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
cache_restore-keys: kashikishi-${{ matrix.job.target }}-cargo-
cache_path: |
~/.cargo/registry
~/.cargo/git
target
artifact_name: kashikishi-${{ matrix.job.target }}
artifact_path: artifact
# release kashikishi
release_kashikishi:
# run on tag [v*]
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }}
needs: [build_artifact]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: mitoma/sver-actions/setup@v2
- id: extract_tag
name: Extract tag name
run: echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
- name: create release
run: ./release.sh "${{ steps.extract_tag.outputs.tag }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}