Skip to content

Commit c319318

Browse files
committed
修改依赖,以及添加tex提示的支持
删除测试文件 修复latex支持 fix: tex提示错误 简化release feat: 改正git actions fix: git actions fix:git actions 修改gaction fix:git action
1 parent 8633830 commit c319318

File tree

13 files changed

+23148
-1865
lines changed

13 files changed

+23148
-1865
lines changed
Lines changed: 260 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,260 @@
1+
name: 'Build and Release'
2+
3+
on:
4+
push:
5+
tags: ['v*']
6+
workflow_dispatch:
7+
inputs:
8+
tag:
9+
description: 'Tag to release'
10+
required: true
11+
default: 'v1.0.0'
12+
13+
jobs:
14+
create-release:
15+
permissions:
16+
contents: write
17+
runs-on: ubuntu-22.04
18+
outputs:
19+
release_id: ${{ steps.create-release.outputs.result }}
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: Create release
26+
id: create-release
27+
uses: actions/github-script@v7
28+
with:
29+
script: |
30+
const { data } = await github.rest.repos.createRelease({
31+
owner: context.repo.owner,
32+
repo: context.repo.repo,
33+
tag_name: context.ref.replace('refs/tags/', '') || '${{ github.event.inputs.tag }}',
34+
name: `MDX Notes ${context.ref.replace('refs/tags/', '') || '${{ github.event.inputs.tag }}'}`,
35+
body: 'Auto-generated release',
36+
draft: true,
37+
prerelease: false
38+
})
39+
return data.id
40+
41+
build-tauri:
42+
needs: create-release
43+
permissions:
44+
contents: write
45+
strategy:
46+
fail-fast: false
47+
matrix:
48+
include:
49+
- platform: 'macos-latest'
50+
args: '--target aarch64-apple-darwin'
51+
target: 'aarch64-apple-darwin'
52+
name: 'macOS-ARM64'
53+
- platform: 'macos-latest'
54+
args: '--target x86_64-apple-darwin'
55+
target: 'x86_64-apple-darwin'
56+
name: 'macOS-Intel'
57+
- platform: 'ubuntu-22.04'
58+
args: ''
59+
target: 'x86_64-unknown-linux-gnu'
60+
name: 'Linux-x86_64'
61+
- platform: 'windows-latest'
62+
args: ''
63+
target: 'x86_64-pc-windows-msvc'
64+
name: 'Windows-x86_64'
65+
66+
runs-on: ${{ matrix.platform }}
67+
steps:
68+
- name: Checkout repository
69+
uses: actions/checkout@v4
70+
71+
- name: Install dependencies (Ubuntu only)
72+
if: matrix.platform == 'ubuntu-22.04'
73+
run: |
74+
sudo apt-get update
75+
sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
76+
77+
- name: Setup Node.js
78+
uses: actions/setup-node@v4
79+
with:
80+
node-version: '18'
81+
cache: 'npm'
82+
83+
- name: Install Rust stable
84+
uses: dtolnay/rust-toolchain@stable
85+
with:
86+
targets: ${{ matrix.target }}
87+
88+
- name: Rust cache
89+
uses: swatinem/rust-cache@v2
90+
with:
91+
workspaces: './src-tauri -> target'
92+
93+
- name: Install frontend dependencies
94+
run: npm ci
95+
96+
- name: Build application
97+
env:
98+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
99+
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
100+
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
101+
run: |
102+
if [ -n "${{ matrix.args }}" ]; then
103+
npm run tauri build -- ${{ matrix.args }}
104+
else
105+
npm run tauri build
106+
fi
107+
108+
- name: Find and upload assets (macOS)
109+
if: matrix.platform == 'macos-latest'
110+
uses: actions/github-script@v7
111+
with:
112+
script: |
113+
const fs = require('fs').promises;
114+
const path = require('path');
115+
116+
const targetDir = 'src-tauri/target/${{ matrix.target }}/release/bundle';
117+
118+
// Upload DMG
119+
try {
120+
const dmgDir = `${targetDir}/dmg`;
121+
const dmgFiles = await fs.readdir(dmgDir);
122+
for (const file of dmgFiles.filter(f => f.endsWith('.dmg'))) {
123+
const filePath = path.join(dmgDir, file);
124+
const stats = await fs.stat(filePath);
125+
const fileData = await fs.readFile(filePath);
126+
127+
await github.rest.repos.uploadReleaseAsset({
128+
owner: context.repo.owner,
129+
repo: context.repo.repo,
130+
release_id: ${{ needs.create-release.outputs.release_id }},
131+
name: `MDX-Notes-${{ matrix.name }}.dmg`,
132+
data: fileData,
133+
});
134+
console.log(`Uploaded ${file} as MDX-Notes-${{ matrix.name }}.dmg`);
135+
}
136+
} catch (error) {
137+
console.log('No DMG files found or error uploading:', error.message);
138+
}
139+
140+
- name: Find and upload assets (Ubuntu)
141+
if: matrix.platform == 'ubuntu-22.04'
142+
uses: actions/github-script@v7
143+
with:
144+
script: |
145+
const fs = require('fs').promises;
146+
const path = require('path');
147+
148+
const targetDir = 'src-tauri/target/release/bundle';
149+
150+
// Upload DEB
151+
try {
152+
const debDir = `${targetDir}/deb`;
153+
const debFiles = await fs.readdir(debDir);
154+
for (const file of debFiles.filter(f => f.endsWith('.deb'))) {
155+
const filePath = path.join(debDir, file);
156+
const fileData = await fs.readFile(filePath);
157+
158+
await github.rest.repos.uploadReleaseAsset({
159+
owner: context.repo.owner,
160+
repo: context.repo.repo,
161+
release_id: ${{ needs.create-release.outputs.release_id }},
162+
name: `MDX-Notes-${{ matrix.name }}.deb`,
163+
data: fileData,
164+
});
165+
console.log(`Uploaded ${file} as MDX-Notes-${{ matrix.name }}.deb`);
166+
}
167+
} catch (error) {
168+
console.log('No DEB files found or error uploading:', error.message);
169+
}
170+
171+
// Upload AppImage
172+
try {
173+
const appImageDir = `${targetDir}/appimage`;
174+
const appImageFiles = await fs.readdir(appImageDir);
175+
for (const file of appImageFiles.filter(f => f.endsWith('.AppImage'))) {
176+
const filePath = path.join(appImageDir, file);
177+
const fileData = await fs.readFile(filePath);
178+
179+
await github.rest.repos.uploadReleaseAsset({
180+
owner: context.repo.owner,
181+
repo: context.repo.repo,
182+
release_id: ${{ needs.create-release.outputs.release_id }},
183+
name: `MDX-Notes-${{ matrix.name }}.AppImage`,
184+
data: fileData,
185+
});
186+
console.log(`Uploaded ${file} as MDX-Notes-${{ matrix.name }}.AppImage`);
187+
}
188+
} catch (error) {
189+
console.log('No AppImage files found or error uploading:', error.message);
190+
}
191+
192+
- name: Find and upload assets (Windows)
193+
if: matrix.platform == 'windows-latest'
194+
uses: actions/github-script@v7
195+
with:
196+
script: |
197+
const fs = require('fs').promises;
198+
const path = require('path');
199+
200+
const targetDir = 'src-tauri/target/release/bundle';
201+
202+
// Upload MSI
203+
try {
204+
const msiDir = `${targetDir}/msi`;
205+
const msiFiles = await fs.readdir(msiDir);
206+
for (const file of msiFiles.filter(f => f.endsWith('.msi'))) {
207+
const filePath = path.join(msiDir, file);
208+
const fileData = await fs.readFile(filePath);
209+
210+
await github.rest.repos.uploadReleaseAsset({
211+
owner: context.repo.owner,
212+
repo: context.repo.repo,
213+
release_id: ${{ needs.create-release.outputs.release_id }},
214+
name: `MDX-Notes-${{ matrix.name }}.msi`,
215+
data: fileData,
216+
});
217+
console.log(`Uploaded ${file} as MDX-Notes-${{ matrix.name }}.msi`);
218+
}
219+
} catch (error) {
220+
console.log('No MSI files found or error uploading:', error.message);
221+
}
222+
223+
// Upload NSIS installer
224+
try {
225+
const nsisDir = `${targetDir}/nsis`;
226+
const nsisFiles = await fs.readdir(nsisDir);
227+
for (const file of nsisFiles.filter(f => f.endsWith('.exe'))) {
228+
const filePath = path.join(nsisDir, file);
229+
const fileData = await fs.readFile(filePath);
230+
231+
await github.rest.repos.uploadReleaseAsset({
232+
owner: context.repo.owner,
233+
repo: context.repo.repo,
234+
release_id: ${{ needs.create-release.outputs.release_id }},
235+
name: `MDX-Notes-${{ matrix.name }}-Setup.exe`,
236+
data: fileData,
237+
});
238+
console.log(`Uploaded ${file} as MDX-Notes-${{ matrix.name }}-Setup.exe`);
239+
}
240+
} catch (error) {
241+
console.log('No NSIS files found or error uploading:', error.message);
242+
}
243+
244+
publish-release:
245+
permissions:
246+
contents: write
247+
runs-on: ubuntu-22.04
248+
needs: [create-release, build-tauri]
249+
250+
steps:
251+
- name: Publish release
252+
uses: actions/github-script@v7
253+
with:
254+
script: |
255+
github.rest.repos.updateRelease({
256+
owner: context.repo.owner,
257+
repo: context.repo.repo,
258+
release_id: ${{ needs.create-release.outputs.release_id }},
259+
draft: false
260+
})

