-
Notifications
You must be signed in to change notification settings - Fork 91
309 lines (275 loc) · 11.1 KB
/
build.yml
File metadata and controls
309 lines (275 loc) · 11.1 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
307
308
name: Build
on:
push:
branches:
- main
tags:
- 'v*'
pull_request:
branches:
- main
workflow_dispatch:
inputs:
tag:
description: 'Tag to release (existing tag name)'
required: true
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
name: Linux
bin-name: green-wall
- os: windows-latest
name: Windows
bin-name: green-wall.exe
- os: macos-latest
name: macOS
bin-name: green-wall
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref }}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
cache-dependency-path: go.sum
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install frontend dependencies
working-directory: frontend
run: npm ci
- name: Build frontend
working-directory: frontend
run: npm run build
- name: Generate Bindings
if: matrix.os != 'windows-latest'
run: |
go run github.com/wailsapp/wails/v2/cmd/wails@latest generate module || true
- name: Generate Bindings (Windows)
if: matrix.os == 'windows-latest'
shell: powershell
run: |
go run github.com/wailsapp/wails/v2/cmd/wails@latest generate module
- name: Install Linux build dependencies
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
# Install all required dependencies including WebKit
sudo apt-get install -y \
libgtk-3-dev \
libwebkit2gtk-4.1-dev \
libgdk-pixbuf2.0-dev \
libglib2.0-dev \
libcairo2-dev \
libpango1.0-dev \
libatk1.0-dev \
libx11-dev \
libxcomposite-dev \
libxdamage-dev \
libxext-dev \
libxfixes-dev \
libxkbcommon-dev \
libxrandr-dev \
libxrender-dev \
libxshmfence-dev \
libxtst-dev \
pkg-config
# Create symlink for webkit2gtk-4.0 to webkit2gtk-4.1 (for Wails compatibility)
if pkg-config --exists webkit2gtk-4.1; then
echo "WebKit 4.1 found, creating compatibility symlink for 4.0"
sudo mkdir -p /usr/lib/x86_64-linux-gnu/pkgconfig
# Create a wrapper .pc file that redirects webkit2gtk-4.0 to webkit2gtk-4.1
echo "prefix=/usr" | sudo tee /usr/lib/x86_64-linux-gnu/pkgconfig/webkit2gtk-4.0.pc
echo "exec_prefix=\${prefix}" | sudo tee -a /usr/lib/x86_64-linux-gnu/pkgconfig/webkit2gtk-4.0.pc
echo "libdir=\${exec_prefix}/lib/x86_64-linux-gnu" | sudo tee -a /usr/lib/x86_64-linux-gnu/pkgconfig/webkit2gtk-4.0.pc
echo "includedir=\${prefix}/include" | sudo tee -a /usr/lib/x86_64-linux-gnu/pkgconfig/webkit2gtk-4.0.pc
echo "" | sudo tee -a /usr/lib/x86_64-linux-gnu/pkgconfig/webkit2gtk-4.0.pc
echo "Name: webkit2gtk-4.0" | sudo tee -a /usr/lib/x86_64-linux-gnu/pkgconfig/webkit2gtk-4.0.pc
echo "Description: WebKit2GTK+ (compatibility wrapper for 4.1)" | sudo tee -a /usr/lib/x86_64-linux-gnu/pkgconfig/webkit2gtk-4.0.pc
echo "Version: 4.0" | sudo tee -a /usr/lib/x86_64-linux-gnu/pkgconfig/webkit2gtk-4.0.pc
echo "Requires: webkit2gtk-4.1" | sudo tee -a /usr/lib/x86_64-linux-gnu/pkgconfig/webkit2gtk-4.0.pc
echo "Libs: -L\${libdir}" | sudo tee -a /usr/lib/x86_64-linux-gnu/pkgconfig/webkit2gtk-4.0.pc
echo "Cflags: -I\${includedir}" | sudo tee -a /usr/lib/x86_64-linux-gnu/pkgconfig/webkit2gtk-4.0.pc
fi
# Verify installation
echo "=== Verifying packages ==="
pkg-config --modversion gtk+-3.0
pkg-config --modversion webkit2gtk-4.1 || echo "webkit2gtk-4.1 not found"
pkg-config --modversion webkit2gtk-4.0 || echo "webkit2gtk-4.0 not found (expected if using symlink)"
pkg-config --cflags webkit2gtk-4.0 || echo "webkit2gtk-4.0 cflags failed"
- name: Build application (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
go run github.com/wailsapp/wails/v2/cmd/wails@latest build -clean -ldflags "-w -s"
- name: Build application (Windows)
if: matrix.os == 'windows-latest'
shell: powershell
run: |
go run github.com/wailsapp/wails/v2/cmd/wails@latest build -clean -ldflags "-w -s"
- name: Build application (macOS)
if: matrix.os == 'macos-latest'
run: |
go run github.com/wailsapp/wails/v2/cmd/wails@latest build -clean -ldflags "-w -s"
- name: List build output (Linux/macOS)
if: matrix.os != 'windows-latest'
shell: bash
run: |
echo "=== Build directory contents ==="
ls -la build/ || echo "build/ not found"
echo "=== Build bin directory contents ==="
ls -la build/bin/ || echo "build/bin/ not found"
echo "=== Current directory ==="
pwd
find . -name "green-wall*" -o -name "*.exe" -o -name "*.app" 2>/dev/null || echo "No build artifacts found"
- name: List build output (Windows)
if: matrix.os == 'windows-latest'
shell: powershell
run: |
echo "=== Build directory contents ==="
Get-ChildItem -Path build -Recurse -ErrorAction SilentlyContinue
echo "=== Build bin directory contents ==="
Get-ChildItem -Path build/bin -ErrorAction SilentlyContinue
echo "=== Current directory ==="
Get-Location
echo "=== Searching for build artifacts ==="
Get-ChildItem -Recurse -Include green-wall*.exe -ErrorAction SilentlyContinue
- name: Create macOS archive
if: matrix.os == 'macos-latest'
run: |
cd build/bin
zip -r ../../green-wall-${{ matrix.name }}-${{ runner.arch }}.zip green-wall.app
- name: Create Linux archive
if: matrix.os == 'ubuntu-latest'
run: |
cd build/bin
tar -czf ../../green-wall-${{ matrix.name }}-${{ runner.arch }}.tar.gz green-wall*
- name: Create Windows archive
if: matrix.os == 'windows-latest'
shell: powershell
run: |
cd build/bin
Compress-Archive -Path green-wall*.exe -DestinationPath ../../green-wall-${{ matrix.name }}-${{ runner.arch }}.zip -Force
- name: Upload macOS artifact
if: matrix.os == 'macos-latest'
uses: actions/upload-artifact@v4
with:
name: green-wall-${{ matrix.name }}-${{ runner.arch }}
path: green-wall-${{ matrix.name }}-${{ runner.arch }}.zip
if-no-files-found: error
retention-days: 30
- name: Upload Linux artifact
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: green-wall-${{ matrix.name }}-${{ runner.arch }}
path: green-wall-${{ matrix.name }}-${{ runner.arch }}.tar.gz
if-no-files-found: error
retention-days: 30
- name: Upload Windows artifact
if: matrix.os == 'windows-latest'
uses: actions/upload-artifact@v4
with:
name: green-wall-${{ matrix.name }}-${{ runner.arch }}
path: green-wall-${{ matrix.name }}-${{ runner.arch }}.zip
if-no-files-found: error
retention-days: 30
release:
needs: build
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
runs-on: ubuntu-latest
permissions:
contents: write
env:
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.ref_name }}
RELEASE_REF: ${{ github.event_name == 'workflow_dispatch' && format('refs/tags/{0}', github.event.inputs.tag) || github.ref }}
steps:
- name: Checkout (for git history)
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ env.RELEASE_REF }}
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
pattern: green-wall-*
- name: Generate contributors list
id: contrib
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
CURRENT_TAG="$RELEASE_TAG"
PREV_TAG=""
RANGE_EXPR="$CURRENT_TAG"
SUMMARY_LABEL="Changes in this release"
if PREV_FOUND=$(git describe --abbrev=0 --tags "${CURRENT_TAG}^" 2>/dev/null); then
PREV_TAG=$PREV_FOUND
RANGE_EXPR="${PREV_TAG}..${CURRENT_TAG}"
SUMMARY_LABEL="Changes since $PREV_TAG"
fi
echo "Using range expression: $RANGE_EXPR"
CONTRIBUTORS=$(git log --format='%aN' $RANGE_EXPR | \
grep -viE '\\[bot\\]' | sort -fu | sed 's/^/- @/')
if [ -z "$CONTRIBUTORS" ]; then
CONTRIBUTORS="- (No user-contributed commits in this range)"
fi
echo "contributors<<EOF" >> $GITHUB_OUTPUT
echo "$CONTRIBUTORS" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "range_expr=$RANGE_EXPR" >> $GITHUB_OUTPUT
echo "range_label=$SUMMARY_LABEL" >> $GITHUB_OUTPUT
echo "previous_tag=$PREV_TAG" >> $GITHUB_OUTPUT
- name: Summarize changes
id: changes
shell: bash
run: |
set -euo pipefail
RANGE_EXPR="${{ steps.contrib.outputs.range_expr }}"
CHANGES=$(git log --no-merges --pretty='- %s' $RANGE_EXPR)
if [ -z "$CHANGES" ]; then
CHANGES="- No code changes recorded in this range."
fi
echo "summary<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Build release notes body
id: notes
shell: bash
run: |
set -euo pipefail
TAG="$RELEASE_TAG"
DATE=$(date -u +%Y-%m-%d)
{
echo "Release $TAG ($DATE)"
echo
echo "${{ steps.contrib.outputs.range_label }}:"
echo
printf '%s\n' "${{ steps.changes.outputs.summary }}"
echo
echo "## Thanks to our contributors:"
echo "## 特别感谢以下几位贡献者:"
echo
printf '%s\n' "${{ steps.contrib.outputs.contributors }}"
} > RELEASE_BODY.md
echo "body_path=RELEASE_BODY.md" >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@v2
with:
draft: true
prerelease: false
files: green-wall-*/*
body_path: ${{ steps.notes.outputs.body_path }}
tag_name: ${{ env.RELEASE_TAG }}