From 4e8316a6ee846547c88e2f9b84dbaf72e00ffbc3 Mon Sep 17 00:00:00 2001 From: Alice <53339016+AliceHincu@users.noreply.github.com> Date: Wed, 4 Sep 2024 14:11:17 +0300 Subject: [PATCH] Desktop: Seamless-Updates - generated latest-mac-arm64.yml (#10982) --- .github/workflows/build-macos-m1.yml | 11 +++++++- packages/app-desktop/afterAllArtifactBuild.js | 26 +++++++++++++++++++ .../app-desktop/artifactBuildCompleted.js | 25 ------------------ 3 files changed, 36 insertions(+), 26 deletions(-) delete mode 100644 packages/app-desktop/artifactBuildCompleted.js diff --git a/.github/workflows/build-macos-m1.yml b/.github/workflows/build-macos-m1.yml index 38c857a64..5bf21a656 100644 --- a/.github/workflows/build-macos-m1.yml +++ b/.github/workflows/build-macos-m1.yml @@ -44,6 +44,14 @@ jobs: with: python-version: '3.11' + - name: Set Publish Flag + run: | + if [[ $GIT_TAG_NAME = v* ]]; then + echo "PUBLISH_ENABLED=true" >> $GITHUB_ENV + else + echo "PUBLISH_ENABLED=false" >> $GITHUB_ENV + fi + - name: Build macOS M1 app env: APPLE_ASC_PROVIDER: ${{ secrets.APPLE_ASC_PROVIDER }} @@ -56,6 +64,7 @@ jobs: GH_REPO: ${{ github.repository }} IS_CONTINUOUS_INTEGRATION: 1 BUILD_SEQUENCIAL: 1 + PUBLISH_ENABLED: ${{ env.PUBLISH_ENABLED }} run: | export npm_config_arch=arm64 export npm_config_target_arch=arm64 @@ -67,7 +76,7 @@ jobs: npm pkg set 'build.mac.target[1].target'='zip' npm pkg set 'build.mac.target[1].arch[0]'='arm64' - if [[ $GIT_TAG_NAME = v* ]]; then + if [[ "$PUBLISH_ENABLED" == "true" ]]; then echo "Building and publishing desktop application..." PYTHON_PATH=$(which python) USE_HARD_LINKS=false yarn dist --mac --arm64 diff --git a/packages/app-desktop/afterAllArtifactBuild.js b/packages/app-desktop/afterAllArtifactBuild.js index 4f6fb670f..f686c23d6 100644 --- a/packages/app-desktop/afterAllArtifactBuild.js +++ b/packages/app-desktop/afterAllArtifactBuild.js @@ -31,8 +31,34 @@ const generateChecksumFile = () => { return [sha512FilePath]; }; +const renameLatestYmlFile = () => { + if (os.platform() === 'darwin' && process.arch === 'arm64') { + // latest-mac.yml is only generated when publishing. + if (process.env.PUBLISH_ENABLED === 'false') { + /* eslint-disable no-console */ + console.info(`Publishing not enabled - skipping renaming latest-mac.yml file for arm64 architecture. process.env.PUBLISH_ENABLED = ${process.env.PUBLISH_ENABLED}`); + return; + } + + /* eslint-disable no-console */ + console.info('Renaming latest-mac.yml file...'); + const latestMacFilePath = path.join(distPath, 'latest-mac.yml'); + const renamedMacFilePath = path.join(distPath, 'latest-mac-arm64.yml'); + + if (fs.existsSync(latestMacFilePath)) { + /* eslint-disable no-console */ + console.info('Renamed latest-mac.yml file to latest-mac-arm64.yml succesfully!'); + fs.renameSync(latestMacFilePath, renamedMacFilePath); + return [renamedMacFilePath]; + } else { + throw new Error('latest-mac.yml not found!'); + } + } +}; + const mainHook = () => { generateChecksumFile(); + renameLatestYmlFile(); }; exports.default = mainHook; diff --git a/packages/app-desktop/artifactBuildCompleted.js b/packages/app-desktop/artifactBuildCompleted.js deleted file mode 100644 index 03d23075a..000000000 --- a/packages/app-desktop/artifactBuildCompleted.js +++ /dev/null @@ -1,25 +0,0 @@ -const fs = require('fs'); -const path = require('path'); -const os = require('os'); -const distDirName = 'dist'; -const distPath = path.join(__dirname, distDirName); - -const renameLatestYmlFile = () => { - if (os.platform() === 'darwin' && process.arch === 'arm64') { - const latestMacFilePath = path.join(distPath, 'latest-mac.yml'); - const renamedMacFilePath = path.join(distPath, 'latest-mac-arm64.yml'); - - if (fs.existsSync(latestMacFilePath)) { - fs.renameSync(latestMacFilePath, renamedMacFilePath); - return [renamedMacFilePath]; - } else { - throw new Error('latest-mac.yml not found!'); - } - } -}; - -const mainHook = () => { - renameLatestYmlFile(); -}; - -exports.default = mainHook;