-
Notifications
You must be signed in to change notification settings - Fork 0
187 lines (161 loc) · 5.34 KB
/
Copy pathci.yml
File metadata and controls
187 lines (161 loc) · 5.34 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
name: CI
on:
push:
branches: [main, master, develop]
tags: ['v*']
pull_request:
branches: [main, master, develop]
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: write
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: npm
- name: Install dependencies
run: npm ci
- name: Typecheck
run: npm run lint
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: npm
- name: Install dependencies
run: npm ci
- name: Rebuild native modules for Node (Vitest)
run: npm rebuild better-sqlite3
- name: Unit tests (critical coverage thresholds)
run: npm run test:ci:critical
- name: Unit tests (full coverage thresholds)
run: npm run test:ci
- name: Vitest coverage report (PR comment)
if: github.event_name == 'pull_request' && always()
uses: davelosert/vitest-coverage-report-action@v2
with:
json-summary-path: coverage/coverage-summary.json
- name: Upload coverage reports
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-${{ github.run_id }}
path: |
coverage/lcov.info
coverage/index.html
coverage/coverage-summary.json
coverage/coverage-final.json
coverage/critical/lcov.info
coverage/critical/index.html
coverage/critical/coverage-summary.json
coverage/critical/coverage-final.json
if-no-files-found: ignore
- name: Coverage summary (job log)
if: success()
run: |
echo '### Coverage' >> "$GITHUB_STEP_SUMMARY"
echo 'HTML: artifact `coverage-*/coverage/index.html` (download from Actions).' >> "$GITHUB_STEP_SUMMARY"
build:
needs: [lint, test]
if: |
github.event_name == 'push' && (
startsWith(github.ref, 'refs/tags/v') ||
github.ref == 'refs/heads/main' ||
github.ref == 'refs/heads/master' ||
github.ref == 'refs/heads/develop'
)
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: npm
- name: Install dependencies
run: npm ci
- name: Build Windows installers
run: npm run build:win
env:
CSC_IDENTITY_AUTO_DISCOVERY: 'false'
- name: Generate SHA256 sidecars for installers
shell: pwsh
run: |
Get-ChildItem -Path 'LexPatrool-bin' -Filter '*.exe' -File | ForEach-Object {
$h = (Get-FileHash -Algorithm SHA256 -Path $_.FullName).Hash.ToLowerInvariant()
$sidecar = $_.FullName + '.sha256'
Set-Content -LiteralPath $sidecar -Value $h -NoNewline -Encoding ascii
Write-Host "Wrote $sidecar"
}
- name: Upload Windows build artifact
uses: actions/upload-artifact@v4
with:
name: windows-build-${{ github.run_id }}
path: |
LexPatrool-bin/LexPatrol Setup *.exe
LexPatrool-bin/LexPatrol Setup *.exe.sha256
LexPatrool-bin/LexPatrol *.exe
LexPatrool-bin/LexPatrol *.exe.sha256
if-no-files-found: error
release:
needs: [build]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download Windows build
uses: actions/download-artifact@v4
with:
name: windows-build-${{ github.run_id }}
path: LexPatrool-bin
- name: Compose release description (tag message + GitHub changelog)
id: release_body
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="${GITHUB_REF_NAME}"
CUSTOM=$(git for-each-ref --format='%(contents)' "refs/tags/${TAG}" 2>/dev/null || true)
if [ -z "${CUSTOM//[$'\t\r\n ']}" ]; then
CUSTOM=$(git show -s --format=%B "${GITHUB_SHA}")
fi
GEN=$(gh api "repos/${GITHUB_REPOSITORY}/releases/generate-notes" \
-f "tag_name=${TAG}" \
--jq .body 2>/dev/null || echo "")
{
echo "body<<REL_BODY_EOF"
printf '%s\n' "${CUSTOM}"
if [ -n "${GEN}" ]; then
printf '\n---\n\n%s\n' "${GEN}"
fi
echo "REL_BODY_EOF"
} >> "${GITHUB_OUTPUT}"
- name: Upload installers to GitHub Release
uses: softprops/action-gh-release@v2
with:
draft: false
body: ${{ steps.release_body.outputs.body }}
generate_release_notes: false
fail_on_unmatched_files: true
files: |
LexPatrool-bin/LexPatrol Setup *.exe
LexPatrool-bin/LexPatrol Setup *.exe.sha256
LexPatrool-bin/LexPatrol *.exe
LexPatrool-bin/LexPatrol *.exe.sha256
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}