Skip to content

Commit c46e13b

Browse files
authored
Merge pull request #6545 from menloresearch/chore/standardize-build-windows
chore: use default nsis template
2 parents b322c76 + 8ba0342 commit c46e13b

File tree

6 files changed

+109
-1096
lines changed

6 files changed

+109
-1096
lines changed

.github/workflows/template-tauri-build-windows-x64-external.yml

Lines changed: 14 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ jobs:
4949
# Update tauri.conf.json
5050
jq --arg version "${{ inputs.new_version }}" '.version = $version | .bundle.createUpdaterArtifacts = false' ./src-tauri/tauri.conf.json > /tmp/tauri.conf.json
5151
mv /tmp/tauri.conf.json ./src-tauri/tauri.conf.json
52-
jq '.bundle.windows.nsis.template = "tauri.bundle.windows.nsis.template"' ./src-tauri/tauri.windows.conf.json > /tmp/tauri.windows.conf.json
53-
mv /tmp/tauri.windows.conf.json ./src-tauri/tauri.windows.conf.json
5452
jq '.bundle.windows.signCommand = "echo External build - skipping signature: %1"' ./src-tauri/tauri.windows.conf.json > /tmp/tauri.windows.conf.json
5553
mv /tmp/tauri.windows.conf.json ./src-tauri/tauri.windows.conf.json
5654
jq --arg version "${{ inputs.new_version }}" '.version = $version' web-app/package.json > /tmp/package.json
@@ -59,58 +57,30 @@ jobs:
5957
ctoml ./src-tauri/Cargo.toml package.version "${{ inputs.new_version }}"
6058
echo "---------Cargo.toml---------"
6159
cat ./src-tauri/Cargo.toml
62-
63-
generate_build_version() {
64-
### Examble
65-
### input 0.5.6 output will be 0.5.6 and 0.5.6.0
66-
### input 0.5.6-rc2-beta output will be 0.5.6 and 0.5.6.2
67-
### input 0.5.6-1213 output will be 0.5.6 and and 0.5.6.1213
68-
local new_version="$1"
69-
local base_version
70-
local t_value
71-
72-
# Check if it has a "-"
73-
if [[ "$new_version" == *-* ]]; then
74-
base_version="${new_version%%-*}" # part before -
75-
suffix="${new_version#*-}" # part after -
76-
77-
# Check if it is rcX-beta
78-
if [[ "$suffix" =~ ^rc([0-9]+)-beta$ ]]; then
79-
t_value="${BASH_REMATCH[1]}"
80-
else
81-
t_value="$suffix"
82-
fi
83-
else
84-
base_version="$new_version"
85-
t_value="0"
86-
fi
87-
88-
# Export two values
89-
new_base_version="$base_version"
90-
new_build_version="${base_version}.${t_value}"
91-
}
92-
generate_build_version ${{ inputs.new_version }}
93-
sed -i "s/jan_version/$new_base_version/g" ./src-tauri/tauri.bundle.windows.nsis.template
94-
sed -i "s/jan_build/$new_build_version/g" ./src-tauri/tauri.bundle.windows.nsis.template
95-
9660
if [ "${{ inputs.channel }}" != "stable" ]; then
9761
jq '.plugins.updater.endpoints = ["https://delta.jan.ai/${{ inputs.channel }}/latest.json"]' ./src-tauri/tauri.conf.json > /tmp/tauri.conf.json
9862
mv /tmp/tauri.conf.json ./src-tauri/tauri.conf.json
63+
64+
# Update product name
65+
jq --arg name "Jan-${{ inputs.channel }}" '.productName = $name' ./src-tauri/tauri.conf.json > /tmp/tauri.conf.json
66+
mv /tmp/tauri.conf.json ./src-tauri/tauri.conf.json
67+
9968
chmod +x .github/scripts/rename-tauri-app.sh
10069
.github/scripts/rename-tauri-app.sh ./src-tauri/tauri.conf.json ${{ inputs.channel }}
70+
71+
echo "---------tauri.conf.json---------"
72+
cat ./src-tauri/tauri.conf.json
73+
74+
# Update Cargo.toml
10175
ctoml ./src-tauri/Cargo.toml package.name "Jan-${{ inputs.channel }}"
10276
ctoml ./src-tauri/Cargo.toml dependencies.tauri.features[] "devtools"
77+
echo "------------------"
78+
cat ./src-tauri/Cargo.toml
79+
10380
chmod +x .github/scripts/rename-workspace.sh
10481
.github/scripts/rename-workspace.sh ./package.json ${{ inputs.channel }}
105-
sed -i "s/jan_productname/Jan-${{ inputs.channel }}/g" ./src-tauri/tauri.bundle.windows.nsis.template
106-
sed -i "s/jan_mainbinaryname/jan-${{ inputs.channel }}/g" ./src-tauri/tauri.bundle.windows.nsis.template
107-
else
108-
sed -i "s/jan_productname/Jan/g" ./src-tauri/tauri.bundle.windows.nsis.template
109-
sed -i "s/jan_mainbinaryname/jan/g" ./src-tauri/tauri.bundle.windows.nsis.template
82+
cat ./package.json
11083
fi
111-
echo "---------nsis.template---------"
112-
cat ./src-tauri/tauri.bundle.windows.nsis.template
113-
11484
- name: Build app
11585
shell: bash
11686
run: |

.github/workflows/template-tauri-build-windows-x64.yml

