diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..beb596d --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,5 @@ +[target.aarch64-unknown-linux-gnu] +linker = "aarch64-linux-gnu-gcc" + +[target.armv7-unknown-linux-gnueabihf] +linker = "arm-linux-gnueabihf-gcc" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0e3795e..e2404cb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,17 +13,6 @@ on: - 'Cargo.toml' - 'Cargo.lock' - '.github/workflows/ci.yml' - push: - branches: [ main, dev ] - paths: - - 'src/**' - - 'src-tauri/**' - - 'package.json' - - 'package-lock.json' - - 'yarn.lock' - - 'Cargo.toml' - - 'Cargo.lock' - - '.github/workflows/ci.yml' env: CARGO_TERM_COLOR: always diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cd20ac5..cf7068d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,11 +12,7 @@ on: required: false type: boolean default: false - workflow_call: - inputs: - version: - required: true - type: string + permissions: write-all env: CARGO_INCREMENTAL: 0 @@ -162,7 +158,7 @@ jobs: if: github.event_name == 'workflow_dispatch' && inputs.version == '' run: | # Update package.json - npm version ${{ steps.version.outputs.version }} --no-git-tag-version + yarn version --new-version ${{ steps.version.outputs.version }} --no-git-tag-version # Update Cargo.toml sed -i 's/^version = "[^"]*"/version = "${{ steps.version.outputs.version }}"/' src-tauri/Cargo.toml @@ -352,6 +348,45 @@ jobs: run: | yarn install yarn run prebuild:dev --target=${{ matrix.target }} + + - name: Update version for build (Windows) + if: needs.auto-version.outputs.version && runner.os == 'Windows' + shell: pwsh + run: | + # Update package.json + yarn version --new-version ${{ needs.auto-version.outputs.version }} --no-git-tag-version + + # Update Cargo.toml + (Get-Content src-tauri/Cargo.toml) -replace '^version = ".*"', 'version = "${{ needs.auto-version.outputs.version }}"' | Set-Content src-tauri/Cargo.toml + + # Update tauri.conf.json + (Get-Content src-tauri/tauri.conf.json) -replace '"version": ".*"', '"version": "${{ needs.auto-version.outputs.version }}"' | Set-Content src-tauri/tauri.conf.json + + - name: Update version for build (macOS) + if: needs.auto-version.outputs.version && runner.os == 'macOS' + shell: bash + run: | + # Update package.json + yarn version --new-version ${{ needs.auto-version.outputs.version }} --no-git-tag-version + + # Update Cargo.toml + sed -i '' 's/^version = "[^"]*"/version = "${{ needs.auto-version.outputs.version }}"/' src-tauri/Cargo.toml + + # Update tauri.conf.json + sed -i '' 's/"version": "[^"]*"/"version": "${{ needs.auto-version.outputs.version }}"/' src-tauri/tauri.conf.json + + - name: Update version for build (Linux) + if: needs.auto-version.outputs.version && runner.os == 'Linux' + shell: bash + run: | + # Update package.json + yarn version --new-version ${{ needs.auto-version.outputs.version }} --no-git-tag-version + + # Update Cargo.toml + sed -i 's/^version = "[^"]*"/version = "${{ needs.auto-version.outputs.version }}"/' src-tauri/Cargo.toml + + # Update tauri.conf.json + sed -i 's/"version": "[^"]*"/"version": "${{ needs.auto-version.outputs.version }}"/' src-tauri/tauri.conf.json - name: Import Apple Developer Certificate (macOS only) if: matrix.os == 'macos-latest' @@ -429,6 +464,18 @@ jobs: yarn install yarn run prebuild:dev --target=${{ matrix.target }} + - name: Update version for build + if: needs.auto-version.outputs.version + run: | + # Update package.json + yarn version --new-version ${{ needs.auto-version.outputs.version }} --no-git-tag-version + + # Update Cargo.toml + sed -i 's/^version = "[^"]*"/version = "${{ needs.auto-version.outputs.version }}"/' src-tauri/Cargo.toml + + # Update tauri.conf.json + sed -i 's/"version": "[^"]*"/"version": "${{ needs.auto-version.outputs.version }}"/' src-tauri/tauri.conf.json + - name: "Setup for linux" run: |- sudo ls -lR /etc/apt/ @@ -483,7 +530,7 @@ jobs: export PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig/:$PKG_CONFIG_PATH export PKG_CONFIG_SYSROOT_DIR=/usr/arm-linux-gnueabihf/ fi - pnpm build --target ${{ matrix.target }} + yarn build --target ${{ matrix.target }} env: NODE_OPTIONS: "--max_old_space_size=4096" TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }} @@ -496,14 +543,11 @@ jobs: echo "VERSION=$(cat package.json | jq '.version' | tr -d '"')" >> $GITHUB_ENV echo "BUILDTIME=$(TZ=Asia/Shanghai date)" >> $GITHUB_ENV - - name: Upload Release - uses: softprops/action-gh-release@v2 + - name: Upload ARM artifacts + uses: actions/upload-artifact@v4 with: - tag_name: ${{ needs.changelog.outputs.tag }} - name: 'OpenList Desktop ${{ needs.changelog.outputs.tag }}' - body: ${{ needs.changelog.outputs.changelog }} - token: ${{ secrets.GITHUB_TOKEN }} - files: | + name: linux-${{ matrix.target }}-artifacts + path: | src-tauri/target/${{ matrix.target }}/release/bundle/deb/*.deb src-tauri/target/${{ matrix.target }}/release/bundle/rpm/*.rpm @@ -521,7 +565,14 @@ jobs: with: name: changelog - - name: Update release + - name: Download ARM artifacts + uses: actions/download-artifact@v4 + with: + pattern: linux-*-artifacts + merge-multiple: true + path: arm-artifacts + + - name: Update release with ARM artifacts uses: softprops/action-gh-release@v1 with: tag_name: ${{ needs.changelog.outputs.tag }} @@ -529,5 +580,8 @@ jobs: body_path: changelog.md draft: false prerelease: false + files: | + arm-artifacts/**/*.deb + arm-artifacts/**/*.rpm env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/scripts/prepare.js b/scripts/prepare.js index abbeb59..6fbbdd6 100644 --- a/scripts/prepare.js +++ b/scripts/prepare.js @@ -1,4 +1,5 @@ import { execSync } from 'node:child_process' +import fsp from 'node:fs/promises' import path from 'node:path' import AdmZip from 'adm-zip' @@ -80,6 +81,32 @@ const getServiceInfo = exeName => { } } +// SimpleSC.dll +const resolvePlugin = async () => { + const url = 'https://nsis.sourceforge.io/mediawiki/images/e/ef/NSIS_Simple_Service_Plugin_Unicode_1.30.zip' + const TEMP_DIR = path.join(cwd, 'temp') + const tempDir = path.join(TEMP_DIR, 'SimpleSC') + const tempZip = path.join(tempDir, 'NSIS_Simple_Service_Plugin_Unicode_1.30.zip') + const tempDll = path.join(tempDir, 'SimpleSC.dll') + const pluginDir = path.join(process.env.APPDATA, 'Local/NSIS') + const pluginPath = path.join(pluginDir, 'SimpleSC.dll') + await fs.mkdir(pluginDir, { recursive: true }) + await fs.mkdir(tempDir, { recursive: true }) + if (fs.existsSync(pluginPath)) return + try { + if (!fs.existsSync(tempZip)) { + await downloadFile(url, tempZip) + } + const zip = new AdmZip(tempZip) + + zip.extractAllTo(tempDir, true) + await fsp.cp(tempDll, pluginPath, { recursive: true, force: true }) + console.log(`SimpleSC.dll copied to ${pluginPath}`) + } finally { + await fsp.rm(tempDir, { recursive: true, force: true }) + } +} + async function resolveSidecar(binInfo) { const { name, targetFile, zipFile, exeFile, downloadURL } = binInfo const binaryDir = path.join(cwd, 'src-tauri', 'binary') @@ -172,7 +199,9 @@ async function main() { ) ) }) - + if (isWin) { + await resolvePlugin() + } await resolveService(getServiceInfo('install-openlist-service')) await resolveService(getServiceInfo('openlist-desktop-service')) await resolveService(getServiceInfo('uninstall-openlist-service')) diff --git a/src-tauri/packages/linux/openist.desktop b/src-tauri/packages/linux/openlist.desktop similarity index 100% rename from src-tauri/packages/linux/openist.desktop rename to src-tauri/packages/linux/openlist.desktop diff --git a/src-tauri/src/cmd/binary.rs b/src-tauri/src/cmd/binary.rs index 5c3d41f..8345006 100644 --- a/src-tauri/src/cmd/binary.rs +++ b/src-tauri/src/cmd/binary.rs @@ -12,10 +12,16 @@ pub async fn get_binary_version(binary_name: Option) -> Result Result<(), String> let mut cmd = Command::new(installer_path); cmd.arg("/SILENT"); + #[cfg(windows)] + { + use std::os::windows::process::CommandExt; + cmd.creation_flags(0x08000000); // CREATE_NO_WINDOW + } + let _ = tokio::task::spawn_blocking(move || { cmd.spawn() .map_err(|e| format!("Failed to start Windows installer: {e}")) diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 65617fe..96616e0 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -4,9 +4,9 @@ "version": "0.1.0", "identifier": "io.github.openlistteam.openlist.desktop", "build": { - "beforeDevCommand": "npm run dev", + "beforeDevCommand": "yarn run dev", "devUrl": "http://localhost:5173", - "beforeBuildCommand": "npm run build", + "beforeBuildCommand": "yarn run web:build", "frontendDist": "../dist" }, "app": {