-
Notifications
You must be signed in to change notification settings - Fork 0
244 lines (219 loc) · 8.57 KB
/
Copy pathbuild-release.yml
File metadata and controls
244 lines (219 loc) · 8.57 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
name: Build jb_updater
on:
push:
branches: [ "**" ]
tags: [ "v*.*.*" ]
pull_request:
workflow_dispatch: { }
permissions:
contents: write
# =========================================================
# =============== BUILD JOBS ==========================
# =========================================================
jobs:
linux:
name: Linux x86_64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: crystal-lang/install-crystal@v1
with:
crystal: latest
- name: Install Linux dependencies
run: |
sudo apt-get update
sudo apt-get install -y libxml2-dev libssl-dev libpcre2-dev libgc-dev liblzma-dev libgtk-3-dev
- name: Install shards
working-directory: jb_updater
run: shards install
- name: Run specs
working-directory: jb_updater
run: crystal spec -v
- name: Run Ameba linter
working-directory: jb_updater
run: ./bin/lint
- name: Build binaries (CLI + GUI)
run: |
cd jb_updater
# CLI
crystal build src/main.cr --release -o jb_updater
# GUI
crystal build src/gui/main_gui.cr --release -o jb_updater_gui
cd ..
# Package CLI
tar -czf jb_updater-linux-x86_64.tar.gz -C jb_updater jb_updater
# Package GUI
tar -czf jb_updater-gui-linux-x86_64.tar.gz -C jb_updater jb_updater_gui
# Package bundle: CLI + GUI together
mkdir -p jb_updater-bundle-linux
cp jb_updater/jb_updater jb_updater-bundle-linux/
cp jb_updater/jb_updater_gui jb_updater-bundle-linux/
tar -czf jb_updater-bundle-linux-x86_64.tar.gz -C jb_updater-bundle-linux .
- uses: actions/upload-artifact@v4
with:
name: jb_updater-linux-x86_64
path: jb_updater-linux-x86_64.tar.gz
- uses: actions/upload-artifact@v4
with:
name: jb_updater-gui-linux-x86_64
path: jb_updater-gui-linux-x86_64.tar.gz
- uses: actions/upload-artifact@v4
with:
name: jb_updater-bundle-linux-x86_64
path: jb_updater-bundle-linux-x86_64.tar.gz
macos:
name: macOS ${{ matrix.arch }}
strategy:
matrix:
include:
- arch: arm64
runs_on: macos-latest
- arch: x86_64
runs_on: macos-13
runs-on: ${{ matrix.runs_on }}
env:
ARCH: ${{ matrix.arch }}
steps:
- uses: actions/checkout@v4
- uses: crystal-lang/install-crystal@v1
with:
crystal: latest
- name: Install OpenSSL 3
run: brew install openssl@3
- name: Install shards
working-directory: jb_updater
run: shards install
- name: Run specs
working-directory: jb_updater
run: crystal spec -v
- name: Run Ameba linter
working-directory: jb_updater
run: ./bin/lint
- name: Build binaries (CLI + GUI)
run: |
cd jb_updater
brew_prefix=$(brew --prefix openssl@3)
unset PKG_CONFIG_PATH
export PKG_CONFIG_PATH="${brew_prefix}/lib/pkgconfig"
echo "Using OpenSSL from ${brew_prefix}"
# CLI
crystal build src/main.cr --release --no-debug \
--link-flags "-L${brew_prefix}/lib -I${brew_prefix}/include" \
-o jb_updater
# GUI
crystal build src/gui/main_gui.cr --release --no-debug \
--link-flags "-L${brew_prefix}/lib -I${brew_prefix}/include" \
-o jb_updater_gui
cd ..
# Package CLI alone (as before)
tar -czf jb_updater-macos-${ARCH}.tar.gz -C jb_updater jb_updater
# Package raw CLI+GUI binaries together (new)
mkdir -p jb_updater-bundle
cp jb_updater/jb_updater jb_updater-bundle/
cp jb_updater/jb_updater_gui jb_updater-bundle/
zip -ry jb_updater-macos-${ARCH}-binaries.zip jb_updater-bundle
# Create a simple .app bundle for GUI (includes CLI inside)
APP_ROOT="JBUpdater.app/Contents"
mkdir -p "$APP_ROOT/MacOS" "$APP_ROOT/Resources"
cp jb_updater/jb_updater_gui "$APP_ROOT/MacOS/jb_updater_gui"
cp jb_updater/jb_updater "$APP_ROOT/MacOS/jb_updater"
cat > "$APP_ROOT/Info.plist" <<'PLIST'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"><dict>
<key>CFBundleName</key><string>JB Updater</string>
<key>CFBundleIdentifier</key><string>com.example.jb-updater</string>
<key>CFBundleVersion</key><string>1.0</string>
<key>CFBundleExecutable</key><string>jb_updater_gui</string>
<key>LSMinimumSystemVersion</key><string>11.0</string>
<key>NSHighResolutionCapable</key><true/>
</dict></plist>
PLIST
# Package GUI app bundle
zip -ry jb_updater-gui-macos-${ARCH}.zip JBUpdater.app
- uses: actions/upload-artifact@v4
with:
name: jb_updater-macos-${{ matrix.arch }}
path: jb_updater-macos-${{ matrix.arch }}.tar.gz
- uses: actions/upload-artifact@v4
with:
name: jb_updater-gui-macos-${{ matrix.arch }}
path: jb_updater-gui-macos-${{ matrix.arch }}.zip
- uses: actions/upload-artifact@v4
with:
name: jb_updater-macos-${{ matrix.arch }}-binaries
path: jb_updater-macos-${{ matrix.arch }}-binaries.zip
windows:
name: Windows x64
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: crystal-lang/install-crystal@v1
with:
crystal: latest
# Ensure MSVC build environment is set up (cl, link, mt, etc.)
- name: Set up MSVC Developer Command Prompt
uses: ilammy/msvc-dev-cmd@v1
- name: Install shards
working-directory: jb_updater
run: shards install
- name: Run specs
working-directory: jb_updater
run: crystal spec -v
- name: Build binaries (CLI + GUI)
working-directory: jb_updater
run: |
# CLI
crystal build src/main.cr --release -o jb_updater.exe
# GUI (windowed subsystem to hide console)
crystal build src/gui/main_gui.cr --release --link-flags=/SUBSYSTEM:WINDOWS -o jb_updater_gui.exe
- name: Package artifacts
run: |
Compress-Archive -Path jb_updater\jb_updater.exe -DestinationPath jb_updater-windows-x64.zip
Compress-Archive -Path jb_updater\jb_updater_gui.exe -DestinationPath jb_updater-gui-windows-x64.zip
# Bundle: CLI + GUI together
New-Item -ItemType Directory -Force -Path jb_updater-bundle | Out-Null
Copy-Item jb_updater\jb_updater.exe jb_updater-bundle\
Copy-Item jb_updater\jb_updater_gui.exe jb_updater-bundle\
Compress-Archive -Path jb_updater-bundle\* -DestinationPath jb_updater-bundle-windows-x64.zip
- uses: actions/upload-artifact@v4
with:
name: jb_updater-windows-x64
path: jb_updater-windows-x64.zip
- uses: actions/upload-artifact@v4
with:
name: jb_updater-gui-windows-x64
path: jb_updater-gui-windows-x64.zip
- uses: actions/upload-artifact@v4
with:
name: jb_updater-bundle-windows-x64
path: jb_updater-bundle-windows-x64.zip
# =========================================================
# =============== RELEASE JOB =========================
# =========================================================
release:
name: Create GitHub Release
needs: [ linux, macos, windows ]
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/')
steps:
- name: Verify branch or tag
run: |
echo "Triggered by $GITHUB_EVENT_NAME for ref $GITHUB_REF"
if [[ "$GITHUB_EVENT_NAME" == "workflow_dispatch" && "$GITHUB_REF_NAME" != "master" ]]; then
echo "⚠️ Manual releases are allowed only from master branch."
exit 1
fi
- name: Download all build artifacts
uses: actions/download-artifact@v4
with:
path: ./all-artifacts
- name: Flatten artifacts
run: |
mkdir -p release-assets
find ./all-artifacts -type f -exec mv {} ./release-assets/ \;
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: release-assets/*
generate_release_notes: true