Merge pull request #6721 from menloresearch/chore/use-custom-nsis-template
chore: use custom nsis template # Conflicts: # Makefile # package.json # src-tauri/tauri.windows.conf.json
This commit is contained in:
parent
6c4dd85e6f
commit
816d60b22a
@ -49,6 +49,8 @@ jobs:
|
|||||||
# Update tauri.conf.json
|
# Update tauri.conf.json
|
||||||
jq --arg version "${{ inputs.new_version }}" '.version = $version | .bundle.createUpdaterArtifacts = false' ./src-tauri/tauri.conf.json > /tmp/tauri.conf.json
|
jq --arg version "${{ inputs.new_version }}" '.version = $version | .bundle.createUpdaterArtifacts = false' ./src-tauri/tauri.conf.json > /tmp/tauri.conf.json
|
||||||
mv /tmp/tauri.conf.json ./src-tauri/tauri.conf.json
|
mv /tmp/tauri.conf.json ./src-tauri/tauri.conf.json
|
||||||
|
jq '.bundle.windows.nsis.template = "tauri.bundle.windows.nsis.template"' ./src-tauri/tauri.windows.conf.json > /tmp/tauri.windows.conf.json
|
||||||
|
mv /tmp/tauri.windows.conf.json ./src-tauri/tauri.windows.conf.json
|
||||||
jq '.bundle.windows.signCommand = "echo External build - skipping signature: %1"' ./src-tauri/tauri.windows.conf.json > /tmp/tauri.windows.conf.json
|
jq '.bundle.windows.signCommand = "echo External build - skipping signature: %1"' ./src-tauri/tauri.windows.conf.json > /tmp/tauri.windows.conf.json
|
||||||
mv /tmp/tauri.windows.conf.json ./src-tauri/tauri.windows.conf.json
|
mv /tmp/tauri.windows.conf.json ./src-tauri/tauri.windows.conf.json
|
||||||
jq --arg version "${{ inputs.new_version }}" '.version = $version' web-app/package.json > /tmp/package.json
|
jq --arg version "${{ inputs.new_version }}" '.version = $version' web-app/package.json > /tmp/package.json
|
||||||
@ -80,6 +82,36 @@ jobs:
|
|||||||
echo "---------./src-tauri/Cargo.toml---------"
|
echo "---------./src-tauri/Cargo.toml---------"
|
||||||
cat ./src-tauri/Cargo.toml
|
cat ./src-tauri/Cargo.toml
|
||||||
|
|
||||||
|
generate_build_version() {
|
||||||
|
### Examble
|
||||||
|
### input 0.5.6 output will be 0.5.6 and 0.5.6.0
|
||||||
|
### input 0.5.6-rc2-beta output will be 0.5.6 and 0.5.6.2
|
||||||
|
### input 0.5.6-1213 output will be 0.5.6 and and 0.5.6.1213
|
||||||
|
local new_version="$1"
|
||||||
|
local base_version
|
||||||
|
local t_value
|
||||||
|
# Check if it has a "-"
|
||||||
|
if [[ "$new_version" == *-* ]]; then
|
||||||
|
base_version="${new_version%%-*}" # part before -
|
||||||
|
suffix="${new_version#*-}" # part after -
|
||||||
|
# Check if it is rcX-beta
|
||||||
|
if [[ "$suffix" =~ ^rc([0-9]+)-beta$ ]]; then
|
||||||
|
t_value="${BASH_REMATCH[1]}"
|
||||||
|
else
|
||||||
|
t_value="$suffix"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
base_version="$new_version"
|
||||||
|
t_value="0"
|
||||||
|
fi
|
||||||
|
# Export two values
|
||||||
|
new_base_version="$base_version"
|
||||||
|
new_build_version="${base_version}.${t_value}"
|
||||||
|
}
|
||||||
|
generate_build_version ${{ inputs.new_version }}
|
||||||
|
sed -i "s/jan_version/$new_base_version/g" ./src-tauri/tauri.bundle.windows.nsis.template
|
||||||
|
sed -i "s/jan_build/$new_build_version/g" ./src-tauri/tauri.bundle.windows.nsis.template
|
||||||
|
|
||||||
if [ "${{ inputs.channel }}" != "stable" ]; then
|
if [ "${{ inputs.channel }}" != "stable" ]; then
|
||||||
jq '.plugins.updater.endpoints = ["https://delta.jan.ai/${{ inputs.channel }}/latest.json"]' ./src-tauri/tauri.conf.json > /tmp/tauri.conf.json
|
jq '.plugins.updater.endpoints = ["https://delta.jan.ai/${{ inputs.channel }}/latest.json"]' ./src-tauri/tauri.conf.json > /tmp/tauri.conf.json
|
||||||
mv /tmp/tauri.conf.json ./src-tauri/tauri.conf.json
|
mv /tmp/tauri.conf.json ./src-tauri/tauri.conf.json
|
||||||
@ -103,7 +135,14 @@ jobs:
|
|||||||
chmod +x .github/scripts/rename-workspace.sh
|
chmod +x .github/scripts/rename-workspace.sh
|
||||||
.github/scripts/rename-workspace.sh ./package.json ${{ inputs.channel }}
|
.github/scripts/rename-workspace.sh ./package.json ${{ inputs.channel }}
|
||||||
cat ./package.json
|
cat ./package.json
|
||||||
|
sed -i "s/jan_productname/Jan-${{ inputs.channel }}/g" ./src-tauri/tauri.bundle.windows.nsis.template
|
||||||
|
sed -i "s/jan_mainbinaryname/jan-${{ inputs.channel }}/g" ./src-tauri/tauri.bundle.windows.nsis.template
|
||||||
|
else
|
||||||
|
sed -i "s/jan_productname/Jan/g" ./src-tauri/tauri.bundle.windows.nsis.template
|
||||||
|
sed -i "s/jan_mainbinaryname/jan/g" ./src-tauri/tauri.bundle.windows.nsis.template
|
||||||
fi
|
fi
|
||||||
|
echo "---------nsis.template---------"
|
||||||
|
cat ./src-tauri/tauri.bundle.windows.nsis.template
|
||||||
- name: Build app
|
- name: Build app
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@ -98,9 +98,15 @@ jobs:
|
|||||||
# Update tauri.conf.json
|
# Update tauri.conf.json
|
||||||
jq --arg version "${{ inputs.new_version }}" '.version = $version | .bundle.createUpdaterArtifacts = true' ./src-tauri/tauri.conf.json > /tmp/tauri.conf.json
|
jq --arg version "${{ inputs.new_version }}" '.version = $version | .bundle.createUpdaterArtifacts = true' ./src-tauri/tauri.conf.json > /tmp/tauri.conf.json
|
||||||
mv /tmp/tauri.conf.json ./src-tauri/tauri.conf.json
|
mv /tmp/tauri.conf.json ./src-tauri/tauri.conf.json
|
||||||
|
jq '.bundle.windows.nsis.template = "tauri.bundle.windows.nsis.template"' ./src-tauri/tauri.windows.conf.json > /tmp/tauri.windows.conf.json
|
||||||
|
mv /tmp/tauri.windows.conf.json ./src-tauri/tauri.windows.conf.json
|
||||||
jq --arg version "${{ inputs.new_version }}" '.version = $version' web-app/package.json > /tmp/package.json
|
jq --arg version "${{ inputs.new_version }}" '.version = $version' web-app/package.json > /tmp/package.json
|
||||||
mv /tmp/package.json web-app/package.json
|
mv /tmp/package.json web-app/package.json
|
||||||
|
|
||||||
|
# Add sign commands to tauri.windows.conf.json
|
||||||
|
jq '.bundle.windows.signCommand = "powershell -ExecutionPolicy Bypass -File ./sign.ps1 %1"' ./src-tauri/tauri.windows.conf.json > /tmp/tauri.windows.conf.json
|
||||||
|
mv /tmp/tauri.windows.conf.json ./src-tauri/tauri.windows.conf.json
|
||||||
|
|
||||||
# Update tauri plugin versions
|
# Update tauri plugin versions
|
||||||
|
|
||||||
jq --arg version "${{ inputs.new_version }}" '.version = $version' ./src-tauri/plugins/tauri-plugin-hardware/package.json > /tmp/package.json
|
jq --arg version "${{ inputs.new_version }}" '.version = $version' ./src-tauri/plugins/tauri-plugin-hardware/package.json > /tmp/package.json
|
||||||
@ -127,9 +133,35 @@ jobs:
|
|||||||
echo "---------./src-tauri/Cargo.toml---------"
|
echo "---------./src-tauri/Cargo.toml---------"
|
||||||
cat ./src-tauri/Cargo.toml
|
cat ./src-tauri/Cargo.toml
|
||||||
|
|
||||||
# Add sign commands to tauri.windows.conf.json
|
generate_build_version() {
|
||||||
jq '.bundle.windows.signCommand = "powershell -ExecutionPolicy Bypass -File ./sign.ps1 %1"' ./src-tauri/tauri.windows.conf.json > /tmp/tauri.windows.conf.json
|
### Examble
|
||||||
mv /tmp/tauri.windows.conf.json ./src-tauri/tauri.windows.conf.json
|
### input 0.5.6 output will be 0.5.6 and 0.5.6.0
|
||||||
|
### input 0.5.6-rc2-beta output will be 0.5.6 and 0.5.6.2
|
||||||
|
### input 0.5.6-1213 output will be 0.5.6 and and 0.5.6.1213
|
||||||
|
local new_version="$1"
|
||||||
|
local base_version
|
||||||
|
local t_value
|
||||||
|
# Check if it has a "-"
|
||||||
|
if [[ "$new_version" == *-* ]]; then
|
||||||
|
base_version="${new_version%%-*}" # part before -
|
||||||
|
suffix="${new_version#*-}" # part after -
|
||||||
|
# Check if it is rcX-beta
|
||||||
|
if [[ "$suffix" =~ ^rc([0-9]+)-beta$ ]]; then
|
||||||
|
t_value="${BASH_REMATCH[1]}"
|
||||||
|
else
|
||||||
|
t_value="$suffix"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
base_version="$new_version"
|
||||||
|
t_value="0"
|
||||||
|
fi
|
||||||
|
# Export two values
|
||||||
|
new_base_version="$base_version"
|
||||||
|
new_build_version="${base_version}.${t_value}"
|
||||||
|
}
|
||||||
|
generate_build_version ${{ inputs.new_version }}
|
||||||
|
sed -i "s/jan_version/$new_base_version/g" ./src-tauri/tauri.bundle.windows.nsis.template
|
||||||
|
sed -i "s/jan_build/$new_build_version/g" ./src-tauri/tauri.bundle.windows.nsis.template
|
||||||
|
|
||||||
echo "---------tauri.windows.conf.json---------"
|
echo "---------tauri.windows.conf.json---------"
|
||||||
cat ./src-tauri/tauri.windows.conf.json
|
cat ./src-tauri/tauri.windows.conf.json
|
||||||
@ -163,7 +195,14 @@ jobs:
|
|||||||
chmod +x .github/scripts/rename-workspace.sh
|
chmod +x .github/scripts/rename-workspace.sh
|
||||||
.github/scripts/rename-workspace.sh ./package.json ${{ inputs.channel }}
|
.github/scripts/rename-workspace.sh ./package.json ${{ inputs.channel }}
|
||||||
cat ./package.json
|
cat ./package.json
|
||||||
|
sed -i "s/jan_productname/Jan-${{ inputs.channel }}/g" ./src-tauri/tauri.bundle.windows.nsis.template
|
||||||
|
sed -i "s/jan_mainbinaryname/jan-${{ inputs.channel }}/g" ./src-tauri/tauri.bundle.windows.nsis.template
|
||||||
|
else
|
||||||
|
sed -i "s/jan_productname/Jan/g" ./src-tauri/tauri.bundle.windows.nsis.template
|
||||||
|
sed -i "s/jan_mainbinaryname/jan/g" ./src-tauri/tauri.bundle.windows.nsis.template
|
||||||
fi
|
fi
|
||||||
|
echo "---------nsis.template---------"
|
||||||
|
cat ./src-tauri/tauri.bundle.windows.nsis.template
|
||||||
|
|
||||||
- name: Install AzureSignTool
|
- name: Install AzureSignTool
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@ -35,8 +35,7 @@
|
|||||||
"copy:assets:mobile": "cpx \"pre-install/*.tgz\" \"src-tauri/resources/pre-install/\" && cpx \"LICENSE\" \"src-tauri/resources/\"",
|
"copy:assets:mobile": "cpx \"pre-install/*.tgz\" \"src-tauri/resources/pre-install/\" && cpx \"LICENSE\" \"src-tauri/resources/\"",
|
||||||
"download:lib": "node ./scripts/download-lib.mjs",
|
"download:lib": "node ./scripts/download-lib.mjs",
|
||||||
"download:bin": "node ./scripts/download-bin.mjs",
|
"download:bin": "node ./scripts/download-bin.mjs",
|
||||||
"download:windows-installer": "node ./scripts/download-win-installer-deps.mjs",
|
"build:tauri:win32": "yarn download:bin && yarn tauri build",
|
||||||
"build:tauri:win32": "yarn download:bin && yarn download:windows-installer && yarn tauri build",
|
|
||||||
"build:tauri:linux": "yarn download:bin && NO_STRIP=1 ./src-tauri/build-utils/shim-linuxdeploy.sh yarn tauri build && ./src-tauri/build-utils/buildAppImage.sh",
|
"build:tauri:linux": "yarn download:bin && NO_STRIP=1 ./src-tauri/build-utils/shim-linuxdeploy.sh yarn tauri build && ./src-tauri/build-utils/buildAppImage.sh",
|
||||||
"build:tauri:darwin": "yarn download:bin && yarn tauri build --target universal-apple-darwin",
|
"build:tauri:darwin": "yarn download:bin && yarn tauri build --target universal-apple-darwin",
|
||||||
"build:tauri": "yarn build:icon && yarn copy:assets:tauri && run-script-os",
|
"build:tauri": "yarn build:icon && yarn copy:assets:tauri && run-script-os",
|
||||||
|
|||||||
@ -1,83 +0,0 @@
|
|||||||
console.log('Downloading Windows installer dependencies...')
|
|
||||||
// scripts/download-win-installer-deps.mjs
|
|
||||||
import https from 'https'
|
|
||||||
import fs, { mkdirSync } from 'fs'
|
|
||||||
import os from 'os'
|
|
||||||
import path from 'path'
|
|
||||||
import { copySync } from 'cpx'
|
|
||||||
|
|
||||||
function download(url, dest) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
console.log(`Downloading ${url} to ${dest}`)
|
|
||||||
const file = fs.createWriteStream(dest)
|
|
||||||
https
|
|
||||||
.get(url, (response) => {
|
|
||||||
console.log(`Response status code: ${response.statusCode}`)
|
|
||||||
if (
|
|
||||||
response.statusCode >= 300 &&
|
|
||||||
response.statusCode < 400 &&
|
|
||||||
response.headers.location
|
|
||||||
) {
|
|
||||||
// Handle redirect
|
|
||||||
const redirectURL = response.headers.location
|
|
||||||
console.log(`Redirecting to ${redirectURL}`)
|
|
||||||
download(redirectURL, dest).then(resolve, reject) // Recursive call
|
|
||||||
return
|
|
||||||
} else if (response.statusCode !== 200) {
|
|
||||||
reject(`Failed to get '${url}' (${response.statusCode})`)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
response.pipe(file)
|
|
||||||
file.on('finish', () => {
|
|
||||||
file.close(resolve)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.on('error', (err) => {
|
|
||||||
fs.unlink(dest, () => reject(err.message))
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async function main() {
|
|
||||||
console.log('Starting Windows installer dependencies download')
|
|
||||||
const platform = os.platform() // 'darwin', 'linux', 'win32'
|
|
||||||
const arch = os.arch() // 'x64', 'arm64', etc.
|
|
||||||
|
|
||||||
if (arch != 'x64') return
|
|
||||||
|
|
||||||
|
|
||||||
const libDir = 'src-tauri/resources/lib'
|
|
||||||
const tempDir = 'scripts/dist'
|
|
||||||
|
|
||||||
try {
|
|
||||||
mkdirSync('scripts/dist')
|
|
||||||
} catch (err) {
|
|
||||||
// Expect EEXIST error if the directory already exists
|
|
||||||
}
|
|
||||||
|
|
||||||
// Download VC++ Redistributable 17
|
|
||||||
if (platform == 'win32') {
|
|
||||||
const vcFilename = 'vc_redist.x64.exe'
|
|
||||||
const vcUrl = 'https://aka.ms/vs/17/release/vc_redist.x64.exe'
|
|
||||||
|
|
||||||
console.log(`Downloading VC++ Redistributable...`)
|
|
||||||
const vcSavePath = path.join(tempDir, vcFilename)
|
|
||||||
if (!fs.existsSync(vcSavePath)) {
|
|
||||||
await download(vcUrl, vcSavePath)
|
|
||||||
}
|
|
||||||
|
|
||||||
// copy to tauri resources
|
|
||||||
try {
|
|
||||||
copySync(vcSavePath, libDir)
|
|
||||||
} catch (err) {
|
|
||||||
// Expect EEXIST error
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('Windows installer dependencies downloads completed.')
|
|
||||||
}
|
|
||||||
|
|
||||||
main().catch((err) => {
|
|
||||||
console.error('Error:', err)
|
|
||||||
process.exit(1)
|
|
||||||
})
|
|
||||||
1007
src-tauri/tauri.bundle.windows.nsis.template
Normal file
1007
src-tauri/tauri.bundle.windows.nsis.template
Normal file
File diff suppressed because it is too large
Load Diff
@ -11,7 +11,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
"bundle": {
|
"bundle": {
|
||||||
"targets": ["nsis"],
|
"targets": ["nsis", "msi"],
|
||||||
"resources": [
|
"resources": [
|
||||||
"resources/pre-install/**/*",
|
"resources/pre-install/**/*",
|
||||||
"resources/lib/vc_redist.x64.exe",
|
"resources/lib/vc_redist.x64.exe",
|
||||||
@ -19,10 +19,6 @@
|
|||||||
],
|
],
|
||||||
"externalBin": ["resources/bin/bun", "resources/bin/uv"],
|
"externalBin": ["resources/bin/bun", "resources/bin/uv"],
|
||||||
"windows": {
|
"windows": {
|
||||||
"nsis": {
|
|
||||||
"installerHooks": "./windows/hooks.nsh",
|
|
||||||
"installerIcon": "icons/icon.ico"
|
|
||||||
},
|
|
||||||
"webviewInstallMode": {
|
"webviewInstallMode": {
|
||||||
"silent": true,
|
"silent": true,
|
||||||
"type": "downloadBootstrapper"
|
"type": "downloadBootstrapper"
|
||||||
|
|||||||
@ -1,65 +0,0 @@
|
|||||||
!macro NSIS_HOOK_POSTINSTALL
|
|
||||||
; Check if Visual C++ Redistributable is already installed
|
|
||||||
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64" "Version"
|
|
||||||
${If} $0 == ""
|
|
||||||
; Try alternative registry location
|
|
||||||
ReadRegStr $0 HKLM "SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x64" "Version"
|
|
||||||
${EndIf}
|
|
||||||
|
|
||||||
${If} $0 == ""
|
|
||||||
; VC++ Redistributable not found, need to install
|
|
||||||
DetailPrint "Visual C++ Redistributable not found, installing from bundled file..."
|
|
||||||
|
|
||||||
; Install from bundled EXE if not installed
|
|
||||||
${If} ${FileExists} "$INSTDIR\resources\lib\vc_redist.x64.exe"
|
|
||||||
DetailPrint "Installing Visual C++ Redistributable..."
|
|
||||||
; Copy to TEMP folder and then execute installer
|
|
||||||
CopyFiles "$INSTDIR\resources\lib\vc_redist.x64.exe" "$TEMP\vc_redist.x64.exe"
|
|
||||||
ExecWait '"$TEMP\vc_redist.x64.exe" /quiet /norestart' $1
|
|
||||||
|
|
||||||
; Check whether installation process exited successfully (code 0) or not
|
|
||||||
${If} $1 == 0
|
|
||||||
DetailPrint "Visual C++ Redistributable installed successfully"
|
|
||||||
${ElseIf} $1 == 1638
|
|
||||||
DetailPrint "Visual C++ Redistributable already installed (newer version)"
|
|
||||||
${ElseIf} $1 == 3010
|
|
||||||
DetailPrint "Visual C++ Redistributable installed successfully (restart required)"
|
|
||||||
${Else}
|
|
||||||
DetailPrint "Visual C++ installation failed with exit code: $1"
|
|
||||||
${EndIf}
|
|
||||||
|
|
||||||
; Clean up setup files from TEMP and your installed app
|
|
||||||
Delete "$TEMP\vc_redist.x64.exe"
|
|
||||||
Delete "$INSTDIR\resources\lib\vc_redist.x64.exe"
|
|
||||||
${Else}
|
|
||||||
DetailPrint "Visual C++ Redistributable not found at expected location: $INSTDIR\resources\lib\vc_redist.x64.exe"
|
|
||||||
${EndIf}
|
|
||||||
${Else}
|
|
||||||
DetailPrint "Visual C++ Redistributable already installed (version: $0)"
|
|
||||||
${EndIf}
|
|
||||||
|
|
||||||
; ---- Copy LICENSE to install root ----
|
|
||||||
${If} ${FileExists} "$INSTDIR\resources\LICENSE"
|
|
||||||
CopyFiles /SILENT "$INSTDIR\resources\LICENSE" "$INSTDIR\LICENSE"
|
|
||||||
DetailPrint "Copied LICENSE to install root"
|
|
||||||
|
|
||||||
; Optional cleanup - remove from resources folder
|
|
||||||
Delete "$INSTDIR\resources\LICENSE"
|
|
||||||
${Else}
|
|
||||||
DetailPrint "LICENSE not found at expected location: $INSTDIR\resources\LICENSE"
|
|
||||||
${EndIf}
|
|
||||||
|
|
||||||
; ---- Copy vulkan-1.dll to install root ----
|
|
||||||
${If} ${FileExists} "$INSTDIR\resources\lib\vulkan-1.dll"
|
|
||||||
CopyFiles /SILENT "$INSTDIR\resources\lib\vulkan-1.dll" "$INSTDIR\vulkan-1.dll"
|
|
||||||
DetailPrint "Copied vulkan-1.dll to install root"
|
|
||||||
|
|
||||||
; Optional cleanup - remove from resources folder
|
|
||||||
Delete "$INSTDIR\resources\lib\vulkan-1.dll"
|
|
||||||
|
|
||||||
; Only remove the lib directory if it's empty after removing both files
|
|
||||||
RMDir "$INSTDIR\resources\lib"
|
|
||||||
${Else}
|
|
||||||
DetailPrint "vulkan-1.dll not found at expected location: $INSTDIR\resources\lib\vulkan-1.dll"
|
|
||||||
${EndIf}
|
|
||||||
!macroend
|
|
||||||
Loading…
x
Reference in New Issue
Block a user