-
Notifications
You must be signed in to change notification settings - Fork 20
161 lines (136 loc) · 5 KB
/
build.yml
File metadata and controls
161 lines (136 loc) · 5 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
name: Multi-Platform Build
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version to build (e.g., 1.0.5.3)'
required: true
default: '1.0.5.3'
env:
APP_NAME: 柠檬Push
ENGLISH_NAME: lemon_push_gui
jobs:
build:
strategy:
matrix:
include:
- os: windows-latest
platform: windows/amd64
artifact_suffix: windows_amd64
- os: macos-latest
platform: darwin/arm64
artifact_suffix: darwin_arm64
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'yarn'
cache-dependency-path: 'desktop_gui/frontend/yarn.lock'
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.23'
- name: Install Wails
run: go install github.com/wailsapp/wails/v2/cmd/wails@latest
- name: Set version from tag or input
run: |
if [[ "${{ github.ref_type }}" == "tag" ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
else
VERSION="${{ github.event.inputs.version }}"
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "Building version: $VERSION"
shell: bash
- name: Update version in wails.json
run: |
# Update version in wails.json
cd desktop_gui
if [[ "$RUNNER_OS" == "macOS" ]]; then
sed -i '' 's/"productVersion": "[^"]*"/"productVersion": "'$VERSION'"/' wails.json
else
sed -i 's/"productVersion": "[^"]*"/"productVersion": "'$VERSION'"/' wails.json
fi
echo "Updated version in wails.json to $VERSION"
shell: bash
- name: Install frontend dependencies
run: cd desktop_gui/frontend && yarn install
- name: Build frontend
run: cd desktop_gui/frontend && yarn build
- name: Build application
run: cd desktop_gui && wails build -platform ${{ matrix.platform }} -clean
- name: Prepare artifacts (Windows)
if: matrix.os == 'windows-latest'
run: |
mkdir -p release
copy "desktop_gui\build\bin\${{ env.APP_NAME }}.exe" "release\${{ env.ENGLISH_NAME }}_v${{ env.VERSION }}_windows_amd64.exe"
# Copy any DLL files if they exist
if exist "desktop_gui\build\bin\*.dll" copy "desktop_gui\build\bin\*.dll" "release\"
shell: powershell
- name: Prepare artifacts (macOS)
if: matrix.os == 'macos-latest'
run: |
mkdir -p release
cp "desktop_gui/build/bin/${{ env.APP_NAME }}" "release/${{ env.ENGLISH_NAME }}_v${{ env.VERSION }}_darwin_arm64"
shell: bash
- name: Create ZIP archive
run: |
cd release
if [[ "$RUNNER_OS" == "Windows" ]]; then
powershell -command "Compress-Archive -Path '*' -DestinationPath '${{ env.ENGLISH_NAME }}_v${{ env.VERSION }}_${{ matrix.artifact_suffix }}.zip' -Force"
else
zip -r "${{ env.ENGLISH_NAME }}_v${{ env.VERSION }}_${{ matrix.artifact_suffix }}.zip" *
fi
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.platform }}
path: release/${{ env.ENGLISH_NAME }}_v${{ env.VERSION }}_${{ matrix.artifact_suffix }}.zip
release:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set version from tag
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "Releasing version: $VERSION"
shell: bash
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create release
uses: softprops/action-gh-release@v1
with:
name: ${{ env.APP_NAME }} v${{ env.VERSION }}
body: |
## ${{ env.APP_NAME }} v${{ env.VERSION }}
### 下载链接:
- Windows (amd64): lemon_push_gui_v${{ env.VERSION }}_windows_amd64.zip
- macOS (arm64): lemon_push_gui_v${{ env.VERSION }}_darwin_arm64.zip
### 安装说明:
#### Windows:
1. 下载并解压 lemon_push_gui_v${{ env.VERSION }}_windows_amd64.zip
2. 运行 lemon_push_gui_v${{ env.VERSION }}_windows_amd64.exe
#### macOS:
1. 下载并解压 lemon_push_gui_v${{ env.VERSION }}_darwin_arm64.zip
2. 将 lemon_push_gui_v${{ env.VERSION }}_darwin_arm64 移动到应用程序文件夹
files: |
artifacts/windows/amd64/lemon_push_gui_v${{ env.VERSION }}_windows_amd64.zip
artifacts/darwin/arm64/lemon_push_gui_v${{ env.VERSION }}_darwin_arm64.zip
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}