From 4cca20a21f1876c35a93e5d2afc66576bf42b25c Mon Sep 17 00:00:00 2001 From: luoluo <1425735414@qq.com> Date: Wed, 3 Jul 2024 16:58:38 +0800 Subject: [PATCH] =?UTF-8?q?cib=E6=89=93=E5=8C=85mac=E5=92=8CLinux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/yakit-ci.yml | 59 ++++++++++++++++++++++--- buildHooks/before_pack.js | 80 ++++++++++++++++++++++++++++++++++ electron-builder.yaml | 51 +++++++++++----------- 3 files changed, 160 insertions(+), 30 deletions(-) create mode 100644 buildHooks/before_pack.js diff --git a/.github/workflows/yakit-ci.yml b/.github/workflows/yakit-ci.yml index d8e901cb5c..486416eca4 100644 --- a/.github/workflows/yakit-ci.yml +++ b/.github/workflows/yakit-ci.yml @@ -29,9 +29,19 @@ jobs: - name: "Download Yak Engine via wget(MacOS)" id: download-darwin-engine run: wget -O bins/yak_darwin_amd64 https://yaklang.oss-accelerate.aliyuncs.com/yak/latest/yak_darwin_amd64 && zip ./bins/yak_darwin_amd64.zip ./bins/yak_darwin_amd64 && rm ./bins/yak_darwin_amd64 + + - name: "Download Yak Engine via wget(MacOS-arm64)" + id: download-darwin-engine-arm64 + run: wget -O bins/yak_darwin_arm64 https://yaklang.oss-accelerate.aliyuncs.com/yak/latest/yak_darwin_arm64 && zip ./bins/yak_darwin_arm64.zip ./bins/yak_darwin_arm64 && rm ./bins/yak_darwin_arm64 + - name: "Download Yak Engine via wget(Linux)" id: download-linux-engine run: wget -O bins/yak_linux_amd64 https://yaklang.oss-accelerate.aliyuncs.com/yak/latest/yak_linux_amd64 && zip ./bins/yak_linux_amd64.zip ./bins/yak_linux_amd64 && rm ./bins/yak_linux_amd64 + + - name: "Download Yak Engine via wget(Linux-arm64)" + id: download-linux-engine-arm64 + run: wget -O bins/yak_linux_arm64 https://yaklang.oss-accelerate.aliyuncs.com/yak/latest/yak_linux_arm64 && zip ./bins/yak_linux_arm64.zip ./bins/yak_linux_arm64 && rm ./bins/yak_linux_arm64 + - name: "Download Yak Engine via wget(Windows)" id: download-windows-engine run: wget -O bins/yak_windows_amd64.exe https://yaklang.oss-accelerate.aliyuncs.com/yak/latest/yak_windows_amd64.exe && zip ./bins/yak_windows_amd64.zip ./bins/yak_windows_amd64.exe && rm ./bins/yak_windows_amd64.exe @@ -141,13 +151,21 @@ jobs: # Yakit-1.0.3-beta24-win32-x64.exe name: Yakit-${{ steps.extract_version.outputs.version }}-darwin-x64.dmg path: ./release/Yakit-${{ steps.extract_version.outputs.version }}-darwin-x64.dmg - - name: Upload Yakit(Community) Artifacts Linux + - name: Upload Yakit(Community) Artifacts Linux(amd64) uses: actions/upload-artifact@v2 if: ${{ startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/ci/community-') }} with: # Yakit-1.0.3-beta24-win32-x64.exe name: Yakit-${{ steps.extract_version.outputs.version }}-linux-amd64.AppImage path: ./release/Yakit-${{ steps.extract_version.outputs.version }}-linux-amd64.AppImage + + - name: Upload Yakit(Community) Artifacts Linux(arm64) + uses: actions/upload-artifact@v2 + if: ${{ startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/ci/community-') }} + with: + name: Yakit-${{ steps.extract_version.outputs.version }}-linux-arm64.AppImage + path: ./release/Yakit-${{ steps.extract_version.outputs.version }}-linux-arm64.AppImage + # start Enterprise Edition - name: Upload Yakit(Enterprise) Artifacts Windows uses: actions/upload-artifact@v2 @@ -177,7 +195,13 @@ jobs: # Yakit-1.0.3-beta24-win32-x64.exe name: EnpriTrace-${{ steps.extract_version.outputs.version }}-linux-amd64.AppImage path: ./release/EnpriTrace-${{ steps.extract_version.outputs.version }}-linux-amd64.AppImage - + - name: Upload Yakit(Enterprise) Artifacts Linux(arm64) + uses: actions/upload-artifact@v2 + if: ${{ startsWith(github.ref, 'refs/heads/ci/yakit-ee') }} + with: + # Yakit-1.0.3-beta24-win32-x64.exe + name: EnpriTrace-${{ steps.extract_version.outputs.version }}-linux-arm64.AppImage + path: ./release/EnpriTrace-${{ steps.extract_version.outputs.version }}-linux-arm64.AppImage # start Special Edition - name: Upload Yakit(Special) Artifacts Windows uses: actions/upload-artifact@v2 @@ -207,6 +231,13 @@ jobs: # Yakit-1.0.3-beta24-win32-x64.exe name: EnpriTraceAgent-${{ steps.extract_version.outputs.version }}-linux-amd64.AppImage path: ./release/EnpriTraceAgent-${{ steps.extract_version.outputs.version }}-linux-amd64.AppImage + - name: Upload Yakit(Special) Artifacts Linux(arm64) + uses: actions/upload-artifact@v2 + if: ${{ startsWith(github.ref, 'refs/heads/ci/yakit-se') }} + with: + # Yakit-1.0.3-beta24-win32-x64.exe + name: EnpriTraceAgent-${{ steps.extract_version.outputs.version }}-linux-arm64.AppImage + path: ./release/EnpriTraceAgent-${{ steps.extract_version.outputs.version }}-linux-arm64.AppImage publish_yakit_ee_to_oss: if: ${{ startsWith(github.ref, 'refs/heads/ci/yakit-ee') && !endsWith(github.ref, '/no-release') }} @@ -244,6 +275,10 @@ jobs: uses: actions/download-artifact@v2 with: name: EnpriTrace-${{ steps.extract_version.outputs.version }}-linux-amd64.AppImage + - name: Download Yakit (Linux arm64) + uses: actions/download-artifact@v2 + with: + name: EnpriTrace-${{ steps.extract_version.outputs.version }}-linux-arm64.AppImage - run: ls name: Ls Published Artifacts... @@ -263,6 +298,7 @@ jobs: Yakit-${{ steps.extract_version.outputs.version }}-darwin-x64.dmg:/yak/${{ steps.extract_version.outputs.version }}/EnpriTrace-${{ steps.extract_version.outputs.version }}-darwin-x64.dmg Yakit-${{ steps.extract_version.outputs.version }}-darwin-arm64.dmg:/yak/${{ steps.extract_version.outputs.version }}/EnpriTrace-${{ steps.extract_version.outputs.version }}-darwin-arm64.dmg Yakit-${{ steps.extract_version.outputs.version }}-linux-amd64.AppImage:/yak/${{ steps.extract_version.outputs.version }}/EnpriTrace-${{ steps.extract_version.outputs.version }}-linux-amd64.AppImage + Yakit-${{ steps.extract_version.outputs.version }}-linux-arm64.AppImage:/yak/${{ steps.extract_version.outputs.version }}/EnpriTrace-${{ steps.extract_version.outputs.version }}-linux-arm64.AppImage # special edition publish_yakit_se_to_oss: if: ${{ startsWith(github.ref, 'refs/heads/ci/yakit-se') && !endsWith(github.ref, '/no-release') }} @@ -349,7 +385,10 @@ jobs: uses: actions/download-artifact@v2 with: name: Yakit-${{ steps.fetchtag_release.outputs.value }}-linux-amd64.AppImage - + - name: Download Yakit (Linux arm64) + uses: actions/download-artifact@v2 + with: + name: Yakit-${{ steps.fetchtag_release.outputs.value }}-linux-arm64.AppImage - run: ls name: Ls Published Artifacts... @@ -409,7 +448,16 @@ jobs: asset_path: ./Yakit-${{ steps.fetchtag_release.outputs.value }}-linux-amd64.AppImage asset_name: Yakit-${{ steps.fetchtag_release.outputs.value }}-linux-amd64.AppImage asset_content_type: application/octet-stream - + - name: Upload Release Asset (Linux-arm64) + uses: actions/upload-release-asset@v1 + continue-on-error: true + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: ./Yakit-${{ steps.fetchtag_release.outputs.value }}-linux-arm64.AppImage + asset_name: Yakit-${{ steps.fetchtag_release.outputs.value }}-linux-arm64.AppImage + asset_content_type: application/octet-stream - name: Run run: ls # - name: Upload yak to oss Latest @@ -450,4 +498,5 @@ jobs: Yakit-${{ steps.fetchtag_release.outputs.value }}-windows-amd64.exe:/yak/${{ steps.fetchtag_release.outputs.value }}/Yakit-${{ steps.fetchtag_release.outputs.value }}-windows-amd64.exe Yakit-${{ steps.fetchtag_release.outputs.value }}-darwin-x64.dmg:/yak/${{ steps.fetchtag_release.outputs.value }}/Yakit-${{ steps.fetchtag_release.outputs.value }}-darwin-x64.dmg Yakit-${{ steps.fetchtag_release.outputs.value }}-darwin-arm64.dmg:/yak/${{ steps.fetchtag_release.outputs.value }}/Yakit-${{ steps.fetchtag_release.outputs.value }}-darwin-arm64.dmg - Yakit-${{ steps.fetchtag_release.outputs.value }}-linux-amd64.AppImage:/yak/${{ steps.fetchtag_release.outputs.value }}/Yakit-${{ steps.fetchtag_release.outputs.value }}-linux-amd64.AppImage \ No newline at end of file + Yakit-${{ steps.fetchtag_release.outputs.value }}-linux-amd64.AppImage:/yak/${{ steps.fetchtag_release.outputs.value }}/Yakit-${{ steps.fetchtag_release.outputs.value }}-linux-amd64.AppImage + Yakit-${{ steps.fetchtag_release.outputs.value }}-linux-arm64.AppImage:/yak/${{ steps.fetchtag_release.outputs.value }}/Yakit-${{ steps.fetchtag_release.outputs.value }}-linux-arm64.AppImage \ No newline at end of file diff --git a/buildHooks/before_pack.js b/buildHooks/before_pack.js new file mode 100644 index 0000000000..8ddb9dee74 --- /dev/null +++ b/buildHooks/before_pack.js @@ -0,0 +1,80 @@ +module.exports = async function (context) { + const archMap = { + 1: 'x64', + 3: 'arm64', + }; + const arch = archMap[context.arch]; + + /**linux */ + /** 1:x64 3:arm64 */ + const linuxConfig = context.electronPlatformName === 'linux' ? context.packager.config.linux : null; + if (linuxConfig) { + const linuxExtraFiles = [ + { + "from": "bins/flag.linux.txt", + "to": "bins/flag.linux.txt", + }, + ] + switch (arch) { + case 'arm64': + linuxConfig.artifactName = '${productName}-${version}-linux-arm64.${ext}'; + linuxConfig.extraFiles = [ + ...linuxExtraFiles, + { + "from": "bins/yak_linux_arm64.zip", + "to": "bins/yak.zip", + }, + ] + break; + case 'x64': + linuxConfig.artifactName = '${productName}-${version}-linux-amd64.${ext}'; + linuxConfig.extraFiles = [ + ...linuxExtraFiles, + { + "from": "bins/yak_linux_amd64.zip", + "to": "bins/yak.zip", + }, + ] + break; + + default: + break; + } + context.packager.config.linux = linuxConfig + } + /**mac */ + /** 1:x64 3:arm64 */ + const macConfig = context.electronPlatformName === 'darwin' ? context.packager.config.mac : null; + if (macConfig) { + const darwinExtraFiles = [ + { + "from": "bins/flag.darwin.txt", + "to": "bins/flag.darwin.txt", + }, + ] + switch (arch) { + case 'arm64': + macConfig.extraFiles = [ + ...darwinExtraFiles, + { + "from": "bins/yak_darwin_arm64.zip", + "to": "bins/yak.zip", + }, + ] + break; + case 'x64': + macConfig.extraFiles = [ + ...darwinExtraFiles, + { + "from": "bins/yak_darwin_amd64.zip", + "to": "bins/yak.zip", + }, + ] + break; + + default: + break; + } + context.packager.config.mac = macConfig + } +}; \ No newline at end of file diff --git a/electron-builder.yaml b/electron-builder.yaml index 24239f892e..a26878dc28 100644 --- a/electron-builder.yaml +++ b/electron-builder.yaml @@ -1,9 +1,7 @@ -appId: 'io.yaklang.yakit' -productName: 'Yakit' +appId: "io.yaklang.yakit" +productName: "Yakit" copyright: Copyright © 2024 yaklang.io - - extraFiles: - from: "bins/scripts/auto-install-cert.zip" to: "bins/scripts/auto-install-cert.zip" @@ -27,6 +25,8 @@ extraFiles: - "!*.db" - from: "LICENSE.md" to: "LICENSE.md" + - from: "report/template.zip" + to: "report/template.zip" directories: buildResources: resources @@ -42,13 +42,13 @@ publish: mac: artifactName: ${productName}-${version}-darwin-${arch}.${ext} - extraFiles: - - from: "bins/flag.darwin.txt" - to: "bins/flag.darwin.txt" - - from: "bins/yak_darwin_amd64.zip" - to: "bins/yak.zip" - - from: "report/template.zip" - to: "report/template.zip" + # extraFiles: + # - from: "bins/flag.darwin.txt" + # to: "bins/flag.darwin.txt" + # - from: bins/yak_darwin_${arch}.zip + # to: "bins/yak.zip" + # - from: "report/template.zip" + # to: "report/template.zip" target: - target: dmg arch: @@ -57,18 +57,19 @@ mac: icon: "app/assets/yakitlogo.icns" linux: - artifactName: ${productName}-${version}-linux-amd64.${ext} - extraFiles: - - from: "bins/flag.linux.txt" - to: "bins/flag.linux.txt" - - from: "bins/yak_linux_amd64.zip" - to: "bins/yak.zip" - - from: "report/template.zip" - to: "report/template.zip" + # artifactName: ${productName}-${version}-linux-${arch}.${ext} + # extraFiles: + # - from: "bins/flag.linux.txt" + # to: "bins/flag.linux.txt" + # - from: bins/yak_linux_${arch}.zip + # to: "bins/yak.zip" + # - from: "report/template.zip" + # to: "report/template.zip" target: - target: AppImage arch: - x64 + - arm64 icon: "app/assets/yakitlogo.icns" win: @@ -78,8 +79,6 @@ win: to: "bins/flag.windows.txt" - from: "bins/yak_windows_amd64.zip" to: "bins/yak.zip" - - from: "report/template.zip" - to: "report/template.zip" # requestedExecutionLevel: requireAdministrator target: - target: nsis @@ -89,18 +88,20 @@ win: nsis: - oneClick: false + oneClick: false perMachine: false deleteAppDataOnUninstall: true - allowToChangeInstallationDirectory: true - installerIcon: app/assets/yakitlogo.ico - uninstallerIcon: app/assets/yakitlogo.ico + allowToChangeInstallationDirectory: true + installerIcon: app/assets/yakitlogo.ico + uninstallerIcon: app/assets/yakitlogo.ico unicode: true include: build/yakit_build.nsh license: LICENSE.md warningsAsErrors: false createDesktopShortcut: false createStartMenuShortcut: true + +beforePack: "buildHooks/before_pack.js" #publish: # - provider: generic # url: https://update.electron-builder.com