🎨 Refactoring action packaging logic

This commit is contained in:
Tw93
2023-08-28 18:59:32 +08:00
parent b512384427
commit 76ee3a185e
4 changed files with 17 additions and 21 deletions

View File

@@ -117,7 +117,7 @@ jobs:
- name: Build with pake-cli
run: |
node ./script/build_with_pake_cli.mjs
node ./script/build_with_pake_cli.js
env:
URL: ${{ inputs.url }}
NAME: ${{ inputs.name }}

View File

@@ -71,14 +71,14 @@ jobs:
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
- name: install dependencies (ubuntu only)
- name: Install dependencies (ubuntu only)
if: matrix.os == 'ubuntu-latest'
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev gnome-video-effects gnome-video-effects-extra
version: 1.1
- name: rust cache restore
- name: Rust cache restore
id: cache_store
uses: actions/cache/restore@v3
with:
@@ -98,7 +98,7 @@ jobs:
URL: ${{ inputs.url }}
run: |
npm install
node ./script/build_with_pake_cli.mjs
node ./script/build_with_pake_cli.js
- name: Build for Ubuntu
if: matrix.os == 'ubuntu-latest'
@@ -129,7 +129,7 @@ jobs:
run: |
git checkout -- src-tauri/Cargo.lock
- name: rust cache store
- name: Rust cache store
uses: actions/cache/save@v3
with:
path: |

View File

@@ -1,12 +1,12 @@
import pakeJson from '../src-tauri/pake.json' assert { type: 'json' };
import tauriJson from '../src-tauri/tauri.conf.json' assert { type: 'json' };
import windowsJson from '../src-tauri/tauri.windows.conf.json' assert { type: 'json' };
import macosJson from '../src-tauri/tauri.macos.conf.json' assert { type: 'json' };
import linuxJson from '../src-tauri/tauri.linux.conf.json' assert { type: 'json' };
import { writeFileSync, existsSync, copyFileSync } from 'fs';
import { writeFileSync, existsSync, copyFileSync, readFileSync } from 'fs';
import os from 'os';
const pakeJson = JSON.parse(readFileSync('../src-tauri/pake.json', 'utf-8'));
const tauriJson = JSON.parse(readFileSync('../src-tauri/tauri.conf.json', 'utf-8'));
const windowsJson = JSON.parse(readFileSync('../src-tauri/tauri.windows.conf.json', 'utf-8'));
const macosJson = JSON.parse(readFileSync('../src-tauri/tauri.macos.conf.json', 'utf-8'));
const linuxJson = JSON.parse(readFileSync('../src-tauri/tauri.linux.conf.json', 'utf-8'));
const desktopEntry = `[Desktop Entry]
Encoding=UTF-8
Categories=Office
@@ -55,8 +55,7 @@ const variables = {
hdIconPath: `src-tauri/png/${process.env.NAME}_256.ico`,
hdDefaultPath: 'src-tauri/png/icon_256.ico',
icon: [`png/${process.env.NAME}_256.ico`, `png/${process.env.NAME}_32.ico`],
resources: [`png/${process.env.NAME}_32.ico`]
resources: [`png/${process.env.NAME}_32.ico`],
},
};
@@ -82,12 +81,11 @@ switch (os.platform()) {
case 'win32':
platformConfig = windowsJson;
platformVariables = variables.windows;
updateResources()
updateResources();
updateIconFile(platformVariables.hdIconPath, platformVariables.hdDefaultPath);
break;
}
updateIconFile(platformVariables.iconPath, platformVariables.defaultIconPath);
updatePlatformConfig(platformConfig, platformVariables);
@@ -149,7 +147,6 @@ function updatePlatformConfig(platformConfig, platformVariables) {
}
function save() {
writeFileSync(variables.pakeConfigPath, JSON.stringify(pakeJson, null, 2));
writeFileSync(variables.tauriConfigPath, JSON.stringify(tauriJson, null, 2));
@@ -159,16 +156,15 @@ function save() {
writeFileSync(variables.macos.configFilePath, JSON.stringify(macosJson, null, 2));
writeFileSync(variables.windows.configFilePath, JSON.stringify(windowsJson, null, 2));
}
function updateDesktopEntry() {
linuxJson.tauri.bundle.deb.files = {};
linuxJson.tauri.bundle.deb.files[variables.linux.desktopEntryConfig.configKey] =
variables.linux.desktopEntryConfig.configValue;
variables.linux.desktopEntryConfig.configValue;
writeFileSync(variables.linux.desktopEntryPath, variables.linux.desktopEntry);
}
function updateResources(){
function updateResources() {
windowsJson.tauri.bundle.resources = variables.windows.resources;
}
}