-
Notifications
You must be signed in to change notification settings - Fork 0
306 lines (279 loc) · 9.36 KB
/
release.yml
File metadata and controls
306 lines (279 loc) · 9.36 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
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
packages: read
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
validate:
name: Validate tag & version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.package.outputs.version }}
tag: ${{ steps.metadata.outputs.tag }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Determine package version
id: package
run: |
set -euo pipefail
VERSION=$(node -p "require('./package.json').version")
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
echo "Package version: ${VERSION}"
- name: Capture tag metadata
id: metadata
run: |
set -euo pipefail
if [[ "${GITHUB_REF_TYPE}" != "tag" ]]; then
echo "::error::The release workflow must be triggered by a tag." >&2
exit 1
fi
echo "tag=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT"
echo "Tag name: ${GITHUB_REF_NAME}"
- name: Validate tag matches package version
run: |
set -euo pipefail
TAG="${GITHUB_REF_NAME}"
VERSION="${{ steps.package.outputs.version }}"
if [[ "${TAG}" != "v${VERSION}" ]]; then
echo "::error::Tag ${TAG} does not match package version v${VERSION}." >&2
exit 1
fi
echo "Tag ${TAG} matches package version v${VERSION}."
- name: Validate changelog entries
run: |
set -euo pipefail
VERSION="${{ steps.package.outputs.version }}"
for file in VERSION_LOG.md docs/VERSION_LOG.md; do
if [[ ! -f "$file" ]]; then
echo "::error file=$file::Changelog file is missing." >&2
exit 1
fi
if ! grep -q "## v${VERSION}" "$file"; then
echo "::error file=$file::Missing changelog entry for v${VERSION}." >&2
exit 1
fi
echo "Found changelog entry for v${VERSION} in $file."
done
build:
name: Build ${{ matrix.display-name }}
needs: validate
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
include:
- display-name: macOS x64
os: macos-latest
script: package:mac:x64
arch: x64
npm-platform: darwin
cache-paths: |
~/Library/Caches/electron
~/Library/Caches/electron-builder
artifact-name: docforge-macos-x64
- display-name: Windows x64
os: windows-latest
script: package:win:x64
arch: x64
npm-platform: win32
cache-paths: |
~/AppData/Local/electron/Cache
~/AppData/Local/electron-builder/Cache
artifact-name: docforge-windows-x64
- display-name: Windows ia32
os: windows-latest
script: package:win:ia32
arch: ia32
npm-platform: win32
cache-paths: |
~/AppData/Local/electron/Cache
~/AppData/Local/electron-builder/Cache
artifact-name: docforge-windows-ia32
- display-name: Linux x64
os: ubuntu-latest
script: package:linux:x64
arch: x64
npm-platform: linux
cache-paths: |
~/.cache/electron
~/.cache/electron-builder
artifact-name: docforge-linux-x64
- display-name: Linux armv7l
os: ubuntu-latest
script: package:linux:armv7l
arch: armv7l
npm-platform: linux
cache-paths: |
~/.cache/electron
~/.cache/electron-builder
artifact-name: docforge-linux-armv7l
- display-name: Linux arm64
os: ubuntu-latest
script: package:linux:arm64
arch: arm64
npm-platform: linux
cache-paths: |
~/.cache/electron
~/.cache/electron-builder
artifact-name: docforge-linux-arm64
env:
NODE_OPTIONS: --max_old_space_size=4096
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: package-lock.json
- name: Cache Electron downloads
uses: actions/cache@v4
with:
path: ${{ matrix.cache-paths }}
key: ${{ runner.os }}-electron-${{ matrix.arch }}-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-electron-${{ matrix.arch }}-
${{ runner.os }}-electron-
- name: Install system dependencies (Linux)
if: runner.os == 'Linux'
run: |
set -euo pipefail
sudo apt-get update
sudo apt-get install --no-install-recommends -y rpm libarchive-tools
if ! sudo apt-get install --no-install-recommends -y libfuse2; then
sudo apt-get install --no-install-recommends -y libfuse2t64
fi
- name: Install dependencies
run: npm ci
env:
npm_config_arch: ${{ matrix.arch }}
npm_config_target_arch: ${{ matrix.arch }}
npm_config_platform: ${{ matrix.npm-platform }}
- name: Prepare native modules
run: npm run postinstall --if-present
env:
npm_config_arch: ${{ matrix.arch }}
npm_config_target_arch: ${{ matrix.arch }}
npm_config_platform: ${{ matrix.npm-platform }}
- name: Package application
run: npm run ${{ matrix.script }}
env:
npm_config_arch: ${{ matrix.arch }}
npm_config_target_arch: ${{ matrix.arch }}
npm_config_platform: ${{ matrix.npm-platform }}
- name: Upload build artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact-name }}
path: |
release/**
!**/*.blockmap
if-no-files-found: error
retention-days: 14
- name: Upload build logs on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact-name }}-logs
path: |
npm-debug.log
*.log
release/**/*.log
if-no-files-found: ignore
retention-days: 7
publish:
name: Publish GitHub release
needs:
- validate
- build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
path: release-artifacts
merge-multiple: false
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: npm ci
- name: Generate release notes
id: notes
run: |
set -euo pipefail
node scripts/generate-release-notes.mjs \
--tag "${{ needs.validate.outputs.tag }}" \
--version "${{ needs.validate.outputs.version }}" \
--artifact-root "release-artifacts" \
--changelog "docs/VERSION_LOG.md" \
--output "release-notes.md" \
--files-output "release-files.txt"
echo "files<<EOF" >> "$GITHUB_OUTPUT"
cat release-files.txt >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
env:
GITHUB_REPOSITORY: ${{ github.repository }}
- name: Verify auto-update manifests
run: |
set -euo pipefail
metadata_dirs=()
while IFS= read -r -d '' metadata_file; do
dir=$(dirname "$metadata_file")
if [[ "$metadata_file" == *"/builder-debug.yml" ]]; then
continue
fi
skip=0
for existing in "${metadata_dirs[@]}"; do
if [[ "$existing" == "$dir" ]]; then
skip=1
break
fi
done
if [[ $skip -eq 0 ]]; then
metadata_dirs+=("$dir")
fi
done < <(find release-artifacts -type f -name '*.yml' -print0)
if [[ ${#metadata_dirs[@]} -eq 0 ]]; then
echo "::error::No auto-update metadata (.yml) files were found in the release artifacts." >&2
exit 1
fi
for dir in "${metadata_dirs[@]}"; do
echo "Verifying auto-update metadata in ${dir}" >&2
node scripts/test-auto-update.mjs --local "$dir" --fix-metadata
done
- name: Display release notes
run: |
echo "Generated release notes:" >&2
cat release-notes.md
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.validate.outputs.tag }}
name: DocForge v${{ needs.validate.outputs.version }}
body_path: release-notes.md
files: ${{ steps.notes.outputs.files }}
draft: false
prerelease: false
fail_on_unmatched_files: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}