-
Notifications
You must be signed in to change notification settings - Fork 1
264 lines (207 loc) · 7.93 KB
/
ci.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
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
name: CI
on:
push:
branches:
- 'byc'
tags:
- 'v*'
name: Continuous Integration
env:
CARGO_TERM_COLOR: always
jobs:
cancel-previous-build:
runs-on: ubuntu-latest
steps:
- name: Cancel Running Workflows
uses: styfle/cancel-workflow-action@0.10.0
with:
access_token: ${{ github.token }}
build:
needs: cancel-previous-build
strategy:
matrix:
os: [windows-latest,ubuntu-latest]
runs-on: ${{ matrix.os }}
permissions:
contents: write
steps:
- name: Cancel previous
uses: styfle/cancel-workflow-action@0.10.0
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v4
with:
fetch-tags: true
- uses: ilammy/msvc-dev-cmd@v1
- name: Display Cpu Information(Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
echo "Cpu Information :"
lscpu
- name: Display Memory Information(Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
echo "Memory Information :"
free -h
steps:
- name: Display Cpu Information(Windows)
if: matrix.os == 'windows-latest'
run: |
echo "Cpu Information :"
Get-WmiObject -Query "Select * from Win32_Processor"
- name: Display Memory Information(Windows)
if: matrix.os == 'windows-latest'
run: |
echo "Memory Information :"
Get-WmiObject -Query "Select * from Win32_OperatingSystem" | fl TotalVisibleMemorySize,FreePhysicalMemory
- name: Define Binary Name(Windows)
if: matrix.os == 'windows-latest'
run: echo "BINARY_NAME=rxqlited" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Define Binary Name(Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: echo "BINARY_NAME=rxqlited" >> $GITHUB_ENV
- run: git fetch --no-tags --prune --depth=1 origin +refs/tags/*:refs/tags/*
- name: Get latest tag (Windows)
if: matrix.os == 'windows-latest'
id: get_tag_windows
run: |
$tag = git describe --tags $(git rev-list --tags --max-count=1)
echo "TAG=$tag" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
shell: pwsh
- name: Latest tag (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: git describe --tags `git rev-list --tags --max-count=1`
- name: Get latest tag (Ubuntu)
if: matrix.os == 'ubuntu-latest'
id: get_tag_ubuntu
run: echo "TAG=$(git describe --tags `git rev-list --tags --max-count=1`)" >> $GITHUB_ENV
- name: Print latest tag
run: echo "Latest tag is ${{ env.TAG }}"
- name: Install dependencies (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get update && sudo apt-get install -y build-essential
- name: Install Clang(Windows)
if: matrix.os == 'windows-latest'
run: choco install llvm
- name: Add libclang to PATH(Windows)
if: matrix.os == 'windows-latest'
run: echo "C:/Program Files/LLVM/bin" >> $GITHUB_PATH
- name: Install NASM(Windows)
if: matrix.os == 'windows-latest'
run: choco install nasm -y
- name: Install Clang(Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get install -y clang
- name: Set target triple (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: echo "TARGET_TRIPLE=x86_64-unknown-linux-gnu" >> $GITHUB_ENV
- name: Set target triple (Windows)
if: matrix.os == 'windows-latest'
run: echo "TARGET_TRIPLE=x86_64-pc-windows-msvc" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Update local toolchain
run: |
rustup update
- name: Display Rust Version
run: |
cargo -vV
rustc -vV
- name: Build(Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: cargo build --release --target ${{ env.TARGET_TRIPLE }}
env:
CARGO_TERM_COLOR: always
TMPDIR: ${{ runner.temp }}
RXQLITED_DIR: ${{ github.workspace }}/target/${{ env.TARGET_TRIPLE }}/release
- name: Build(Windows)
if: matrix.os == 'windows-latest'
run: cargo build --release --target ${{ env.TARGET_TRIPLE }}
env:
CARGO_TERM_COLOR: always
TEMP: ${{ runner.temp }}
RXQLITED_DIR: ${{ github.workspace }}/target/${{ env.TARGET_TRIPLE }}/release
- name: Test(Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: cargo test --release --target ${{ env.TARGET_TRIPLE }} -- --nocapture
env:
CARGO_TERM_COLOR: always
TMPDIR: ${{ runner.temp }}
RXQLITED_DIR: ${{ github.workspace }}/target/${{ env.TARGET_TRIPLE }}/release
- name: Test(Windows)
if: matrix.os == 'windows-latest'
run: cargo test --release --target ${{ env.TARGET_TRIPLE }} -- --nocapture
env:
CARGO_TERM_COLOR: always
TEMP: ${{ runner.temp }}
RXQLITED_DIR: ${{ github.workspace }}/target/${{ env.TARGET_TRIPLE }}/release
- name: Strip(Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: strip -s target/${{ env.TARGET_TRIPLE }}/release/${{ env.BINARY_NAME }}
- name: Install zip (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get install zip
- name: Install 7zip (Windows)
if: matrix.os == 'windows-latest'
run: choco install 7zip
- name: Name The Artifcat Archive(Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: echo "ARTIFACT_ARCHIVE=./${{ env.BINARY_NAME }}-ubuntu.zip" >> $GITHUB_ENV
- name: Name The Artifcat Archive(Windows)
if: matrix.os == 'windows-latest'
run: echo "ARTIFACT_ARCHIVE=./${{ env.BINARY_NAME }}-win32.zip" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Zip the executable(Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: cd ./target/${{ env.TARGET_TRIPLE }}/release && zip ./../../../${{ env.ARTIFACT_ARCHIVE }} ${{ env.BINARY_NAME }} && cd -
- name: Zip the executable(Windows)
if: matrix.os == 'windows-latest'
run: 7z a ${{ env.ARTIFACT_ARCHIVE }} ./target/${{ env.TARGET_TRIPLE }}/release/${{ env.BINARY_NAME }}.exe
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ runner.os }}-artifact
path: ${{ env.ARTIFACT_ARCHIVE }}
deploy:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-tags: true
- name: Define Binary Name(Windows)
if: runner.os == 'Windows'
run: echo "BINARY_NAME=rxqlited" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Define Binary Name(Ubuntu)
if: runner.os == 'Linux'
run: echo "BINARY_NAME=rxqlited" >> $GITHUB_ENV
- run: git fetch --no-tags --prune --depth=1 origin +refs/tags/*:refs/tags/*
- name: Get latest tag
id: get_tag_ubuntu
run: echo "TAG=$(git describe --tags `git rev-list --tags --max-count=1`)" >> $GITHUB_ENV
- name: Print latest tag
run: echo "Latest tag is ${{ env.TAG }}"
- name: Download Windows Artifact
uses: actions/download-artifact@v3
with:
path: "."
name: Windows-artifact
- name: Download Ubuntu Artifact
uses: actions/download-artifact@v3
with:
path: "."
name: Linux-artifact
- name: List Files
run: ls -R
- name: Delete release if exists
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref_name }}
run: |
gh release delete ${{ env.TAG }} -y
continue-on-error: true
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref_name }}
run: |
gh release create ${{ env.TAG }} ./${{ env.BINARY_NAME }}-win32.zip ./${{ env.BINARY_NAME }}-ubuntu.zip