.github/workflows/release.yml

Lines changed: 55 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
name: 'Publish'
22
on:
33
push:
4-
tags: [v\d+\.\d+\.\d+]
4+
tags: [v*]
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: 'Version to release'
9+
required: true
10+
default: 'v1.0.0'
511

612
jobs:
713
publish-tauri:
@@ -11,58 +17,82 @@ jobs:
1117
fail-fast: false
1218
matrix:
1319
settings:
14-
- platform: 'macos-latest' # for Arm based macs (M1 and above).
20+
- platform: 'macos-latest'
1521
args: '--target aarch64-apple-darwin'
16-
- platform: 'macos-latest' # for Intel based macs.
22+
arch: 'aarch64'
23+
- platform: 'macos-latest'
1724
args: '--target x86_64-apple-darwin'
18-
- platform: 'ubuntu-22.04' # for Tauri v1 you could replace this with ubuntu-20.04.
25+
arch: 'x86_64'
26+
- platform: 'ubuntu-22.04'
1927
args: ''
28+
arch: 'x86_64'
2029
- platform: 'windows-latest'
2130
args: ''
31+
arch: 'x86_64'
2232

2333
runs-on: ${{ matrix.settings.platform }}
2434
steps:
25-
- uses: actions/checkout@v4
35+
- name: Checkout repository
36+
uses: actions/checkout@v4
2637

