|
9 | 9 | - 'v*' |
10 | 10 |
|
11 | 11 | jobs: |
12 | | - build: |
| 12 | + build-and-release: |
13 | 13 | runs-on: ubuntu-latest |
| 14 | + permissions: |
| 15 | + contents: write |
14 | 16 | steps: |
15 | | - - uses: actions/checkout@v4 |
| 17 | + - name: Checkout |
| 18 | + uses: actions/checkout@v4 |
16 | 19 | with: |
17 | 20 | fetch-depth: 0 |
18 | 21 | fetch-tags: true |
| 22 | + |
19 | 23 | - name: Set up Go |
20 | 24 | uses: actions/setup-go@v4 |
21 | 25 | with: |
22 | 26 | go-version: '1.23' |
23 | | - |
24 | | - - name: Install keepassxc-cli |
25 | | - run: sudo apt-get update && sudo apt-get install -y keepassxc |
26 | 27 |
|
27 | | - - name: Build |
28 | | - run: go build |
| 28 | + - name: Install system dependencies (keepassxc + clamav) |
| 29 | + run: | |
| 30 | + sudo apt-get update |
| 31 | + sudo apt-get install -y --no-install-recommends keepassxc clamav |
| 32 | + sudo freshclam || echo "freshclam may have rate-limited; continuing with existing DB" |
29 | 33 |
|
30 | | - - name: Test |
| 34 | + - name: Run unit tests |
31 | 35 | run: go test ./... |
32 | 36 |
|
33 | | - release: |
34 | | - needs: build |
35 | | - runs-on: ubuntu-latest |
36 | | - steps: |
37 | | - - uses: actions/checkout@v4 |
38 | | - with: |
39 | | - fetch-depth: 0 |
40 | | - fetch-tags: true |
41 | | - - name: Set up Go |
42 | | - uses: actions/setup-go@v4 |
43 | | - with: |
44 | | - go-version: '1.23' |
45 | | - - name: Build with GoReleaser (no publish) |
46 | | - uses: goreleaser/goreleaser-action@v5 |
| 37 | + - name: Install GoReleaser (no execution yet) |
| 38 | + uses: goreleaser/goreleaser-action@v6 |
47 | 39 | with: |
48 | 40 | distribution: goreleaser |
49 | | - version: latest |
50 | | - args: build --clean |
| 41 | + version: '~> v2' |
| 42 | + install-only: true |
| 43 | + |
| 44 | + - name: GoReleaser release (build only, skip publish & announce) |
51 | 45 | env: |
52 | 46 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
53 | | - |
54 | | - - name: Upload artifacts for scanning |
55 | | - uses: actions/upload-artifact@v4 |
56 | | - with: |
57 | | - name: release-artifacts |
58 | | - path: dist/ |
59 | | - retention-days: 1 |
| 47 | + run: goreleaser release --clean --skip=publish --skip=announce |
60 | 48 |
|
61 | | - virus-scan: |
62 | | - needs: release |
63 | | - runs-on: ubuntu-latest |
64 | | - steps: |
65 | | - - name: Download release artifacts |
66 | | - uses: actions/download-artifact@v4 |
67 | | - with: |
68 | | - name: release-artifacts |
69 | | - path: dist/ |
70 | | - |
71 | | - - name: Install ClamAV |
72 | | - run: | |
73 | | - sudo apt-get update |
74 | | - sudo apt-get install -y clamav clamav-daemon |
75 | | - sudo systemctl stop clamav-freshclam |
76 | | - sudo freshclam |
77 | | - sudo systemctl start clamav-daemon |
78 | | - # Wait for daemon to start |
79 | | - sleep 10 |
80 | | - |
81 | | - - name: Scan release artifacts |
| 49 | + - name: Virus scan dist artifacts |
82 | 50 | run: | |
83 | | - echo "Scanning release artifacts for viruses..." |
84 | | - |
85 | | - clamscan --recursive --verbose --infected --bell dist/ |
86 | | - scan_result=$? |
87 | | - |
88 | | - if [ $scan_result -eq 0 ]; then |
89 | | - echo "✅ All artifacts are clean - no viruses detected" |
90 | | - elif [ $scan_result -eq 1 ]; then |
91 | | - echo "❌ Virus detected in artifacts!" |
92 | | - exit 1 |
93 | | - else |
94 | | - echo "⚠️ Scanner error occurred" |
| 51 | + echo "Scanning dist/ with ClamAV..." |
| 52 | + # clamscan returns 1 if a virus is found, 0 if none found. |
| 53 | + clamscan --recursive --infected --verbose dist/ || SCAN_STATUS=$? |
| 54 | + if [ "${SCAN_STATUS:-0}" -eq 1 ]; then |
| 55 | + echo "❌ Virus detected in build artifacts. Aborting publish." >&2 |
95 | 56 | exit 1 |
| 57 | + elif [ "${SCAN_STATUS:-0}" -gt 1 ]; then |
| 58 | + echo "❌ ClamAV scan error (exit code $SCAN_STATUS). Aborting publish." >&2 |
| 59 | + exit $SCAN_STATUS |
96 | 60 | fi |
97 | | - |
98 | | - - name: Upload clean artifacts |
99 | | - if: success() |
100 | | - uses: actions/upload-artifact@v4 |
101 | | - with: |
102 | | - name: scanned-artifacts |
103 | | - path: dist/ |
104 | | - retention-days: 1 |
| 61 | + echo "✅ No viruses found. Proceeding to publish." |
105 | 62 |
|
106 | | - publish-release: |
107 | | - needs: virus-scan |
108 | | - runs-on: ubuntu-latest |
109 | | - steps: |
110 | | - - uses: actions/checkout@v4 |
111 | | - with: |
112 | | - fetch-depth: 0 |
113 | | - fetch-tags: true |
114 | | - |
115 | | - - name: Download scanned artifacts |
116 | | - uses: actions/download-artifact@v4 |
117 | | - with: |
118 | | - name: scanned-artifacts |
119 | | - path: dist/ |
120 | | - |
121 | | - - name: Extract version from tag |
122 | | - id: version |
123 | | - run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT |
124 | | - |
125 | | - - name: List available artifacts |
126 | | - run: | |
127 | | - echo "Available artifacts in dist/:" |
128 | | - find dist/ -type f -ls |
129 | | - |
130 | | - - name: Create release with scanned artifacts |
131 | | - run: | |
132 | | - # Collect standard release artifacts (archives and checksums) |
133 | | - ARTIFACTS=$(find dist/ \( -name "*.tar.gz" -o -name "checksums.txt" \) -type f | tr '\n' ' ') |
134 | | - |
135 | | - echo "Artifacts to upload: $ARTIFACTS" |
136 | | - |
137 | | - if [ -z "$ARTIFACTS" ]; then |
138 | | - echo "❌ No artifacts found to upload!" |
139 | | - exit 1 |
140 | | - fi |
141 | | - |
142 | | - gh release create ${{ steps.version.outputs.VERSION }} \ |
143 | | - --title "Release ${{ steps.version.outputs.VERSION }}" \ |
144 | | - --generate-notes \ |
145 | | - $ARTIFACTS |
| 63 | + - name: GoReleaser publish |
146 | 64 | env: |
147 | 65 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 66 | + run: goreleaser publish --clean |
148 | 67 |
|
149 | | - publish-versioned-docs: |
150 | | - needs: publish-release |
| 68 | + publish-docs: |
| 69 | + needs: build-and-release |
151 | 70 | runs-on: ubuntu-latest |
152 | 71 | permissions: |
153 | 72 | contents: write |
|
0 commit comments