Skip to content

Commit e56d0d8

Browse files
authored
Merge pull request #5 from soulteary/ci/fix-build
ci: fix build
2 parents bd3453a + 10817d2 commit e56d0d8

File tree

1 file changed

+122
-24
lines changed

1 file changed

+122
-24
lines changed

.github/workflows/build.yml

Lines changed: 122 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,158 @@
1-
name: Build Wails Desktop App
1+
name: Release Desktop App
22

33
on:
44
push:
55
tags:
66
- "v*.*.*"
77
workflow_dispatch:
88

9+
env:
10+
NODE_OPTIONS: "--max-old-space-size=4096"
11+
912
jobs:
10-
build:
13+
release:
14+
name: Release Desktop App
1115
strategy:
1216
matrix:
13-
os: [ubuntu-latest, macos-latest, windows-latest]
17+
os: [ubuntu-latest, windows-latest, macos-latest]
1418

1519
runs-on: ${{ matrix.os }}
1620

1721
steps:
1822
- name: Checkout
1923
uses: actions/checkout@v4
2024

25+
- name: Set build name with tag
26+
shell: bash
27+
run: |
28+
OS_NAME=$(echo "${{ runner.os }}" | tr '[:upper:]' '[:lower:]')
29+
if [ "$OS_NAME" = "macos" ]; then OS_NAME="darwin"; fi
30+
echo "BUILD_NAME=can-finder-${GITHUB_REF_NAME}.${OS_NAME}-amd64" >> $GITHUB_ENV
31+
version=$(echo ${GITHUB_REF_NAME} | sed -e 's/^v//')
32+
echo "BUILD_VER=$version" >> $GITHUB_ENV
33+
34+
- name: Echo vars
35+
shell: bash
36+
run: |
37+
echo "Build name: ${{ env.BUILD_NAME }}"
38+
echo "Version: ${{ env.BUILD_VER }}"
39+
2140
- name: Setup Go
2241
uses: actions/setup-go@v5
2342
with:
24-
go-version: '1.24'
43+
go-version: "1.24.0"
44+
45+
- name: Install Wails CLI
46+
shell: bash
47+
run: |
48+
go install github.com/wailsapp/wails/v2/cmd/wails@latest
49+
wails doctor
50+
51+
- name: Update frontend version
52+
shell: bash
53+
run: |
54+
jq '.info.productVersion = "${{ env.BUILD_VER }}"' wails.json > tmp.json
55+
mv tmp.json wails.json
56+
cd frontend
57+
rm -f package-lock.json
58+
jq '.version = "${{ env.BUILD_VER }}"' package.json > tmp.json
59+
mv tmp.json package.json
2560
26-
- name: Install dependencies (Ubuntu)
61+
- name: Install Linux prerequisites
2762
if: runner.os == 'Linux'
63+
shell: bash
2864
run: |
2965
sudo apt-get update
30-
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev build-essential pkg-config
66+
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev jq build-essential pkg-config
3167
32-
- name: Install dependencies (macOS)
68+
- name: Install macOS prerequisites
3369
if: runner.os == 'macOS'
70+
shell: bash
3471
run: |
35-
brew install gtk+3 webkitgtk pkg-config
72+
brew install gtk+3 webkitgtk jq pkg-config
3673
37-
- name: Install Wails CLI
38-
run: go install github.com/wailsapp/wails/v2/cmd/wails@latest
74+
- name: Install Windows prerequisites
75+
if: runner.os == 'Windows'
76+
uses: crazy-max/ghaction-chocolatey@v2
77+
with:
78+
args: install nsis jq
3979

40-
- name: Verify Installation
41-
run: wails doctor
80+
- name: Build App (Linux)
81+
if: runner.os == 'Linux'
82+
shell: bash
83+
run: |
84+
wails build -clean -tags webkit2_41 -o ${{ env.BUILD_NAME }}
4285
43-
- name: Build Application (Linux/MacOS)
44-
if: runner.os != 'Windows'
86+
- name: Build App (macOS)
87+
if: runner.os == 'macOS'
88+
shell: bash
89+
run: |
90+
wails build -clean -platform darwin/universal
91+
92+
- name: Build NSIS Installer (Windows)
93+
if: runner.os == 'Windows'
94+
shell: bash
4595
run: |
46-
wails build -clean -platform ${{ runner.os == 'Linux' && 'linux/amd64' || 'darwin/universal' }}
96+
wails build -clean -nsis -webview2 embed
4797
48-
- name: Build Application (Windows)
98+
- name: Rename Windows Installer
4999
if: runner.os == 'Windows'
100+
working-directory: ./build/bin
101+
shell: powershell
50102
run: |
51-
wails build -clean -platform windows/amd64
103+
Rename-Item -Path "*-installer.exe" -NewName "${{ env.BUILD_NAME }}.exe"
52104
53-
- name: Upload Release Artifacts
54-
uses: actions/upload-artifact@v4
105+
- name: Install nfpm (Linux)
106+
if: runner.os == 'Linux'
107+
shell: bash
108+
run: |
109+
go install github.com/goreleaser/nfpm/v2/cmd/nfpm@latest
110+
111+
- name: Package with nfpm (Linux)
112+
if: runner.os == 'Linux'
113+
shell: bash
114+
run: |
115+
NAME=${{ env.BUILD_NAME }} VERSION=${{ env.BUILD_VER }} nfpm pkg --packager deb --config nfpm.yaml -t ${{ env.BUILD_NAME }}.deb
116+
NAME=${{ env.BUILD_NAME }} VERSION=${{ env.BUILD_VER }} nfpm pkg --packager rpm --config nfpm.yaml -t ${{ env.BUILD_NAME }}.rpm
117+
118+
- name: Show build artifacts
119+
shell: bash
120+
run: |
121+
ls -alh ./build/bin || true
122+
ls -alh *.deb *.rpm || true
123+
ls -alh build/*.app || true
124+
125+
- name: Archive macOS App
126+
if: runner.os == 'macOS'
127+
shell: bash
128+
run: |
129+
cd build/bin
130+
zip -r ../../${{ env.BUILD_NAME }}.zip *.app
131+
132+
- name: Upload Release Assets (Linux)
133+
if: runner.os == 'Linux'
134+
uses: softprops/action-gh-release@v2
135+
with:
136+
files: |
137+
*.deb
138+
*.rpm
139+
env:
140+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
141+
142+
- name: Upload Release Assets (macOS)
143+
if: runner.os == 'macOS'
144+
uses: softprops/action-gh-release@v2
145+
with:
146+
files: |
147+
*.zip
148+
env:
149+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
150+
151+
- name: Upload Release Assets (Windows)
152+
if: runner.os == 'Windows'
153+
uses: softprops/action-gh-release@v2
55154
with:
56-
name: CAN-Finder-${{ matrix.os }}
57-
path: |
58-
build/bin/
59-
build/*.app
60-
build/*.exe
155+
files: |
156+
build/bin/${{ env.BUILD_NAME }}.exe
157+
env:
158+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)