forked from longbridge/gpui-component
-
Notifications
You must be signed in to change notification settings - Fork 51
373 lines (325 loc) · 13 KB
/
Copy pathrelease.yml
File metadata and controls
373 lines (325 loc) · 13 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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
keep_build_cache:
description: "Restore and save Cargo build cache for faster release builds"
type: boolean
default: true
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build (${{ matrix.target }})
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-apple-darwin
os: macos-latest
binary: onetcli
archive: onetcli-aarch64-apple-darwin.tar.gz
- target: x86_64-apple-darwin
os: macos-15-intel
binary: onetcli
archive: onetcli-x86_64-apple-darwin.tar.gz
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
binary: onetcli
archive: onetcli-x86_64-unknown-linux-gnu.tar.gz
- target: aarch64-unknown-linux-gnu
os: ubuntu-24.04-arm
binary: onetcli
archive: onetcli-aarch64-unknown-linux-gnu.tar.gz
- target: x86_64-pc-windows-msvc
os: windows-latest
binary: onetcli.exe
archive: onetcli-x86_64-pc-windows-msvc.zip
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: ${{ matrix.target }}
- name: Free disk space (macOS)
if: runner.os == 'macOS'
run: |
df -h
remove_path() {
local path="$1"
if [ -e "$path" ]; then
sudo rm -rf "$path" || echo "::warning::Failed to remove $path"
fi
}
remove_directory_contents() {
local path="$1"
if [ -d "$path" ]; then
sudo find "$path" -mindepth 1 -maxdepth 1 -exec rm -rf {} + \
|| echo "::warning::Failed to remove some entries under $path"
fi
}
remove_path /usr/local/lib/node_modules
remove_path "$HOME/.npm"
remove_path "$HOME/.nvm"
remove_directory_contents "$HOME/Library/Caches"
remove_path /System/Library/Frameworks/Python.framework
df -h
- name: Install system dependencies (Linux)
if: runner.os == 'Linux'
run: script/bootstrap
- name: Install system dependencies (macOS)
if: runner.os == 'macOS'
run: script/bootstrap
- name: Install system dependencies (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
cmake --version
- name: Cache Cargo
if: ${{ github.event_name != 'workflow_dispatch' || inputs.keep_build_cache }}
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: release-cargo-${{ runner.os }}-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}-${{ github.run_id }}
restore-keys: |
release-cargo-${{ runner.os }}-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}-
release-cargo-${{ runner.os }}-${{ matrix.target }}-
- name: Set environment variables
shell: bash
run: |
if [[ "${{ github.ref_type }}" == "tag" ]]; then
VERSION="${{ github.ref_name }}"
VERSION="${VERSION#v}"
echo "ONETCLI_VERSION=${VERSION}" >> "$GITHUB_ENV"
else
echo "ONETCLI_VERSION=0.0.0-dev.$(git rev-parse --short HEAD)" >> "$GITHUB_ENV"
fi
if [[ "${{ matrix.target }}" == "aarch64-unknown-linux-gnu" ]]; then
echo "CARGO_BUILD_JOBS=1" >> "$GITHUB_ENV"
echo "CARGO_PROFILE_RELEASE_LTO=false" >> "$GITHUB_ENV"
echo "CARGO_PROFILE_RELEASE_CODEGEN_UNITS=16" >> "$GITHUB_ENV"
fi
- name: Verify secrets are set
shell: bash
env:
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }}
run: |
if [ -z "$SUPABASE_URL" ]; then
echo "::error::SUPABASE_URL secret is empty or not set"
exit 1
fi
if [ -z "$SUPABASE_ANON_KEY" ]; then
echo "::error::SUPABASE_ANON_KEY secret is empty or not set"
exit 1
fi
- name: Build release binary
env:
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }}
ONETCLI_PUBLIC_BASE_URL: ${{ vars.ONETCLI_PUBLIC_BASE_URL }}
ONETCLI_TEAM_MANAGEMENT_URL_TEMPLATE: ${{ vars.ONETCLI_TEAM_MANAGEMENT_URL_TEMPLATE }}
run: |
cargo --version
rustc --version
echo "CARGO_BUILD_JOBS=${CARGO_BUILD_JOBS:-}"
echo "CARGO_PROFILE_RELEASE_LTO=${CARGO_PROFILE_RELEASE_LTO:-}"
echo "CARGO_PROFILE_RELEASE_CODEGEN_UNITS=${CARGO_PROFILE_RELEASE_CODEGEN_UNITS:-}"
cargo build --release -p main --target ${{ matrix.target }}
- name: Clean build artifacts (macOS)
if: ${{ runner.os == 'macOS' && github.event_name == 'workflow_dispatch' && inputs.keep_build_cache == false }}
run: |
rm -rf target/debug
find target -name "incremental" -o -name "deps" -o -name "build" | xargs rm -rf || true
rm -rf ~/.cargo/registry/cache ~/.cargo/git/db
df -h
- name: Create macOS app bundle
if: runner.os == 'macOS'
run: |
chmod +x script/bundle-macos.sh
chmod +x script/bundle-macos-dmg.sh
script/bundle-macos.sh ${{ matrix.target }}
script/bundle-macos-dmg.sh ${{ matrix.target }}
tar czf ${{ matrix.archive }} -C target OnetCli.app
- name: Package (Linux)
if: runner.os == 'Linux'
run: |
mkdir -p package/usr/bin
mkdir -p package/usr/share/applications
mkdir -p package/usr/share/icons/hicolor/128x128/apps
mkdir -p package/usr/share/icons/hicolor/256x256/apps
mkdir -p package/usr/share/icons/hicolor/512x515/apps
cp target/${{ matrix.target }}/release/${{ matrix.binary }} package/usr/bin/
cp resources/linux/onetcli.desktop package/usr/share/applications/
cp resources/linux/onetcli-128.png package/usr/share/icons/hicolor/128x128/apps/onetcli.png
cp resources/linux/onetcli-256.png package/usr/share/icons/hicolor/256x256/apps/onetcli.png
cp resources/linux/onetcli-512.png package/usr/share/icons/hicolor/512x515/apps/onetcli.png
tar czf ${{ matrix.archive }} -C package .
- name: Install Linux packaging dependencies
if: matrix.target == 'x86_64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y rpm
- name: Package Linux installers (x86_64)
if: matrix.target == 'x86_64-unknown-linux-gnu'
shell: bash
run: |
set -euo pipefail
PACKAGE_VERSION="${ONETCLI_VERSION//-/.}"
DEB_NAME="onetcli_${PACKAGE_VERSION}_amd64.deb"
RPM_NAME="onetcli-${PACKAGE_VERSION}-1.x86_64.rpm"
APPIMAGE_NAME="onetcli_${PACKAGE_VERSION}_amd64.AppImage"
rm -rf package-deb rpmbuild OnetCli.AppDir linuxdeploy-x86_64.AppImage
mkdir -p package-deb/DEBIAN
cp -a package/. package-deb/
cat > package-deb/DEBIAN/control <<EOF
Package: onetcli
Version: ${PACKAGE_VERSION}
Section: utils
Priority: optional
Architecture: amd64
Maintainer: feigeCode <noreply@github.com>
Homepage: https://github.com/feigeCode/onetcli
Description: One Net Client - Database, SSH, Terminal, AI Tools
EOF
dpkg-deb --root-owner-group --build package-deb "${DEB_NAME}"
RPM_ROOT="${PWD}/rpmbuild"
mkdir -p "${RPM_ROOT}"/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
tar czf "${RPM_ROOT}/SOURCES/onetcli-${PACKAGE_VERSION}.tar.gz" -C package .
cat > "${RPM_ROOT}/SPECS/onetcli.spec" <<EOF
Name: onetcli
Version: ${PACKAGE_VERSION}
Release: 1%{?dist}
Summary: One Net Client - Database, SSH, Terminal, AI Tools
License: Apache-2.0
URL: https://github.com/feigeCode/onetcli
BuildArch: x86_64
Source0: %{name}-%{version}.tar.gz
%description
One Net Client - Database, SSH, Terminal, AI Tools.
%prep
mkdir -p %{_builddir}/%{name}-%{version}
tar -xzf %{SOURCE0} -C %{_builddir}/%{name}-%{version}
%build
%install
mkdir -p %{buildroot}
cp -a %{_builddir}/%{name}-%{version}/* %{buildroot}/
%files
/usr/bin/onetcli
/usr/share/applications/onetcli.desktop
/usr/share/icons/hicolor/128x128/apps/onetcli.png
/usr/share/icons/hicolor/256x256/apps/onetcli.png
/usr/share/icons/hicolor/512x515/apps/onetcli.png
EOF
rpmbuild --define "_topdir ${RPM_ROOT}" -bb "${RPM_ROOT}/SPECS/onetcli.spec"
generated_rpm="$(find "${RPM_ROOT}/RPMS" -name "onetcli-${PACKAGE_VERSION}-1*.x86_64.rpm" -print -quit)"
test -n "${generated_rpm}"
cp "${generated_rpm}" "${RPM_NAME}"
mkdir -p OnetCli.AppDir
cp -a package/. OnetCli.AppDir/
curl -L -o linuxdeploy-x86_64.AppImage \
https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
chmod +x linuxdeploy-x86_64.AppImage
VERSION="${PACKAGE_VERSION}" APPIMAGE_EXTRACT_AND_RUN=1 ./linuxdeploy-x86_64.AppImage \
--appdir OnetCli.AppDir \
--executable OnetCli.AppDir/usr/bin/onetcli \
--desktop-file resources/linux/onetcli.desktop \
--icon-file package/usr/share/icons/hicolor/512x515/apps/onetcli.png \
--output appimage
generated_appimage="$(find . -maxdepth 1 -name '*.AppImage' ! -name 'linuxdeploy-x86_64.AppImage' -print -quit)"
test -n "${generated_appimage}"
mv "${generated_appimage}" "${APPIMAGE_NAME}"
- name: Package (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
New-Item -ItemType Directory -Force package | Out-Null
Copy-Item "target/${{ matrix.target }}/release/${{ matrix.binary }}" "package/${{ matrix.binary }}"
Compress-Archive -Path "package/*" -DestinationPath "${{ matrix.archive }}"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.archive }}
path: ${{ matrix.archive }}
- name: Upload macOS DMG artifact
if: runner.os == 'macOS'
uses: actions/upload-artifact@v4
with:
name: onetcli-${{ matrix.target }}.dmg
path: "*.dmg"
- name: Upload Linux installer artifacts
if: matrix.target == 'x86_64-unknown-linux-gnu'
uses: actions/upload-artifact@v4
with:
name: onetcli-linux-x86_64-installers
path: |
onetcli_*.deb
onetcli-*.rpm
onetcli_*.AppImage
release:
name: Create Release
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: List artifacts
run: ls -la artifacts/
- name: Generate checksums
run: |
cd artifacts
shopt -s nullglob
release_files=(onetcli-* onetcli_*)
if [ "${#release_files[@]}" -eq 0 ]; then
echo "::error::No release artifacts found for checksum generation"
exit 1
fi
sha256sum "${release_files[@]}" > sha256sums.txt
cat sha256sums.txt
- name: Write release metadata
run: |
node <<'NODE'
const fs = require("fs");
const releaseTag = process.env.GITHUB_REF_NAME;
const version = releaseTag.replace(/^v/, "");
fs.writeFileSync(
"artifacts/release-metadata.json",
`${JSON.stringify({ release_tag: releaseTag, version }, null, 2)}\n`,
);
NODE
- name: Upload release metadata
uses: actions/upload-artifact@v4
with:
name: release-metadata
path: artifacts/release-metadata.json
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: OnetCli ${{ github.ref_name }}
generate_release_notes: true
files: |
artifacts/onetcli-*.tar.gz
artifacts/onetcli-*.zip
artifacts/onetcli-*.dmg
artifacts/onetcli_*.deb
artifacts/onetcli-*.rpm
artifacts/onetcli_*.AppImage
artifacts/sha256sums.txt