From b5123844274aaa018c5c53d067ea3b745b1b309d Mon Sep 17 00:00:00 2001 From: Tw93 Date: Mon, 28 Aug 2023 18:48:56 +0800 Subject: [PATCH] :art: Refactoring action packaging logic --- .github/workflows/pake_build_next.yaml | 2 +- .github/workflows/pake_build_single_app.yaml | 42 ++++----- package.json | 1 - ...p_config.mjs => build_with_app_config.mjs} | 0 script/build_with_pake_cli.ps1 | 92 ------------------- 5 files changed, 20 insertions(+), 117 deletions(-) rename script/{app_config.mjs => build_with_app_config.mjs} (100%) delete mode 100644 script/build_with_pake_cli.ps1 diff --git a/.github/workflows/pake_build_next.yaml b/.github/workflows/pake_build_next.yaml index 72b0876..47c00fe 100644 --- a/.github/workflows/pake_build_next.yaml +++ b/.github/workflows/pake_build_next.yaml @@ -1,4 +1,4 @@ -name: Build Popular App +name: Build All Popular Apps on: push: tags: diff --git a/.github/workflows/pake_build_single_app.yaml b/.github/workflows/pake_build_single_app.yaml index be569a4..43b3443 100644 --- a/.github/workflows/pake_build_single_app.yaml +++ b/.github/workflows/pake_build_single_app.yaml @@ -3,43 +3,43 @@ on: workflow_dispatch: inputs: name: - description: "app name" + description: 'app name' required: true - default: "twitter" + default: 'twitter' title: - description: "app title" + description: 'app title' required: true - default: "Twitter" + default: 'Twitter' name_zh: - description: "app name in Chinese" + description: 'app name in Chinese' required: true - default: "推特" + default: '推特' url: - description: "app url" + description: 'app url' required: true - default: "https://twitter.com/" + default: 'https://twitter.com/' workflow_call: inputs: name: - description: "app name" + description: 'app name' type: string required: true - default: "twitter" + default: 'twitter' title: - description: "app title" + description: 'app title' required: true type: string - default: "Twitter" + default: 'Twitter' name_zh: - description: "app name in Chinese" + description: 'app name in Chinese' required: true type: string - default: "推特" + default: '推特' url: - description: "app url" + description: 'app url' required: true type: string - default: "https://twitter.com/" + default: 'https://twitter.com/' jobs: build_single_app: @@ -98,8 +98,7 @@ jobs: URL: ${{ inputs.url }} run: | npm install - npm run build:app:config - + node ./script/build_with_pake_cli.mjs - name: Build for Ubuntu if: matrix.os == 'ubuntu-latest' @@ -109,7 +108,6 @@ jobs: mv src-tauri/target/release/bundle/deb/*.deb output/linux/${{inputs.title}}_`arch`.deb mv src-tauri/target/release/bundle/appimage/*.AppImage output/linux/"${{inputs.title}}"_`arch`.AppImage - - name: Build for Macos if: matrix.os == 'macos-latest' run: | @@ -119,7 +117,6 @@ jobs: mkdir -p output/macos mv src-tauri/target/universal-apple-darwin/release/bundle/dmg/*.dmg output/macos/"${{inputs.title}}".dmg - - name: Build for Windows if: matrix.os == 'windows-latest' run: | @@ -143,12 +140,11 @@ jobs: src-tauri/target/ key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - name: Upload For Single Build uses: actions/upload-artifact@v3 if: startsWith(github.ref, 'refs/tags/') != true with: - path: "output/*/*.*" + path: 'output/*/*.*' - name: Upload For Release # arg info: https://github.com/ncipollo/release-action#release-action @@ -156,5 +152,5 @@ jobs: if: startsWith(github.ref, 'refs/tags/') == true with: allowUpdates: true - artifacts: "output/*/*.*" + artifacts: 'output/*/*.*' token: ${{ secrets.GITHUB_TOKEN }} diff --git a/package.json b/package.json index e7f2749..b7de62f 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,6 @@ "start": "npm run dev", "dev": "npm run tauri dev", "build": "npm run tauri build --release", - "build:app:config": "chmod +x ./script/app_config.mjs && node ./script/app_config.mjs", "build:debug": "npm run tauri build -- --debug", "build:mac": "npm run tauri build -- --target universal-apple-darwin", "analyze": "cd src-tauri && cargo bloat --release --crates", diff --git a/script/app_config.mjs b/script/build_with_app_config.mjs similarity index 100% rename from script/app_config.mjs rename to script/build_with_app_config.mjs diff --git a/script/build_with_pake_cli.ps1 b/script/build_with_pake_cli.ps1 deleted file mode 100644 index 42457a4..0000000 --- a/script/build_with_pake_cli.ps1 +++ /dev/null @@ -1,92 +0,0 @@ -Write-Host "Welcome to use Powershell" -Write-Host "`n=======================" -Write-Host "build for windows" -Write-Host "make ture powershell == 7.2.10" -Write-Host "powershell 7.2.10 download url: https://github.com/PowerShell/PowerShell/releases/tag/v7.2.10" -Write-Host "Powershell info in your localhost " -$PSVersionTable -Write-Host "`n=======================`n" - -Write-Host "`n=======================" -Write-Host "pake parameters is: " -Write-Host "url: " $env:URL -Write-Host "name: " $env:NAME -Write-Host "icon: " $env:ICON -Write-Host "height: " $env:HEIGHT -Write-Host "width: " $env:WIDTH -Write-Host "transparent: " $env:TRANSPARENT -Write-Host "resize: " $env:RESIZE -Write-Host "is multi arch? only for Mac: " $env:MULTI_ARCH -Write-Host "targets type? only for Linux: " $env:TARGETS -Write-Host "===========================`n" - - -Set-Location node_modules/pake-cli -# init params -${Params}="node cli.js $env:URL --name $env:NAME" - -# download icon -if ((($null -ne $env:ICON) -and ($env:ICON -ne ""))){ - if ($IsLinux) { - curl -L "$env:ICON" -o icon.png - ${Params}="${Params} --icon icon.png" - } elseif ($IsMacOS) { - curl -L "$env:ICON" -o icon.icns - ${Params}="${Params} --icon icon.icns" - } elseif ($IsWindows) { - curl -L "$env:ICON" -o icon.ico - ${Params}="${Params} --icon icon.ico" - } else { - Write-Host "it won't download icon, becase it can't detect you OS system!" - } -} - -# height && weight -${Params}="${Params} --height $env:HEIGHT --width $env:WIDTH" - -# transparent -if ("$env:TRANSPARENT" -eq "true") { - ${Params}="${Params} --transparent" -} - -# resize -if ("$env:FULLSCREEN" -eq "true" ) { - ${Params}="${Params} --resize" -} - -# multi-arch only for mac -if (($env:MULTI_ARCH -eq "true") -and ($IsMacOS)) { - rustup target add aarch64-apple-darwin - ${Params}="${Params} --multi-arch" -} - -# targets type, only for linux -if (($null -ne $env:TARGETS) -and ($env:TARGETS -ne "") -and ($IsLinux)) { - ${Params}="${Params} --targets $env:TARGETS" -} - -# add systemTray for Window / Linux default -if ($IsWindows) { - ${Params}="${Params} --show-system-tray" -} - -if ($IsLinux) { - ${Params}="${Params} --show-system-tray" -} - -# add menu for MacOS default -if ($IsMacOS) { - ${Params}="${Params} --show-menu" -} - -Write-Host "Pake parameters is: ${Params}" -Write-Host "compile...." -Invoke-Expression $Params - -# output -if (-not(Test-Path output)) { - New-Item -ItemType Directory -Path "output" -} -Move-Item -Path "$env:NAME.*" -Destination "output/" -Write-Host "Build Success" -Set-Location ../..