156 lines
6.9 KiB
YAML
156 lines
6.9 KiB
YAML
name: tauri-build-windows-x64-external
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
ref:
|
|
required: true
|
|
type: string
|
|
default: 'refs/heads/main'
|
|
new_version:
|
|
required: true
|
|
type: string
|
|
default: ''
|
|
channel:
|
|
required: true
|
|
type: string
|
|
default: 'nightly'
|
|
description: 'The channel to use for this job'
|
|
jobs:
|
|
build-windows-x64-external:
|
|
runs-on: windows-latest
|
|
steps:
|
|
- name: Getting the repo
|
|
uses: actions/checkout@v3
|
|
with:
|
|
ref: ${{ inputs.ref }}
|
|
|
|
- name: Replace Icons for Beta Build
|
|
if: inputs.channel != 'stable'
|
|
shell: bash
|
|
run: |
|
|
cp .github/scripts/icon-${{ inputs.channel }}.png src-tauri/icons/icon.png
|
|
|
|
- name: Installing node
|
|
uses: actions/setup-node@v1
|
|
with:
|
|
node-version: 20
|
|
|
|
- name: Install jq
|
|
uses: dcarbone/install-jq-action@v2.0.1
|
|
|
|
- name: Install ctoml
|
|
run: |
|
|
cargo install ctoml
|
|
|
|
- name: Update app version
|
|
shell: bash
|
|
run: |
|
|
echo "Version: ${{ inputs.new_version }}"
|
|
# Update 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
|
|
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
|
|
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
|
|
mv /tmp/package.json web-app/package.json
|
|
|
|
# Update tauri plugin versions
|
|
|
|
jq --arg version "${{ inputs.new_version }}" '.version = $version' ./src-tauri/plugins/tauri-plugin-hardware/package.json > /tmp/package.json
|
|
mv /tmp/package.json ./src-tauri/plugins/tauri-plugin-hardware/package.json
|
|
|
|
echo "---------./src-tauri/plugins/tauri-plugin-hardware/package.json---------"
|
|
cat ./src-tauri/plugins/tauri-plugin-hardware/package.json
|
|
|
|
jq --arg version "${{ inputs.new_version }}" '.version = $version' ./src-tauri/plugins/tauri-plugin-llamacpp/package.json > /tmp/package.json
|
|
mv /tmp/package.json ./src-tauri/plugins/tauri-plugin-llamacpp/package.json
|
|
|
|
echo "---------./src-tauri/plugins/tauri-plugin-llamacpp/package.json---------"
|
|
cat ./src-tauri/plugins/tauri-plugin-llamacpp/package.json
|
|
|
|
ctoml ./src-tauri/plugins/tauri-plugin-hardware/Cargo.toml package.version "${{ inputs.new_version }}"
|
|
echo "---------./src-tauri/plugins/tauri-plugin-hardware/Cargo.toml---------"
|
|
cat ./src-tauri/plugins/tauri-plugin-hardware/Cargo.toml
|
|
|
|
ctoml ./src-tauri/plugins/tauri-plugin-llamacpp/Cargo.toml package.version "${{ inputs.new_version }}"
|
|
echo "---------./src-tauri/plugins/tauri-plugin-llamacpp/Cargo.toml---------"
|
|
cat ./src-tauri/plugins/tauri-plugin-llamacpp/Cargo.toml
|
|
|
|
ctoml ./src-tauri/Cargo.toml package.version "${{ inputs.new_version }}"
|
|
echo "---------./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
|
|
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
|
|
|
|
# Update product name
|
|
jq --arg name "Jan-${{ inputs.channel }}" '.productName = $name' ./src-tauri/tauri.conf.json > /tmp/tauri.conf.json
|
|
mv /tmp/tauri.conf.json ./src-tauri/tauri.conf.json
|
|
|
|
chmod +x .github/scripts/rename-tauri-app.sh
|
|
.github/scripts/rename-tauri-app.sh ./src-tauri/tauri.conf.json ${{ inputs.channel }}
|
|
|
|
echo "---------tauri.conf.json---------"
|
|
cat ./src-tauri/tauri.conf.json
|
|
|
|
# Update Cargo.toml
|
|
ctoml ./src-tauri/Cargo.toml package.name "Jan-${{ inputs.channel }}"
|
|
ctoml ./src-tauri/Cargo.toml dependencies.tauri.features[] "devtools"
|
|
echo "------------------"
|
|
cat ./src-tauri/Cargo.toml
|
|
|
|
chmod +x .github/scripts/rename-workspace.sh
|
|
.github/scripts/rename-workspace.sh ./package.json ${{ inputs.channel }}
|
|
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
|
|
echo "---------nsis.template---------"
|
|
cat ./src-tauri/tauri.bundle.windows.nsis.template
|
|
- name: Build app
|
|
shell: bash
|
|
run: |
|
|
make build
|
|
|
|
- name: Upload Artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: jan-windows-${{ inputs.new_version }}
|
|
path: |
|
|
./src-tauri/target/release/bundle/nsis/*.exe |