27-
- name: install dependencies (ubuntu only)
28-
if: matrix.settings.platform == 'ubuntu-22.04' # This must match the platform value defined above.
38+
- name: Install dependencies (ubuntu only)
39+
if: matrix.settings.platform == 'ubuntu-22.04'
2940
run: |
3041
sudo apt-get update
3142
sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
32-
# webkitgtk 4.0 is for Tauri v1 - webkitgtk 4.1 is for Tauri v2.
33-
# You can remove the one that doesn't apply to your app to speed up the workflow a bit.
3443
35-
- name: setup node
44+
- name: Setup Node.js
3645
uses: actions/setup-node@v4
3746
with:
38-
node-version: lts/*
39-
cache: 'yarn' # Set this to npm, yarn or pnpm.
47+
node-version: '18'
48+
cache: 'npm'
4049

41-
- name: install Rust stable
50+
- name: Install Rust stable
4251
uses: dtolnay/rust-toolchain@stable
4352
with:
44-
# Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds.
4553
targets: ${{ matrix.settings.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}
4654

4755
- name: Rust cache
4856
uses: swatinem/rust-cache@v2
4957
with:
5058
workspaces: './src-tauri -> target'
5159

52-
- name: install frontend dependencies
53-
# If you don't have `beforeBuildCommand` configured you may want to build your frontend here too.
54-
run: yarn install # change this to npm or pnpm depending on which one you use.
60+
- name: Install frontend dependencies
61+
run: npm ci
5562

56-
- uses: tauri-apps/tauri-action@v0
63+
- name: Build frontend
64+
run: npm run build
65+
66+
- name: Debug info
67+
run: |
68+
echo "Node version: $(node --version)"
69+
echo "NPM version: $(npm --version)"
70+
echo "Rust version: $(rustc --version)"
71+
echo "Cargo version: $(cargo --version)"
72+
echo "Package.json scripts:"
73+
cat package.json | grep -A 10 "scripts"
74+
echo "Tauri info:"
75+
npm run tauri info || true
76+
77+
- name: Build Tauri app
5778
env:
5879
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5980
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
6081
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
82+
run: |
83+
echo "Building for platform: ${{ matrix.settings.platform }}"
84+
echo "Build args: ${{ matrix.settings.args }}"
85+
86+
if [ "${{ matrix.settings.args }}" != "" ]; then
87+
npm run tauri build -- ${{ matrix.settings.args }}
88+
else
89+
npm run tauri build
90+
fi
91+
92+
- name: Upload artifacts
93+
uses: actions/upload-artifact@v4
6194
with:
62-
includeDebug: true
63-
tagName: v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version.
64-
releaseName: 'MDX Notes v__VERSION__'
65-
releaseBody: 'See the assets to download this version and install.'
66-
releaseDraft: true
67-
prerelease: false
68-
args: ${{ matrix.settings.args }}
95+
name: release-${{ matrix.settings.platform }}-${{ matrix.settings.arch }}
96+
path: |
97+
src-tauri/target/release/bundle/
98+
src-tauri/target/*/release/bundle/

0 commit comments

Comments
 (0)