-
-
Notifications
You must be signed in to change notification settings - Fork 40
199 lines (171 loc) · 6.1 KB
/
Copy pathbuild.yml
File metadata and controls
199 lines (171 loc) · 6.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
name: Build and Publish Electron App
on:
workflow_dispatch:
jobs:
build:
name: Build ${{ matrix.target }} - ${{ matrix.arch }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: linux
arch: x64
- os: ubuntu-latest
target: linux
arch: arm64
- os: macos-latest
target: mac
arch: x64
- os: macos-latest
target: mac
arch: arm64
- os: windows-latest
target: win
arch: x64
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '23.x'
- name: Install Python to fix node-gyp issues
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Cache Node.js modules
uses: actions/cache@v4
with:
path: |
~/.npm
node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-modules-
- name: Install dependencies
run: |
npm install --no-optional
npm install -g @electron/rebuild
- name: Manually install dmg-license (macOS only)
if: matrix.os == 'macos-latest'
run: npm install dmg-license
- name: Rebuild native dependencies
run: |
npx @electron/rebuild -f
env:
PYTHON: python3
- name: Build the app
run: npm run dist
- name: Build for production with electron-builder
run: npm run build:${{ matrix.target }}:${{ matrix.arch }}
env:
GH_TOKEN: ${{ secrets.GH_PAT }}
- name: "Debug: List release-builds directory"
run: |
echo "Contents of release-builds directory:"
ls -l release-builds
- name: Prepare artifacts (Linux/macOS)
if: runner.os != 'Windows'
run: |
mkdir -p prepared-artifacts
# Handle Linux
if [[ "${{ matrix.target }}" == "linux" ]]; then
# Move setup files if they exist
if compgen -G "release-builds/*.AppImage" > /dev/null; then
mv release-builds/*.AppImage prepared-artifacts/
fi
if compgen -G "release-builds/*.snap" > /dev/null; then
mv release-builds/*.snap prepared-artifacts/
fi
# Compress unpacked folders appropriately
if [[ -d release-builds/linux-arm64-unpacked ]]; then
cd release-builds
zip -r ../prepared-artifacts/linux-arm64-unpacked.zip linux-arm64-unpacked
cd ..
elif [[ -d release-builds/linux-unpacked ]]; then
cd release-builds
zip -r ../prepared-artifacts/linux-unpacked.zip linux-unpacked
cd ..
fi
fi
# Handle macOS
if [[ "${{ matrix.target }}" == "mac" ]]; then
# Move setup file if it exists
if compgen -G "release-builds/*.dmg" > /dev/null; then
mv release-builds/*.dmg prepared-artifacts/
fi
# Compress unpacked folders appropriately
if [[ "${{ matrix.arch }}" == "x64" && -d release-builds/mac ]]; then
cd release-builds
zip -r ../prepared-artifacts/mac-unpacked.zip mac
cd ..
elif [[ -d release-builds/mac-${{ matrix.arch }} ]]; then
cd release-builds
zip -r ../prepared-artifacts/mac-${{ matrix.arch }}.zip mac-${{ matrix.arch }}
cd ..
fi
fi
shell: bash
- name: Prepare artifacts (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
mkdir -p prepared-artifacts
# Move setup file (e.g., .exe)
if (Test-Path "release-builds/*.exe") {
Move-Item "release-builds/*.exe" "prepared-artifacts/"
}
# Compress unpacked folder
if (Test-Path "release-builds/win-unpacked") {
Compress-Archive -Path "release-builds/win-unpacked/*" -DestinationPath "prepared-artifacts/win-unpacked-${{ matrix.arch }}.zip"
}
- name: Move artifacts to release directory
run: |
mkdir -p release-artifacts
mv prepared-artifacts/* release-artifacts/
- name: Upload setup files
uses: actions/upload-artifact@v4
with:
name: setup-files-${{ matrix.target }}-${{ matrix.arch }}
path: |
release-artifacts/*.exe
release-artifacts/*.dmg
release-artifacts/*.AppImage
release-artifacts/*.snap
- name: Upload unpacked folders (zipped)
uses: actions/upload-artifact@v4
with:
name: unpacked-folders-${{ matrix.target }}-${{ matrix.arch }}
path: release-artifacts/*.zip
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Create Git tag
run: |
TAG_NAME="v$(date +'%Y%m%d%H%M%S')"
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git tag $TAG_NAME
git remote set-url origin https://x-access-token:${{ secrets.GH_PAT }}@github.com/${{ github.repository }}
git push origin $TAG_NAME
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: release-artifacts
- name: Upload GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.TAG_NAME }}
files: |
release-artifacts/**/*.exe
release-artifacts/**/*.dmg
release-artifacts/**/*.AppImage
release-artifacts/**/*.snap
release-artifacts/**/*.zip
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}