mirror of
https://github.com/OpenListTeam/OpenList-Desktop.git
synced 2025-11-25 03:14:56 +08:00
feat: update release ci (#8)
* 📦 Chore(custom): update build command * 🐛 Fix(custom): fix action error * 🐛 Fix(custom): fix ci * 🐛 Fix(custom): fix prepare.js for linux and macos * 🐛 Fix(custom): fix windows scripts syntax * 🐛 Fix(custom): add linker for linux * 🐛 Fix(custom): fix linux arm building * 🐛 Fix(custom): add creation flags for silent installer on Windows
This commit is contained in:
5
.cargo/config.toml
Normal file
5
.cargo/config.toml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
[target.aarch64-unknown-linux-gnu]
|
||||||
|
linker = "aarch64-linux-gnu-gcc"
|
||||||
|
|
||||||
|
[target.armv7-unknown-linux-gnueabihf]
|
||||||
|
linker = "arm-linux-gnueabihf-gcc"
|
||||||
11
.github/workflows/ci.yml
vendored
11
.github/workflows/ci.yml
vendored
@@ -13,17 +13,6 @@ on:
|
|||||||
- 'Cargo.toml'
|
- 'Cargo.toml'
|
||||||
- 'Cargo.lock'
|
- 'Cargo.lock'
|
||||||
- '.github/workflows/ci.yml'
|
- '.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:
|
env:
|
||||||
CARGO_TERM_COLOR: always
|
CARGO_TERM_COLOR: always
|
||||||
|
|||||||
84
.github/workflows/release.yml
vendored
84
.github/workflows/release.yml
vendored
@@ -12,11 +12,7 @@ on:
|
|||||||
required: false
|
required: false
|
||||||
type: boolean
|
type: boolean
|
||||||
default: false
|
default: false
|
||||||
workflow_call:
|
|
||||||
inputs:
|
|
||||||
version:
|
|
||||||
required: true
|
|
||||||
type: string
|
|
||||||
permissions: write-all
|
permissions: write-all
|
||||||
env:
|
env:
|
||||||
CARGO_INCREMENTAL: 0
|
CARGO_INCREMENTAL: 0
|
||||||
@@ -162,7 +158,7 @@ jobs:
|
|||||||
if: github.event_name == 'workflow_dispatch' && inputs.version == ''
|
if: github.event_name == 'workflow_dispatch' && inputs.version == ''
|
||||||
run: |
|
run: |
|
||||||
# Update package.json
|
# 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
|
# Update Cargo.toml
|
||||||
sed -i 's/^version = "[^"]*"/version = "${{ steps.version.outputs.version }}"/' src-tauri/Cargo.toml
|
sed -i 's/^version = "[^"]*"/version = "${{ steps.version.outputs.version }}"/' src-tauri/Cargo.toml
|
||||||
@@ -352,6 +348,45 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
yarn install
|
yarn install
|
||||||
yarn run prebuild:dev --target=${{ matrix.target }}
|
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)
|
- name: Import Apple Developer Certificate (macOS only)
|
||||||
if: matrix.os == 'macos-latest'
|
if: matrix.os == 'macos-latest'
|
||||||
@@ -429,6 +464,18 @@ jobs:
|
|||||||
yarn install
|
yarn install
|
||||||
yarn run prebuild:dev --target=${{ matrix.target }}
|
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"
|
- name: "Setup for linux"
|
||||||
run: |-
|
run: |-
|
||||||
sudo ls -lR /etc/apt/
|
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_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig/:$PKG_CONFIG_PATH
|
||||||
export PKG_CONFIG_SYSROOT_DIR=/usr/arm-linux-gnueabihf/
|
export PKG_CONFIG_SYSROOT_DIR=/usr/arm-linux-gnueabihf/
|
||||||
fi
|
fi
|
||||||
pnpm build --target ${{ matrix.target }}
|
yarn build --target ${{ matrix.target }}
|
||||||
env:
|
env:
|
||||||
NODE_OPTIONS: "--max_old_space_size=4096"
|
NODE_OPTIONS: "--max_old_space_size=4096"
|
||||||
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
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 "VERSION=$(cat package.json | jq '.version' | tr -d '"')" >> $GITHUB_ENV
|
||||||
echo "BUILDTIME=$(TZ=Asia/Shanghai date)" >> $GITHUB_ENV
|
echo "BUILDTIME=$(TZ=Asia/Shanghai date)" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Upload Release
|
- name: Upload ARM artifacts
|
||||||
uses: softprops/action-gh-release@v2
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ needs.changelog.outputs.tag }}
|
name: linux-${{ matrix.target }}-artifacts
|
||||||
name: 'OpenList Desktop ${{ needs.changelog.outputs.tag }}'
|
path: |
|
||||||
body: ${{ needs.changelog.outputs.changelog }}
|
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
files: |
|
|
||||||
src-tauri/target/${{ matrix.target }}/release/bundle/deb/*.deb
|
src-tauri/target/${{ matrix.target }}/release/bundle/deb/*.deb
|
||||||
src-tauri/target/${{ matrix.target }}/release/bundle/rpm/*.rpm
|
src-tauri/target/${{ matrix.target }}/release/bundle/rpm/*.rpm
|
||||||
|
|
||||||
@@ -521,7 +565,14 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: changelog
|
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
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ needs.changelog.outputs.tag }}
|
tag_name: ${{ needs.changelog.outputs.tag }}
|
||||||
@@ -529,5 +580,8 @@ jobs:
|
|||||||
body_path: changelog.md
|
body_path: changelog.md
|
||||||
draft: false
|
draft: false
|
||||||
prerelease: false
|
prerelease: false
|
||||||
|
files: |
|
||||||
|
arm-artifacts/**/*.deb
|
||||||
|
arm-artifacts/**/*.rpm
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { execSync } from 'node:child_process'
|
import { execSync } from 'node:child_process'
|
||||||
|
import fsp from 'node:fs/promises'
|
||||||
import path from 'node:path'
|
import path from 'node:path'
|
||||||
|
|
||||||
import AdmZip from 'adm-zip'
|
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) {
|
async function resolveSidecar(binInfo) {
|
||||||
const { name, targetFile, zipFile, exeFile, downloadURL } = binInfo
|
const { name, targetFile, zipFile, exeFile, downloadURL } = binInfo
|
||||||
const binaryDir = path.join(cwd, 'src-tauri', 'binary')
|
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('install-openlist-service'))
|
||||||
await resolveService(getServiceInfo('openlist-desktop-service'))
|
await resolveService(getServiceInfo('openlist-desktop-service'))
|
||||||
await resolveService(getServiceInfo('uninstall-openlist-service'))
|
await resolveService(getServiceInfo('uninstall-openlist-service'))
|
||||||
|
|||||||
@@ -12,10 +12,16 @@ pub async fn get_binary_version(binary_name: Option<String>) -> Result<String, S
|
|||||||
} else {
|
} else {
|
||||||
app_dir.join(binary_name.unwrap_or("openlist".to_string()))
|
app_dir.join(binary_name.unwrap_or("openlist".to_string()))
|
||||||
};
|
};
|
||||||
let output = Command::new(binary_path)
|
let mut cmd = Command::new(binary_path);
|
||||||
.arg("version")
|
cmd.arg("version");
|
||||||
.output()
|
|
||||||
.map_err(|e| e.to_string())?;
|
#[cfg(windows)]
|
||||||
|
{
|
||||||
|
use std::os::windows::process::CommandExt;
|
||||||
|
cmd.creation_flags(0x08000000); // CREATE_NO_WINDOW
|
||||||
|
}
|
||||||
|
|
||||||
|
let output = cmd.output().map_err(|e| e.to_string())?;
|
||||||
if output.status.success() {
|
if output.status.success() {
|
||||||
let version_output = String::from_utf8_lossy(&output.stdout);
|
let version_output = String::from_utf8_lossy(&output.stdout);
|
||||||
let version_line = version_output
|
let version_line = version_output
|
||||||
|
|||||||
@@ -396,6 +396,12 @@ async fn install_windows_update(installer_path: &PathBuf) -> Result<(), String>
|
|||||||
let mut cmd = Command::new(installer_path);
|
let mut cmd = Command::new(installer_path);
|
||||||
cmd.arg("/SILENT");
|
cmd.arg("/SILENT");
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
{
|
||||||
|
use std::os::windows::process::CommandExt;
|
||||||
|
cmd.creation_flags(0x08000000); // CREATE_NO_WINDOW
|
||||||
|
}
|
||||||
|
|
||||||
let _ = tokio::task::spawn_blocking(move || {
|
let _ = tokio::task::spawn_blocking(move || {
|
||||||
cmd.spawn()
|
cmd.spawn()
|
||||||
.map_err(|e| format!("Failed to start Windows installer: {e}"))
|
.map_err(|e| format!("Failed to start Windows installer: {e}"))
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"identifier": "io.github.openlistteam.openlist.desktop",
|
"identifier": "io.github.openlistteam.openlist.desktop",
|
||||||
"build": {
|
"build": {
|
||||||
"beforeDevCommand": "npm run dev",
|
"beforeDevCommand": "yarn run dev",
|
||||||
"devUrl": "http://localhost:5173",
|
"devUrl": "http://localhost:5173",
|
||||||
"beforeBuildCommand": "npm run build",
|
"beforeBuildCommand": "yarn run web:build",
|
||||||
"frontendDist": "../dist"
|
"frontendDist": "../dist"
|
||||||
},
|
},
|
||||||
"app": {
|
"app": {
|
||||||
|
|||||||
Reference in New Issue
Block a user