Lines changed: 12 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -95,56 +95,33 @@ jobs:
9595
# Update tauri.conf.json
9696
jq --arg version "${{ inputs.new_version }}" '.version = $version | .bundle.createUpdaterArtifacts = true' ./src-tauri/tauri.conf.json > /tmp/tauri.conf.json
9797
mv /tmp/tauri.conf.json ./src-tauri/tauri.conf.json
98-
jq '.bundle.windows.nsis.template = "tauri.bundle.windows.nsis.template"' ./src-tauri/tauri.windows.conf.json > /tmp/tauri.windows.conf.json
99-
mv /tmp/tauri.windows.conf.json ./src-tauri/tauri.windows.conf.json
10098
jq --arg version "${{ inputs.new_version }}" '.version = $version' web-app/package.json > /tmp/package.json
10199
mv /tmp/package.json web-app/package.json
102-
100+
103101
ctoml ./src-tauri/Cargo.toml package.version "${{ inputs.new_version }}"
104102
echo "---------Cargo.toml---------"
105103
cat ./src-tauri/Cargo.toml
106104
107-
generate_build_version() {
108-
### Examble
109-
### input 0.5.6 output will be 0.5.6 and 0.5.6.0
110-
### input 0.5.6-rc2-beta output will be 0.5.6 and 0.5.6.2
111-
### input 0.5.6-1213 output will be 0.5.6 and and 0.5.6.1213
112-
local new_version="$1"
113-
local base_version
114-
local t_value
115-
116-
# Check if it has a "-"
117-
if [[ "$new_version" == *-* ]]; then
118-
base_version="${new_version%%-*}" # part before -
119-
suffix="${new_version#*-}" # part after -
120-
121-
# Check if it is rcX-beta
122-
if [[ "$suffix" =~ ^rc([0-9]+)-beta$ ]]; then
123-
t_value="${BASH_REMATCH[1]}"
124-
else
125-
t_value="$suffix"
126-
fi
127-
else
128-
base_version="$new_version"
129-
t_value="0"
130-
fi
131-
132-
# Export two values
133-
new_base_version="$base_version"
134-
new_build_version="${base_version}.${t_value}"
135-
}
136-
generate_build_version ${{ inputs.new_version }}
137-
sed -i "s/jan_version/$new_base_version/g" ./src-tauri/tauri.bundle.windows.nsis.template
138-
sed -i "s/jan_build/$new_build_version/g" ./src-tauri/tauri.bundle.windows.nsis.template
105+
# Add sign commands to tauri.windows.conf.json
106+
jq '.bundle.windows.signCommand = "powershell -ExecutionPolicy Bypass -File ./sign.ps1 %1"' ./src-tauri/tauri.windows.conf.json > /tmp/tauri.windows.conf.json
107+
mv /tmp/tauri.windows.conf.json ./src-tauri/tauri.windows.conf.json
108+
109+
echo "---------tauri.windows.conf.json---------"
110+
cat ./src-tauri/tauri.windows.conf.json
139111
140112
# Temporarily enable devtool on prod build
141113
ctoml ./src-tauri/Cargo.toml dependencies.tauri.features[] "devtools"
142114
cat ./src-tauri/Cargo.toml
143115
144116
# Change app name for beta and nightly builds
145117
if [ "${{ inputs.channel }}" != "stable" ]; then
118+
# Update updater endpoint
146119
jq '.plugins.updater.endpoints = ["https://delta.jan.ai/${{ inputs.channel }}/latest.json"]' ./src-tauri/tauri.conf.json > /tmp/tauri.conf.json
147120
mv /tmp/tauri.conf.json ./src-tauri/tauri.conf.json
121+
122+
# Update product name
123+
jq --arg name "Jan-${{ inputs.channel }}" '.productName = $name' ./src-tauri/tauri.conf.json > /tmp/tauri.conf.json
124+
mv /tmp/tauri.conf.json ./src-tauri/tauri.conf.json
148125
149126
chmod +x .github/scripts/rename-tauri-app.sh
150127
.github/scripts/rename-tauri-app.sh ./src-tauri/tauri.conf.json ${{ inputs.channel }}
@@ -161,15 +138,7 @@ jobs:
161138
chmod +x .github/scripts/rename-workspace.sh
162139
.github/scripts/rename-workspace.sh ./package.json ${{ inputs.channel }}
163140
cat ./package.json
164-
165-
sed -i "s/jan_productname/Jan-${{ inputs.channel }}/g" ./src-tauri/tauri.bundle.windows.nsis.template
166-
sed -i "s/jan_mainbinaryname/jan-${{ inputs.channel }}/g" ./src-tauri/tauri.bundle.windows.nsis.template
167-
else
168-
sed -i "s/jan_productname/Jan/g" ./src-tauri/tauri.bundle.windows.nsis.template
169-
sed -i "s/jan_mainbinaryname/jan/g" ./src-tauri/tauri.bundle.windows.nsis.template
170141
fi
171-
echo "---------nsis.template---------"
172-
cat ./src-tauri/tauri.bundle.windows.nsis.template
173142
174143
- name: Install AzureSignTool
175144
run: |

scripts/download-lib.mjs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,25 @@ async function main() {
7777
// Expect EEXIST error
7878
}
7979

80+
// Download VC++ Redistributable 17
81+
if (platform == 'win32') {
82+
const vcFilename = 'vc_redist.x64.exe'
83+
const vcUrl = 'https://aka.ms/vs/17/release/vc_redist.x64.exe'
84+
85+
console.log(`Downloading VC++ Redistributable...`)
86+
const vcSavePath = path.join(tempDir, vcFilename)
87+
if (!fs.existsSync(vcSavePath)) {
88+
await download(vcUrl, vcSavePath)
89+
}
90+
91+
// copy to tauri resources
92+
try {
93+
copySync(vcSavePath, libDir)
94+
} catch (err) {
95+
// Expect EEXIST error
96+
}
97+
}
98+
8099
console.log('Downloads completed.')
81100
}
82101

0 commit comments

Comments
 (0)