-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (129 loc) · 3.5 KB
/
build_and_release.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
138
139
140
141
142
name: Build & Release
permissions:
contents: write
on:
push:
tags:
- "v*"
jobs:
format:
name: fmt
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install toolchain
uses: dtolnay/rust-toolchain@1.73.0
with:
components: rustfmt
- name: Check formatting
run: |
cargo fmt --all -- --check
clippy:
name: clippy
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install toolchain
uses: dtolnay/rust-toolchain@1.73.0
with:
components: clippy
- name: Check the lints
run: |
cargo clippy -- -D warnings
test:
name: test
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install toolchain
uses: dtolnay/rust-toolchain@1.73.0
- name: Unit Test
run: |
cargo test --workspace
env:
RUST_BACKTRACE: 1
build:
name: Build and release
needs: [format, clippy, test]
runs-on: ${{ matrix.os }}-latest
strategy:
matrix:
target:
[
x86_64-apple-darwin,
aarch64-unknown-linux-gnu,
x86_64-unknown-linux-gnu,
aarch64-apple-darwin,
]
include:
- target: x86_64-apple-darwin
os: macos
- target: x86_64-unknown-linux-gnu
os: ubuntu
- target: aarch64-unknown-linux-gnu
os: ubuntu
- target: aarch64-apple-darwin
os: macos
steps:
- name: Install toolchain for ${{ matrix.target }}
uses: dtolnay/rust-toolchain@1.73.0
with:
targets: ${{ matrix.target }}
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install cross
if: ${{ matrix.os }} == 'ubuntu'
run: cargo install cross
- name: Build
run: |
cross build --release --bins --target ${{ matrix.target }}
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: cl-${{ matrix.target }}
path: target/${{ matrix.target }}/release/
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download darwin_aarch64
uses: actions/download-artifact@v4
with:
name: cl-aarch64-apple-darwin
path: target/aarch64-apple-darwin/release/
- name: Download darwin_x86_64
uses: actions/download-artifact@v4
with:
name: cl-x86_64-apple-darwin
path: target/x86_64-apple-darwin/release/
- name: Download linux_aarch64
uses: actions/download-artifact@v4
with:
name: cl-aarch64-unknown-linux-gnu
path: target/aarch64-unknown-linux-gnu/release/
- name: Download linux_x86_64
uses: actions/download-artifact@v4
with:
name: cl-x86_64-unknown-linux-gnu
path: target/x86_64-unknown-linux-gnu/release/
- name: Set up Go
uses: actions/setup-go@v4
- name: Release binaries
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Check Result
run: |
cat result.done