-
Notifications
You must be signed in to change notification settings - Fork 2
341 lines (304 loc) · 11.3 KB
/
release.yml
File metadata and controls
341 lines (304 loc) · 11.3 KB
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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
name: Release
on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:
inputs:
tag:
description: 'Tag to release'
required: true
type: string
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
release_id: ${{ steps.create_release.outputs.id }}
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Get version from tag
id: get_version
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
VERSION="${{ github.event.inputs.tag }}"
else
VERSION=${GITHUB_REF#refs/tags/}
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "version_number=${VERSION#v}" >> $GITHUB_OUTPUT
- name: Generate changelog
id: changelog
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
TAG="${{ github.event.inputs.tag }}"
else
TAG=${GITHUB_REF#refs/tags/}
fi
# Get previous tag
PREV_TAG=$(git describe --tags --abbrev=0 $TAG^ 2>/dev/null || echo "")
if [ -n "$PREV_TAG" ]; then
echo "## Changes since $PREV_TAG" > changelog.md
echo "" >> changelog.md
git log --pretty=format:"- %s (%h)" $PREV_TAG..$TAG >> changelog.md
else
echo "## Initial Release" > changelog.md
echo "" >> changelog.md
echo "First release of ClamReef Agent" >> changelog.md
fi
echo "" >> changelog.md
echo "## Features" >> changelog.md
echo "- 🔒 Comprehensive endpoint protection monitoring" >> changelog.md
echo "- 📊 Rich host metrics with system information" >> changelog.md
echo "- ⏱️ Performance analytics and scan duration tracking" >> changelog.md
echo "- 🗓️ Automated ClamAV scanning with cron schedules" >> changelog.md
echo "- 📡 OpenTelemetry integration for observability" >> changelog.md
echo "- 🌐 Cross-platform support (Linux, macOS, Windows)" >> changelog.md
echo "" >> changelog.md
echo "## Installation" >> changelog.md
echo '```bash' >> changelog.md
echo "# Download and install" >> changelog.md
echo "curl -LO https://github.com/${{ github.repository }}/releases/download/$TAG/clamreef-agent-\$(uname -s)-\$(uname -m)" >> changelog.md
echo "chmod +x clamreef-agent-*" >> changelog.md
echo "sudo mv clamreef-agent-* /usr/local/bin/clamreef-agent" >> changelog.md
echo '```' >> changelog.md
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_version.outputs.version }}
release_name: ClamReef Agent ${{ steps.get_version.outputs.version }}
body_path: changelog.md
draft: false
prerelease: ${{ contains(steps.get_version.outputs.version, 'alpha') || contains(steps.get_version.outputs.version, 'beta') || contains(steps.get_version.outputs.version, 'rc') }}
build:
name: Build Release Binaries
needs: create-release
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
# Linux targets
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact_name: clamreef-agent
asset_name: clamreef-agent-Linux-x86_64
cross: false
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
artifact_name: clamreef-agent
asset_name: clamreef-agent-Linux-x86_64-musl
cross: true
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
artifact_name: clamreef-agent
asset_name: clamreef-agent-Linux-aarch64
cross: true
- os: ubuntu-latest
target: armv7-unknown-linux-gnueabihf
artifact_name: clamreef-agent
asset_name: clamreef-agent-Linux-armv7
cross: true
# macOS targets
- os: macos-latest
target: x86_64-apple-darwin
artifact_name: clamreef-agent
asset_name: clamreef-agent-Darwin-x86_64
cross: false
- os: macos-latest
target: aarch64-apple-darwin
artifact_name: clamreef-agent
asset_name: clamreef-agent-Darwin-aarch64
cross: false
# Windows targets
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: clamreef-agent.exe
asset_name: clamreef-agent-Windows-x86_64.exe
cross: false
- os: windows-latest
target: i686-pc-windows-msvc
artifact_name: clamreef-agent.exe
asset_name: clamreef-agent-Windows-i686.exe
cross: false
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.os }}-${{ matrix.target }}
- name: Install cross-compilation dependencies (Linux)
if: matrix.cross && matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y gcc-multilib
cargo install cross --git https://github.com/cross-rs/cross
- name: Install additional dependencies (Ubuntu)
if: matrix.os == 'ubuntu-latest' && !matrix.cross
run: |
sudo apt-get update
sudo apt-get install -y libssl-dev pkg-config
- name: Install additional dependencies (macOS)
if: matrix.os == 'macos-latest'
run: |
# No additional dependencies needed for macOS
- name: Build binary (native)
if: "!matrix.cross"
run: |
cargo build --release --target ${{ matrix.target }} --all-features
- name: Build binary (cross-compiled)
if: matrix.cross
run: |
cross build --release --target ${{ matrix.target }} --all-features
- name: Strip binary (Unix)
if: matrix.os != 'windows-latest'
run: |
strip target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
- name: Create archive (Unix)
if: matrix.os != 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
tar czf ../../../${{ matrix.asset_name }}.tar.gz ${{ matrix.artifact_name }}
cd ../../..
- name: Create archive (Windows)
if: matrix.os == 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
7z a ../../../${{ matrix.asset_name }}.zip ${{ matrix.artifact_name }}
cd ../../..
- name: Upload binary to release (Unix)
if: matrix.os != 'windows-latest'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ${{ matrix.asset_name }}.tar.gz
asset_name: ${{ matrix.asset_name }}.tar.gz
asset_content_type: application/gzip
- name: Upload binary to release (Windows)
if: matrix.os == 'windows-latest'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ${{ matrix.asset_name }}.zip
asset_name: ${{ matrix.asset_name }}.zip
asset_content_type: application/zip
- name: Upload standalone binary (Unix)
if: matrix.os != 'windows-latest'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
asset_name: ${{ matrix.asset_name }}
asset_content_type: application/octet-stream
- name: Upload standalone binary (Windows)
if: matrix.os == 'windows-latest'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
asset_name: ${{ matrix.asset_name }}
asset_content_type: application/octet-stream
docker:
name: Build and Push Docker Image
needs: create-release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Get version from tag
id: get_version
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
VERSION="${{ github.event.inputs.tag }}"
else
VERSION=${GITHUB_REF#refs/tags/}
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "version_number=${VERSION#v}" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
clamreef/agent
ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
VERSION=${{ steps.get_version.outputs.version_number }}
checksums:
name: Generate Checksums
needs: [create-release, build]
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v3
- name: Generate checksums
run: |
find . -name "clamreef-agent-*" -type f | while read file; do
if [[ "$file" == *.tar.gz ]] || [[ "$file" == *.zip ]] || [[ "$file" != *.* ]]; then
sha256sum "$file" >> checksums.txt
sha512sum "$file" >> checksums.txt
fi
done
- name: Upload checksums
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: checksums.txt
asset_name: checksums.txt
asset_content_type: text/plain