Skip to content

Commit cfe50b9

Browse files
committed
ci: attach virus scan result to the release
1 parent 8960e68 commit cfe50b9

3 files changed

Lines changed: 26 additions & 36 deletions

File tree

.github/workflows/build.yml

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ jobs:
2222
uses: actions/setup-go@v4
2323
with:
2424
go-version: '1.23'
25-
25+
2626
- name: Run golangci-lint
2727
uses: golangci/golangci-lint-action@v4
2828
with:
2929
version: latest
30-
30+
3131
- name: Install system dependencies (keepassxc + clamav)
3232
run: |
3333
sudo apt-get update
@@ -40,17 +40,4 @@ jobs:
4040
run: make build
4141

4242
- name: Virus scan
43-
run: |
44-
scannerVersion=$(clamscan --version)
45-
echo "Using scanner version: $scannerVersion"
46-
47-
echo "Scanning built binary with ClamAV..."
48-
clamscan --recursive --infected --verbose dist/ || SCAN_STATUS=$?
49-
if [ "${SCAN_STATUS:-0}" -eq 1 ]; then
50-
echo "❌ Virus detected in built binary. Build failed." >&2
51-
exit 1
52-
elif [ "${SCAN_STATUS:-0}" -gt 1 ]; then
53-
echo "❌ ClamAV scan error (exit code $SCAN_STATUS). Build failed." >&2
54-
exit $SCAN_STATUS
55-
fi
56-
echo "✅ No viruses found."
43+
run: scripts/run_virus_scan

.github/workflows/release.yml

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,7 @@ jobs:
4545
run: scripts/build_binaries
4646

4747
- name: Virus scan
48-
run: |
49-
scannerVersion=$(clamscan --version)
50-
echo "Using scanner version: $scannerVersion"
51-
52-
echo "Scanning built binary with ClamAV..."
53-
clamscan --recursive --infected --verbose dist/ || SCAN_STATUS=$?
54-
if [ "${SCAN_STATUS:-0}" -eq 1 ]; then
55-
echo "❌ Virus detected in build artifacts. Build failed." >&2
56-
exit 1
57-
elif [ "${SCAN_STATUS:-0}" -gt 1 ]; then
58-
echo "❌ ClamAV scan error (exit code $SCAN_STATUS). Build failed." >&2
59-
exit $SCAN_STATUS
60-
fi
61-
echo "✅ No viruses found."
48+
run: scripts/run_virus_scan
6249

6350
- name: Create GitHub Release & upload artifacts
6451
uses: softprops/action-gh-release@v2
@@ -69,6 +56,7 @@ jobs:
6956
files: |
7057
dist/ctRestClient_*.tar.gz
7158
dist/checksums.txt
59+
dist/virus_scan.log
7260
env:
7361
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7462

@@ -85,30 +73,30 @@ jobs:
8573
with:
8674
fetch-depth: 0
8775
fetch-tags: true
88-
76+
8977
- name: Set up Python
9078
uses: actions/setup-python@v4
9179
with:
9280
python-version: '3.x'
93-
81+
9482
- name: Install MkDocs and dependencies
9583
run: |
9684
python -m pip install --upgrade pip
9785
pip install mkdocs mkdocs-material mike
98-
86+
9987
- name: Extract version from tag
10088
id: version
10189
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
102-
90+
10391
- name: Create versioned MkDocs config
10492
run: |
10593
bash .github/scripts/create-versioned-mkdocs-config.sh ${{ steps.version.outputs.VERSION }}
106-
94+
10795
- name: Configure Git for mike
10896
run: |
10997
git config user.name "${{ github.repository_owner }}"
11098
git config user.email "${{ github.repository_owner }}@users.noreply.github.com"
111-
99+
112100
- name: Deploy versioned docs
113101
run: |
114102
# Deploy the new version to gh-pages branch

scripts/run_virus_scan

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
SCANNER_VERSION=$(clamscan --version)
4+
echo "Using scanner version: $SCANNER_VERSION" | tee -a dist/virus_scan.log
5+
6+
echo "Scanning built binary with ClamAV..."
7+
clamscan --recursive --infected --verbose dist/ | tee -a dist/virus_scan.log || SCAN_STATUS=$?
8+
if [ "${SCAN_STATUS:-0}" -eq 1 ]; then
9+
echo "❌ Virus detected in build artifacts. Build failed." | tee -a dist/virus_scan.log >&2
10+
exit 1
11+
elif [ "${SCAN_STATUS:-0}" -gt 1 ]; then
12+
echo "❌ ClamAV scan error (exit code $SCAN_STATUS). Build failed." | tee -a dist/virus_scan.log >&2
13+
exit $SCAN_STATUS
14+
fi
15+
echo "✅ No viruses found." | tee -a dist/virus_scan.log

0 commit comments

Comments
 (0)