-
Notifications
You must be signed in to change notification settings - Fork 203
272 lines (253 loc) · 10.9 KB
/
release.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
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
265
266
267
268
269
270
271
272
name: Hayabusa Release Automation
on:
workflow_dispatch:
inputs:
release_ver:
required: true
default: "2.x.x"
description: "Version of the release"
branch_or_tag:
required: true
default: "main"
description: "Branch or Tag to checkout"
jobs:
upload:
runs-on: ${{ matrix.info.os }}
strategy:
matrix:
info:
- {
os: "windows-latest",
target: "x86_64-pc-windows-msvc",
cross: false,
}
- {
os: "windows-2022",
target: "i686-pc-windows-msvc",
cross: true,
}
- {
os: "windows-2019",
target: "aarch64-pc-windows-msvc",
cross: true,
}
- {
os: "ubuntu-latest",
target: "x86_64-unknown-linux-gnu",
cross: false,
}
- {
os: "ubuntu-24.04",
target: "aarch64-unknown-linux-gnu",
cross: true,
}
- {
os: "ubuntu-22.04",
target: "x86_64-unknown-linux-musl",
cross: true,
}
- {
os: "macos-latest",
target: "aarch64-apple-darwin",
cross: false
}
- {
os: "macos-13",
target: "x86_64-apple-darwin",
cross: false
}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch_or_tag }}
submodules: 'true'
- name: Clone hayabusa rule repo
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
repository: Yamato-Security/hayabusa-rules
fetch-depth: 0
path: hayabusa-rules
- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.info.target }}
- name: Install musl-tools
if: matrix.info.target == 'x86_64-unknown-linux-musl' == true
run: |
sudo apt-get update
sudo apt-get install -y musl-tools
- name: Build Hayabusa binary
run: |
cargo run --release -- update-rules -q
cargo build --release --target ${{ matrix.info.target }}
- name: Package and Zip - Windows
if: contains(matrix.info.os, 'windows') == true
shell: pwsh
run: |
mkdir -p release-binaries
mkdir -p release-binaries/logs
Copy-Item -Path ./target/release/hayabusa.exe -Destination release-binaries/
Copy-Item -Recurse -Path ./config -Destination release-binaries/
Remove-Item -Path ./hayabusa-rules/.gitignore -Force
Remove-Item -Path ./hayabusa-rules/*.md -Force
Remove-Item -Path ./hayabusa-rules/.github -Recurse -Force
Remove-Item -Path ./hayabusa-rules/scripts -Recurse -Force
Remove-Item -Path ./hayabusa-rules/doc -Recurse -Force
Copy-Item -Recurse -Path ./hayabusa-rules/ -Destination release-binaries/rules -Force
switch ("${{ matrix.info.os }}") {
"windows-latest" { mv release-binaries/hayabusa.exe release-binaries/hayabusa-${{ github.event.inputs.release_ver }}-win-x64.exe }
"windows-2022" { mv release-binaries/hayabusa.exe release-binaries/hayabusa-${{ github.event.inputs.release_ver }}-win-x86.exe }
"windows-2019" { mv release-binaries/hayabusa.exe release-binaries/hayabusa-${{ github.event.inputs.release_ver }}-win-arm.exe }
}
- name: Package and Zip(encoded_rule) - Windows
if: contains(matrix.info.os, 'windows') == true
shell: pwsh
run: |
mkdir -p release-binaries-encoded-rules
mkdir -p release-binaries-encoded-rules/logs
Copy-Item -Path ./target/release/hayabusa.exe -Destination release-binaries-encoded-rules/
Invoke-WebRequest -Uri https://raw.githubusercontent.com/Yamato-Security/hayabusa-encoded-rules/refs/heads/main/encoded_rules.yml -OutFile release-binaries-encoded-rules/encoded_rules.yml
Invoke-WebRequest -Uri https://raw.githubusercontent.com/Yamato-Security/hayabusa-encoded-rules/refs/heads/main/rules_config_files.txt -OutFile release-binaries-encoded-rules/rules_config_files.txt
switch ("${{ matrix.info.os }}") {
"windows-latest" { mv release-binaries-encoded-rules/hayabusa.exe release-binaries-encoded-rules/hayabusa-${{ github.event.inputs.release_ver }}-win-x64.exe }
"windows-2022" { mv release-binaries-encoded-rules/hayabusa.exe release-binaries-encoded-rules/hayabusa-${{ github.event.inputs.release_ver }}-win-x86.exe }
"windows-2019" { mv release-binaries-encoded-rules/hayabusa.exe release-binaries-encoded-rules/hayabusa-${{ github.event.inputs.release_ver }}-win-arm.exe }
}
- name: Package and Zip - Unix
if: contains(matrix.info.os, 'windows') == false
run: |
mkdir -p release-binaries
cp ./target/release/hayabusa release-binaries/
cp -r ./config release-binaries/config
cp -r ./logs release-binaries/logs
rm -f ./hayabusa-rules/.gitignore
rm -f ./hayabusa-rules/*.md
rm -rf ./hayabusa-rules/.github
rm -rf ./hayabusa-rules/scripts
rm -rf ./hayabusa-rules/doc
cp -r ./hayabusa-rules/. release-binaries/rules
case ${{ matrix.info.os }} in
'ubuntu-latest')
mv release-binaries/hayabusa release-binaries/hayabusa-${{ github.event.inputs.release_ver }}-lin-intel-x64-gnu ;;
'ubuntu-24.04')
mv release-binaries/hayabusa release-binaries/hayabusa-${{ github.event.inputs.release_ver }}-lin-intel-x64-musl ;;
'ubuntu-22.04')
mv release-binaries/hayabusa release-binaries/hayabusa-${{ github.event.inputs.release_ver }}-lin-arm-x64-gnu ;;
'ubuntu-20.04')
mv release-binaries/hayabusa release-binaries/hayabusa-${{ github.event.inputs.release_ver }}-lin-arm-x64-musl ;;
'macos-latest')
mv release-binaries/hayabusa release-binaries/hayabusa-${{ github.event.inputs.release_ver }}-mac-aarch64 ;;
'macos-13')
mv release-binaries/hayabusa release-binaries/hayabusa-${{ github.event.inputs.release_ver }}-mac-x64 ;;
esac
- name: Set Artifact Name
id: set_artifact_name
shell: bash
run: |
case "${{ matrix.info.os }}" in
'windows-latest')
echo "artifact_name=hayabusa-${{ github.event.inputs.release_ver }}-win-x64" >> $GITHUB_OUTPUT ;;
'windows-2022')
echo "artifact_name=hayabusa-${{ github.event.inputs.release_ver }}-win-x86" >> $GITHUB_OUTPUT ;;
'windows-2019')
echo "artifact_name=hayabusa-${{ github.event.inputs.release_ver }}-win-arm" >> $GITHUB_OUTPUT ;;
'ubuntu-latest')
echo "artifact_name=hayabusa-${{ github.event.inputs.release_ver }}-linux-intel-gnu" >> $GITHUB_OUTPUT ;;
'ubuntu-24.04')
echo "artifact_name=hayabusa-${{ github.event.inputs.release_ver }}-linux-intel-musl" >> $GITHUB_OUTPUT ;;
'ubuntu-22.04')
echo "artifact_name=hayabusa-${{ github.event.inputs.release_ver }}-linux-arm-gnu" >> $GITHUB_OUTPUT ;;
'ubuntu-20.04')
echo "artifact_name=hayabusa-${{ github.event.inputs.release_ver }}-linux-arm-musl" >> $GITHUB_OUTPUT ;;
'macos-latest')
echo "artifact_name=hayabusa-${{ github.event.inputs.release_ver }}-mac-arm" >> $GITHUB_OUTPUT ;;
'macos-13')
echo "artifact_name=hayabusa-${{ github.event.inputs.release_ver }}-mac-intel" >> $GITHUB_OUTPUT ;;
esac
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ steps.set_artifact_name.outputs.artifact_name }}
path: release-binaries/*
include-hidden-files: true
- name: Set Artifact Name(encoded_rule)
if: contains(matrix.info.os, 'windows') == true
id: set_artifact_name_encoded_rule
shell: bash
run: |
case "${{ matrix.info.os }}" in
'windows-latest')
echo "artifact_name=hayabusa-${{ github.event.inputs.release_ver }}-win-x64-live-response" > $GITHUB_OUTPUT ;;
'windows-2022')
echo "artifact_name=hayabusa-${{ github.event.inputs.release_ver }}-win-x86-live-response" > $GITHUB_OUTPUT ;;
'windows-2019')
echo "artifact_name=hayabusa-${{ github.event.inputs.release_ver }}-win-arm-live-response" > $GITHUB_OUTPUT ;;
esac
- name: Upload Artifacts(encoded_rule)
if: contains(matrix.info.os, 'windows') == true
uses: actions/upload-artifact@v4
with:
name: ${{ steps.set_artifact_name_encoded_rule.outputs.artifact_name }}
path: release-binaries-encoded-rules/*
include-hidden-files: true
- name: Setup node
if: matrix.info.os == 'macos-latest'
uses: actions/setup-node@v4
with:
node-version: 20
- name: Create PDF
if: matrix.info.os == 'macos-latest'
run: |
npm i -g md-to-pdf
md-to-pdf ./*.md --md-file-encoding utf-8
mv ./README.pdf ./README-${{ github.event.inputs.release_ver }}-English.pdf
mv ./README-Japanese.pdf ./README-${{ github.event.inputs.release_ver }}-Japanese.pdf
- name: Upload Document Artifacts
if: matrix.info.os == 'macos-latest'
uses: actions/upload-artifact@v4
with:
name: hayabusa-documents
path: |
./*.pdf
upload-all-platforms:
needs: upload
runs-on: ubuntu-latest
steps:
- name: Download All Artifacts
uses: actions/download-artifact@v4
with:
path: all-packages
pattern: hayabusa-*
merge-multiple: true
- run: |
rm -rf all-packages/encoded_rules.yml
rm -rf all-packages/rules_config_files.txt
- name: Upload Artifacts(all-platforms)
uses: actions/upload-artifact@v4
with:
name: hayabusa-${{ github.event.inputs.release_ver }}-all-platforms
path: all-packages/*
include-hidden-files: true
all-packages-zip:
needs: upload-all-platforms
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: all-packages
pattern: hayabusa-*
- run: |
ls -lR all-packages
cd all-packages
for dir in */; do
zip -r "${dir%/}.zip" "$dir"
done
- name: Upload Zip Artifacts(all-packages)
uses: actions/upload-artifact@v4
with:
name: all-packages
path: all-packages/*.zip