Skip to content

Commit 2394ab6

Browse files
committed
chore(ci): use @moeru-ai/airi's electron build workflow
1 parent 56f8d22 commit 2394ab6

8 files changed

Lines changed: 527 additions & 149 deletions

File tree

.github/workflows/build-app.yml

Lines changed: 0 additions & 60 deletions
This file was deleted.

.github/workflows/release-app.yml

Lines changed: 142 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,54 +3,183 @@ name: Release App
33
permissions:
44
contents: write
55

6+
env:
7+
PRODUCT_NAME: 'Deditor'
8+
BUNDLE_NAME: ''
9+
610
on:
711
release:
812
types:
913
- prereleased
14+
workflow_dispatch:
15+
inputs:
16+
build_only:
17+
description: Build only
18+
required: false
19+
default: false
20+
type: boolean
21+
artifacts_only:
22+
description: Build and upload artifacts only
23+
required: false
24+
default: false
25+
type: boolean
26+
tag:
27+
description: Specific tag/commit for the release (leave empty to auto-detect latest tag)
28+
required: false
29+
type: string
30+
schedule:
31+
- cron: '0 0 * * *'
1032

1133
jobs:
1234
build:
1335
name: Build
1436
strategy:
1537
matrix:
1638
include:
39+
1740
- os: macos-13
1841
artifact: darwin-x64
42+
target: x86_64-apple-darwin
43+
builder-args: --macos --x64
1944
ext: dmg
45+
2046
- os: macos-latest
2147
artifact: darwin-arm64
48+
target: aarch64-apple-darwin
49+
builder-args: --macos --arm64
2250
ext: dmg
51+
2352
- os: ubuntu-latest
2453
artifact: linux-x64
54+
target: x86_64-unknown-linux-gnu
55+
builder-args: --linux --x64
2556
ext: AppImage
26-
# - os: ubuntu-24.04-arm
27-
# artifact: linux-arm64
28-
# ext: AppImage
57+
58+
- os: ubuntu-24.04-arm
59+
artifact: linux-arm64
60+
target: aarch64-unknown-linux-gnu
61+
builder-args: --linux --arm64
62+
ext: AppImage
63+
2964
- os: windows-latest
3065
artifact: windows-x64-setup
66+
target: x86_64-pc-windows-msvc
67+
builder-args: --windows --x64
3168
ext: exe
69+
3270
runs-on: ${{ matrix.os }}
3371
steps:
34-
- uses: actions/checkout@v4
72+
# Why?
73+
#
74+
# failed to build archive at `/home/runner/work/deditor/deditor/target/x86_64-unknown-linux-gnu/release/deps/libapp_lib.rlib`:
75+
# No space left on device (os error 28)
76+
- name: Free Disk Space
77+
if: matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-24.04-arm'
78+
uses: jlumbroso/free-disk-space@main
79+
80+
- uses: actions/checkout@v5
3581
- uses: pnpm/action-setup@v4
3682
with:
3783
run_install: false
38-
- uses: actions/setup-node@v4
84+
- uses: actions/setup-node@v5
3985
with:
4086
node-version: lts/*
4187
cache: pnpm
4288
- run: pnpm install --frozen-lockfile
43-
- name: Build
89+
90+
# ---------
91+
# Build
92+
# ---------
93+
94+
- run: pnpm run build:packages
95+
96+
- name: Build (Windows Only) # Windows
97+
if: matrix.os == 'windows-latest'
98+
run: pnpm run -F @deditor-app/deditor build && pnpm -F @deditor-app/deditor exec electron-builder build ${{ matrix.builder-args }}
99+
100+
- name: Build (macOS Only) # macOS
101+
if: matrix.os == 'macos-13' || matrix.os == 'macos-latest'
102+
run: pnpm run -F @deditor-app/deditor build && pnpm -F @deditor-app/deditor exec electron-builder build ${{ matrix.builder-args }}
103+
104+
- name: Build (Linux Only) # Linux
105+
if: matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-24.04-arm'
106+
run: pnpm run -F @deditor-app/deditor build && pnpm -F @deditor-app/deditor exec electron-builder build ${{ matrix.builder-args }}
107+
108+
# ---------
109+
# Nightly (schedule) builds only
110+
# ---------
111+
- name: Get Name of Artifacts (Nightly + Windows Only)
112+
if: ${{ github.event_name == 'schedule' && matrix.os == 'windows-latest' }}
113+
run: |
114+
pnpm -F @deditor-app/deditor name-of-artifacts ${{ matrix.target }} --out bundle_name
115+
echo "BUNDLE_NAME=$(node -p "require('node:fs').readFileSync(require('node:path').join('apps', 'deditor', 'bundle_name')).toString('utf-8')")" >> $env:GITHUB_ENV
116+
117+
- name: Get Name of Artifacts (Nightly)
118+
if: ${{ github.event_name == 'schedule' && matrix.os != 'windows-latest' }}
44119
run: |
45-
pnpm run build:packages
46-
pnpm run build:electron
120+
pnpm -F @deditor-app/deditor name-of-artifacts ${{ matrix.target }} --out bundle_name
121+
echo "BUNDLE_NAME=$(node -p "require('node:fs').readFileSync(require('node:path').join('apps', 'deditor', 'bundle_name')).toString('utf-8')")" >> $GITHUB_ENV
122+
123+
- name: Rename Artifacts (Nightly)
124+
if: ${{ github.event_name == 'schedule' }}
125+
run:
126+
pnpm run -F @deditor-app/deditor rename-artifacts ${{ matrix.target }}
127+
128+
- name: Upload Artifacts (Nightly)
129+
if: ${{ github.event_name == 'schedule' }}
130+
uses: actions/upload-artifact@v4
131+
with:
132+
name: ${{ env.BUNDLE_NAME }}
133+
path: apps/deditor/bundle/${{ env.BUNDLE_NAME }}
134+
135+
# ---------
136+
# Workflow Dispatch only
137+
# ---------
138+
139+
- name: Get Name of Artifacts (Manual + Windows Only)
140+
if: ${{ github.event_name == 'workflow_dispatch' && matrix.os == 'windows-latest' }}
141+
run: |
142+
pnpm -F @deditor-app/deditor name-of-artifacts ${{ matrix.target }} --out bundle_name --release ${{ !inputs.build_only && !inputs.artifacts_only }} --tag ${{ inputs.tag }} --auto-tag ${{ !inputs.build_only }}
143+
echo "BUNDLE_NAME=$(node -p "require('node:fs').readFileSync(require('node:path').join('apps', 'deditor', 'bundle_name')).toString('utf-8')")" >> $env:GITHUB_ENV
144+
145+
- name: Get Name of Artifacts (Manual)
146+
if: ${{ github.event_name == 'workflow_dispatch' && matrix.os != 'windows-latest' }}
147+
run: |
148+
pnpm -F @deditor-app/deditor name-of-artifacts ${{ matrix.target }} --out bundle_name --release ${{ !inputs.build_only && !inputs.artifacts_only }} --tag ${{ inputs.tag }} --auto-tag ${{ !inputs.build_only }}
149+
echo "BUNDLE_NAME=$(node -p "require('node:fs').readFileSync(require('node:path').join('apps', 'deditor', 'bundle_name')).toString('utf-8')")" >> $GITHUB_ENV
150+
151+
- name: Rename Artifacts (Manual)
152+
if: ${{ github.event_name == 'workflow_dispatch' }}
153+
run: |
154+
pnpm run -F @deditor-app/deditor rename-artifacts ${{ matrix.target }} --release ${{ !inputs.build_only && !inputs.artifacts_only }} --tag ${{ inputs.tag }} --auto-tag ${{ !inputs.build_only }}
155+
156+
- name: Upload Artifacts (Manual + Non-Release)
157+
if: ${{ github.event_name == 'workflow_dispatch' && !inputs.build_only && inputs.artifacts_only }}
158+
uses: actions/upload-artifact@v4
159+
with:
160+
name: ${{ env.BUNDLE_NAME }}
161+
path: apps/deditor/bundle/${{ env.BUNDLE_NAME }}
162+
163+
- name: Upload To GitHub Releases (Manual + Overwrite Release)
164+
if: ${{ github.event_name == 'workflow_dispatch' && !inputs.build_only && !inputs.artifacts_only }}
165+
uses: softprops/action-gh-release@v2
166+
with:
167+
files: apps/deditor/bundle/${{ env.PRODUCT_NAME }}_*
168+
append_body: true
169+
tag_name: ${{ inputs.tag }}
170+
171+
# ---------
172+
# Version push
173+
# ---------
47174

48-
- id: version
175+
- name: Rename Artifacts (Automatic)
176+
if: ${{ github.event_name == 'release' }}
49177
run: |
50-
echo VERSION=$(pnpm exec tsx scripts/get-package-json-version.ts) >> $GITHUB_ENV
178+
pnpm run -F @deditor-app/deditor rename-artifacts ${{ matrix.target }} --release --auto-tag
51179
52-
- name: Upload To GitHub Releases
180+
- name: Upload To GitHub Releases (Automatic)
181+
if: ${{ github.event_name == 'release' }}
53182
uses: softprops/action-gh-release@v2
54183
with:
55-
files: dist/Deditor-v${{ steps.version.outputs.VERSION }}-${{ matrix.artifact }}.${{ matrix.ext }}
56-
generate_release_notes: true
184+
files: apps/deditor/bundle/${{ env.PRODUCT_NAME }}_*
185+
append_body: true

apps/deditor/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,15 @@
7979
"@types/three": "^0.180.0",
8080
"@unocss/reset": "^66.5.3",
8181
"@vitejs/plugin-vue": "^6.0.1",
82+
"cac": "^6.7.14",
8283
"class-variance-authority": "^0.7.1",
8384
"clsx": "^2.1.1",
8485
"debug": "^4.4.3",
8586
"drizzle-orm": "^0.44.6",
8687
"electron": "^38.2.2",
8788
"electron-builder": "^26.0.12",
8889
"electron-vite": "^4.0.1",
90+
"execa": "^9.6.0",
8991
"ml-pca": "^4.1.1",
9092
"msvana-tsne": "^0.1.2",
9193
"postgres": "^3.4.7",
@@ -98,6 +100,7 @@
98100
"unplugin-vue-router": "^0.15.0",
99101
"vite-plugin-vue-devtools": "^8.0.2",
100102
"vite-plugin-vue-layouts": "^0.11.0",
101-
"vue-tsc": "^3.1.1"
103+
"vue-tsc": "^3.1.1",
104+
"yaml": "^2.8.1"
102105
}
103106
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import process from 'node:process'
2+
3+
import { existsSync, mkdirSync, writeFileSync } from 'node:fs'
4+
import { dirname } from 'node:path'
5+
6+
import { cac } from 'cac'
7+
8+
import { getFilename } from './utils'
9+
10+
async function main() {
11+
const cli = cac('name-of-artifact')
12+
.option(
13+
'--release',
14+
'Rename with version from package.json',
15+
{ default: false },
16+
)
17+
.option(
18+
'--auto-tag',
19+
'Automatically tag the release with the latest git ref',
20+
{ default: false },
21+
)
22+
.option(
23+
'--tag <tag>',
24+
'Tag to use for the release',
25+
{ default: '', type: [String] },
26+
)
27+
.option(
28+
'--out <path>',
29+
'Path to output the filename',
30+
{ default: 'bundle_name', type: [String] },
31+
)
32+
33+
const args = cli.parse()
34+
35+
const argOptions = args.options as {
36+
release: boolean
37+
autoTag: boolean
38+
tag: string[]
39+
out: string[]
40+
}
41+
42+
const target = args.args[0]
43+
const filename = await getFilename(target, argOptions)
44+
if (argOptions.out[0]) {
45+
if (!existsSync(dirname(argOptions.out[0]))) {
46+
mkdirSync(dirname(argOptions.out[0]), { recursive: true })
47+
}
48+
49+
writeFileSync(argOptions.out[0], filename, { encoding: 'utf-8' })
50+
}
51+
else {
52+
console.info(filename)
53+
}
54+
}
55+
56+
main()
57+
.catch((error) => {
58+
console.error('Error during generating name:', error)
59+
process.exit(1)
60+
})

0 commit comments

Comments
 (0)