-
Notifications
You must be signed in to change notification settings - Fork 2
feat: comprehensive improvements and dev workflow enhancements #136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
bfabb44
3f6d7b5
5e487c4
1906dfe
5c03602
901bfdd
3363096
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,236 @@ | ||
| name: Dev Release Build | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| platform: | ||
| description: 'Target platform' | ||
| required: true | ||
| type: choice | ||
| options: | ||
| - macos | ||
| - linux | ||
| - windows | ||
| version: | ||
| description: 'Version to set (optional)' | ||
| required: false | ||
| type: string | ||
|
|
||
| jobs: | ||
| build-macos: | ||
| runs-on: macos-latest | ||
| if: ${{ inputs.platform == 'macos' }} | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '20' | ||
|
|
||
| - name: Setup pnpm | ||
| uses: pnpm/action-setup@v3 | ||
| with: | ||
| version: 8 | ||
| run_install: false | ||
|
|
||
| - name: Get pnpm store directory | ||
| shell: bash | ||
| run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | ||
|
|
||
| - name: Setup pnpm cache | ||
| uses: actions/cache@v3 | ||
| with: | ||
| path: ${{ env.STORE_PATH }} | ||
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-pnpm-store- | ||
|
|
||
| - name: Install dependencies | ||
| run: pnpm install | ||
|
|
||
| - name: Set version | ||
| if: ${{ inputs.version != '' }} | ||
| shell: bash | ||
| run: | | ||
| node -e " | ||
| const fs = require('fs'); | ||
| const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); | ||
| pkg.version = '${{ inputs.version }}'; | ||
| fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n'); | ||
| console.log(\`Version set to \${pkg.version}\`); | ||
| " | ||
|
|
||
|
Comment on lines
+54
to
+65
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Add validation for version input format The version setting logic doesn't validate the format of the input version string. Consider adding validation to ensure it follows semantic versioning or your project's version format to prevent invalid versions from being set. - name: Set version
if: ${{ inputs.version != '' }}
shell: bash
run: |
node -e "
const fs = require('fs');
+ const version = '${{ inputs.version }}';
+ // Basic semver validation
+ if (!/^v?\d+\.\d+\.\d+(-[a-zA-Z0-9.-]+)?(\+[a-zA-Z0-9.-]+)?$/.test(version)) {
+ console.error('Invalid version format: ' + version);
+ process.exit(1);
+ }
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
- pkg.version = '${{ inputs.version }}';
+ pkg.version = version;
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
console.log(\`Version set to \${pkg.version}\`);
"Also applies to: 127-138, 200-211 🤖 Prompt for AI Agents |
||
| - name: Build macOS package | ||
| run: | | ||
| pnpm build | ||
| pnpm exec electron-builder --mac --publish never | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| ELECTRON_BUILDER_CHANNEL: dev | ||
|
|
||
| - name: List build artifacts | ||
| shell: bash | ||
| run: | | ||
| echo "Build artifacts:" | ||
| find dist -type f -name "*" | head -20 | ||
|
|
||
| - name: Upload artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: macos-dev-artifacts | ||
| path: | | ||
| dist/*.dmg | ||
| dist/*.zip | ||
| dist/*.yml | ||
| dist/*.yaml | ||
| dist/*.blockmap | ||
| retention-days: 30 | ||
| if-no-files-found: warn | ||
|
|
||
| build-linux: | ||
| runs-on: ubuntu-latest | ||
| if: ${{ inputs.platform == 'linux' }} | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '20' | ||
|
|
||
| - name: Setup pnpm | ||
| uses: pnpm/action-setup@v3 | ||
| with: | ||
| version: 8 | ||
| run_install: false | ||
|
|
||
| - name: Get pnpm store directory | ||
| shell: bash | ||
| run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | ||
|
|
||
| - name: Setup pnpm cache | ||
| uses: actions/cache@v3 | ||
| with: | ||
| path: ${{ env.STORE_PATH }} | ||
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-pnpm-store- | ||
|
|
||
| - name: Install dependencies | ||
| run: pnpm install | ||
|
|
||
| - name: Set version | ||
| if: ${{ inputs.version != '' }} | ||
| shell: bash | ||
| run: | | ||
| node -e " | ||
| const fs = require('fs'); | ||
| const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); | ||
| pkg.version = '${{ inputs.version }}'; | ||
| fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n'); | ||
| console.log(\`Version set to \${pkg.version}\`); | ||
| " | ||
|
|
||
| - name: Build Linux package | ||
| run: | | ||
| pnpm build | ||
| pnpm exec electron-builder --linux --publish never | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| ELECTRON_BUILDER_CHANNEL: dev | ||
|
|
||
| - name: List build artifacts | ||
| shell: bash | ||
| run: | | ||
| echo "Build artifacts:" | ||
| find dist -type f -name "*" | head -20 | ||
|
|
||
| - name: Upload artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: linux-dev-artifacts | ||
| path: | | ||
| dist/*.AppImage | ||
| dist/*.deb | ||
| dist/*.yml | ||
| dist/*.yaml | ||
| dist/*.blockmap | ||
| retention-days: 30 | ||
| if-no-files-found: warn | ||
|
|
||
| build-windows: | ||
| runs-on: windows-latest | ||
| if: ${{ inputs.platform == 'windows' }} | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '20' | ||
|
|
||
| - name: Setup pnpm | ||
| uses: pnpm/action-setup@v3 | ||
| with: | ||
| version: 8 | ||
| run_install: false | ||
|
|
||
| - name: Get pnpm store directory | ||
| shell: bash | ||
| run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | ||
|
|
||
| - name: Setup pnpm cache | ||
| uses: actions/cache@v3 | ||
| with: | ||
| path: ${{ env.STORE_PATH }} | ||
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-pnpm-store- | ||
|
|
||
| - name: Install dependencies | ||
| run: pnpm install | ||
|
|
||
| - name: Set version | ||
| if: ${{ inputs.version != '' }} | ||
| shell: bash | ||
| run: | | ||
| node -e " | ||
| const fs = require('fs'); | ||
| const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); | ||
| pkg.version = '${{ inputs.version }}'; | ||
| fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n'); | ||
| console.log(\`Version set to \${pkg.version}\`); | ||
| " | ||
|
|
||
| - name: Build Windows package | ||
| run: | | ||
| pnpm build | ||
| pnpm exec electron-builder --win --publish never | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| ELECTRON_BUILDER_CHANNEL: dev | ||
|
|
||
| - name: List build artifacts | ||
| shell: bash | ||
| run: | | ||
| echo "Build artifacts:" | ||
| find dist -type f -name "*" | head -20 | ||
|
|
||
| - name: Upload artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: windows-dev-artifacts | ||
| path: | | ||
| dist/*.exe | ||
| dist/*.yml | ||
| dist/*.yaml | ||
| dist/*.blockmap | ||
| retention-days: 30 | ||
| if-no-files-found: warn | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,23 @@ | ||||||||||||||||||||||||||||||||||||
| export const videoExts = ['.mp4', '.avi', '.mov', '.wmv', '.flv', '.mkv'] | ||||||||||||||||||||||||||||||||||||
| export const audioExts = ['.mp3', '.wav', '.ogg', '.flac', '.aac'] | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||
| * 将扩展名数组转换为 Electron dialog 所需的格式(不含点) | ||||||||||||||||||||||||||||||||||||
| * @param extArray 扩展名数组(可包含或不包含点) | ||||||||||||||||||||||||||||||||||||
| * @returns 不含点的扩展名数组 | ||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||
| export function toDialogExtensions(extArray: string[]): string[] { | ||||||||||||||||||||||||||||||||||||
| return extArray.map((ext) => (ext.startsWith('.') ? ext.slice(1) : ext)) | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
Comment on lines
+4
to
+11
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix contract mismatch: strip all leading dots and update JSDoc Doc says “不含点”, but implementation only removes one leading dot (e.g., '..mp4' -> '.mp4'). Make it remove all leading dots to meet the contract and avoid downstream dialog issues. /**
- * 将扩展名数组转换为 Electron dialog 所需的格式(不含点)
+ * 将扩展名数组转换为 Electron dialog 所需的格式(不含点)
+ * 注意:会移除所有前导点(如 '..mp4' => 'mp4')
* @param extArray 扩展名数组(可包含或不包含点)
* @returns 不含点的扩展名数组
*/
export function toDialogExtensions(extArray: string[]): string[] {
- return extArray.map((ext) => (ext.startsWith('.') ? ext.slice(1) : ext))
+ return extArray.map((ext) => ext.replace(/^\.+/, ''))
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||
| * 获取用于 Electron dialog 的视频文件扩展名数组 | ||||||||||||||||||||||||||||||||||||
| * @returns 不含点的视频扩展名数组 | ||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||
| export function getVideoDialogExtensions(): string[] { | ||||||||||||||||||||||||||||||||||||
| return toDialogExtensions(videoExts) | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
Comment on lines
+17
to
+19
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Memoize getVideoDialogExtensions to avoid per-call allocations This aligns with the test intent “应该缓存结果以提高性能” and avoids repeated mapping. +let _videoDialogExtensions: string[] | null = null
export function getVideoDialogExtensions(): string[] {
- return toDialogExtensions(videoExts)
+ return (_videoDialogExtensions ??= toDialogExtensions(videoExts))
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| export const KB = 1024 | ||||||||||||||||||||||||||||||||||||
| export const MB = 1024 * KB | ||||||||||||||||||||||||||||||||||||
| export const GB = 1024 * MB | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Update deprecated actions/cache to v4
The workflow uses
actions/cache@v3which is deprecated. GitHub recommends updating to v4 for continued support and security updates.Apply this update to all three occurrences (lines 44, 117, 190).
Also applies to: 117-117, 190-190
🧰 Tools
🪛 actionlint (1.7.7)
44-44: the runner of "actions/cache@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
🤖 Prompt for AI Agents