-
Notifications
You must be signed in to change notification settings - Fork 9
204 lines (177 loc) · 6.75 KB
/
Copy pathmain.yml
File metadata and controls
204 lines (177 loc) · 6.75 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
name: Atlas Release
on:
push:
branches:
- main
permissions:
contents: write
jobs:
build-and-release:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest]
timeout-minutes: 60
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Install dependencies (Windows)
if: matrix.os == 'windows-latest'
run: npm install
shell: cmd
- name: Install dependencies (Linux)
if: matrix.os == 'ubuntu-latest'
run: npm install
shell: bash
- name: Install Linux system dependencies
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y libarchive-tools rpm
# appimagetool (bundled by electron-builder to build the AppImage
# target) is itself an AppImage and needs FUSE2 to run. Ubuntu
# 24.04 ("noble", what ubuntu-latest currently points to) renamed
# libfuse2 -> libfuse2t64; fall back to the old name in case the
# runner image changes again.
sudo apt-get install -y libfuse2t64 || sudo apt-get install -y libfuse2
shell: bash
- name: Build renderer
if: matrix.os == 'windows-latest'
run: npx vite build
shell: cmd
- name: Build renderer (Linux)
if: matrix.os == 'ubuntu-latest'
run: npx vite build
shell: bash
- name: Build extension zip (Windows)
if: matrix.os == 'windows-latest'
run: npm run build:extension
shell: cmd
- name: Build extension zip (Linux)
if: matrix.os == 'ubuntu-latest'
run: npm run build:extension
shell: bash
- name: Build and publish (Windows)
if: matrix.os == 'windows-latest'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx electron-builder --win --x64 -p always
shell: cmd
- name: Build and publish (Linux)
if: matrix.os == 'ubuntu-latest'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx electron-builder --linux --x64 -p always
shell: bash
- name: Verify Linux release assets
if: matrix.os == 'ubuntu-latest'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
shopt -s nullglob
linux_files=(release/*.deb release/*.AppImage release/*.pacman)
if [ ${#linux_files[@]} -eq 0 ]; then
echo "No Linux packages were produced in release/."
exit 1
fi
tag="v$(node -p "require('./package.json').version")"
linux_assets=$(gh release view "$tag" --json assets --jq '[.assets[].name | select(test("\\.(deb|AppImage|pacman)$"))] | length')
if [ "$linux_assets" -eq 0 ]; then
echo "Release $tag does not contain Linux assets."
exit 1
fi
shell: bash
- name: Upload Windows artifact
if: matrix.os == 'windows-latest'
uses: actions/upload-artifact@v4
with:
name: windows-installer
path: release/*.exe
if-no-files-found: warn
- name: Upload Linux artifact
if: always() && matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: linux-installer
path: |
release/*.deb
release/*.AppImage
release/*.pacman
if-no-files-found: error
virus-scan:
name: ClamAV scan of release artifacts
needs: build-and-release
runs-on: ubuntu-latest
# Report-only by default: ClamAV can false-positive on unsigned/packed
# Electron installers, so a detection should be surfaced loudly but not
# block a release. Flip FAIL_ON_DETECTION to 'true' to make hits fail.
env:
FAIL_ON_DETECTION: 'false'
steps:
- name: Download Windows artifact
uses: actions/download-artifact@v4
with:
name: windows-installer
path: scan/windows
continue-on-error: true
- name: Download Linux artifact
uses: actions/download-artifact@v4
with:
name: linux-installer
path: scan/linux
continue-on-error: true
- name: Install ClamAV
run: |
sudo apt-get update
sudo apt-get install -y clamav
# freshclam holds a lock via the daemon; stop it so we can update.
sudo systemctl stop clamav-freshclam || true
- name: Update virus definitions
run: sudo freshclam || echo "freshclam returned non-zero (definitions may already be current); continuing."
- name: Scan artifacts
id: scan
run: |
set +e
shopt -s nullglob globstar
files=(scan/**/*.exe scan/**/*.AppImage scan/**/*.deb scan/**/*.pacman)
if [ ${#files[@]} -eq 0 ]; then
echo "No release artifacts were downloaded to scan." | tee -a "$GITHUB_STEP_SUMMARY"
echo "detections=0" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "## ClamAV scan results" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "| Artifact | SHA-256 | Result |" >> "$GITHUB_STEP_SUMMARY"
echo "| --- | --- | --- |" >> "$GITHUB_STEP_SUMMARY"
total_infected=0
for f in "${files[@]}"; do
sha=$(sha256sum "$f" | awk '{print $1}')
# --no-summary keeps output to one "FOUND"/"OK" line per file.
out=$(clamscan --no-summary --stdout "$f" 2>&1)
code=$?
name=$(basename "$f")
if [ $code -eq 0 ]; then
result="✅ Clean"
elif [ $code -eq 1 ]; then
sig=$(echo "$out" | grep -o ': .* FOUND' | sed 's/^: //; s/ FOUND$//' | paste -sd '; ' -)
result="🚨 INFECTED — ${sig:-detection}"
total_infected=$((total_infected + 1))
else
result="⚠️ Scan error (exit $code)"
fi
echo "| \`$name\` | \`$sha\` | $result |" >> "$GITHUB_STEP_SUMMARY"
echo "$name $sha $result"
done
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "_Report-only. For a multi-engine view, submit an artifact's SHA-256 at https://www.virustotal.com/gui/search_ ." >> "$GITHUB_STEP_SUMMARY"
echo "detections=$total_infected" >> "$GITHUB_OUTPUT"
- name: Enforce detection policy
if: steps.scan.outputs.detections != '0' && env.FAIL_ON_DETECTION == 'true'
run: |
echo "ClamAV reported ${{ steps.scan.outputs.detections }} infected artifact(s) and FAIL_ON_DETECTION is true."
exit 1