-
-
Notifications
You must be signed in to change notification settings - Fork 1
198 lines (175 loc) · 5 KB
/
build_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
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
name: Rust
on:
push:
branches:
- main
- beta
paths-ignore:
- '*.md'
pull_request:
paths-ignore:
- '*.md'
env:
CARGO_TERM_COLOR: always
jobs:
get-next-version:
name: Get next version
uses: lenra-io/github-actions/.github/workflows/get-version.yml@main
style:
name: Check Style
runs-on: ubuntu-20.04
timeout-minutes: 2
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt
profile: minimal
override: true
- name: cargo fmt -- --check
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
test:
name: Test
needs: [style]
runs-on: ubuntu-20.04
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Build debug
uses: actions-rs/cargo@v1
with:
command: build
args: --verbose
- name: Test
uses: actions-rs/cargo@v1
with:
command: test
args: --verbose
build:
name: Build ${{ matrix.os }} ${{ matrix.arch }}
needs: [test, get-next-version]
runs-on: "${{ matrix.runner }}"
env:
VERSION: ${{ needs.get-next-version.outputs.version }}
timeout-minutes: 20
strategy:
matrix: # Need to find what's the best target for `x86-x64-linux` and remove the others (gnu or musl)
include:
- target: aarch64-unknown-linux-musl
os: linux
arch: aarch64
runner: ubuntu-20.04
- target: x86_64-unknown-linux-musl
os: linux
arch: x86_64
runner: ubuntu-20.04
- target: x86_64-pc-windows-msvc
os: windows
arch: x86_64
runner: windows-2022
file_extension: '.exe'
- target: aarch64-pc-windows-msvc
os: windows
arch: aarch64
runner: windows-2022
file_extension: '.exe'
- target: x86_64-apple-darwin
os: macos
arch: x86_64
runner: macos-11
- target: aarch64-apple-darwin
os: macos
arch: aarch64
runner: macos-11
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
target: ${{ matrix.target }}
- name: Install cargo-edit
uses: actions-rs/cargo@v1
with:
command: install
args: cargo-edit
- name: Set version
uses: actions-rs/cargo@v1
with:
command: set-version
args: ${{ env.VERSION }}
- name: Build target
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --release -F cli --target ${{ matrix.target }}
- name: Zip
if: ${{ matrix.os == 'windows' }}
shell: pwsh
run: Compress-Archive "target/${{ matrix.target }}/release/dofigen${{ matrix.file_extension }}" "dofigen-${{ matrix.os }}-${{ matrix.arch }}.zip"
- name: Zip
if: ${{ matrix.os != 'windows' }}
shell: bash
run: tar -C "target/${{ matrix.target }}/release" -czf "dofigen-${{ matrix.os }}-${{ matrix.arch }}.tar.gz" "dofigen${{ matrix.file_extension }}"
- name: Upload
uses: actions/upload-artifact@v3
with:
name: dofigen-${{ matrix.os }}-${{ matrix.arch }}
path: dofigen-${{ matrix.os }}-${{ matrix.arch }}.*
publish:
name: publish
needs: [build, get-next-version]
if: github.ref_name == 'main' || github.ref_name == 'beta'
uses: lenra-io/github-actions/.github/workflows/release.yml@main
with:
download-artifacts: true
assets: artifacts/
publish-cargo:
name: publish-cargo
needs: [build, get-next-version, publish]
if: github.ref_name == 'main' || github.ref_name == 'beta'
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.get-next-version.outputs.version }}
steps:
- name: Checkout
if: ${{ needs.get-next-version.outputs.will-release }}
uses: actions/checkout@v3
- name: download-artifacts
if: ${{ needs.get-next-version.outputs.will-release }}
uses: actions/download-artifact@v3
with:
path: artifacts/
- name: Install cargo-edit
if: ${{ needs.get-next-version.outputs.will-release }}
uses: actions-rs/cargo@v1
with:
command: install
args: cargo-edit
- name: Set version
if: ${{ needs.get-next-version.outputs.will-release }}
uses: actions-rs/cargo@v1
with:
command: set-version
args: ${{ env.VERSION }}
- name: Publish cargo
if: ${{ needs.get-next-version.outputs.will-release }}
shell: bash
run: cargo publish -p dofigen --allow-dirty --token "${{ secrets.CARGO_TOKEN }}"