From a1cfa84919de01fadbee74d0c7f1cbc9fb7730cf Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Fri, 27 Aug 2021 11:28:00 -0400 Subject: [PATCH] chore: Create release folder for desktop builds --- package.json | 1 - ui/desktop/README.md | 1 + ui/desktop/electron-app/config/cli.js | 16 ++++++++++++-- ui/desktop/electron-app/config/desktop.js | 3 ++- .../electron-app/config/forge.config.js | 21 +++++++++--------- .../environments/ubuntu-focal64/Vagrantfile | 22 +++++++++++++++++-- ui/desktop/package.json | 2 +- 7 files changed, 48 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index 8f31d5302..a96317204 100755 --- a/package.json +++ b/package.json @@ -19,7 +19,6 @@ "build:ui:desktop:win": "docker-compose -f docker-compose-embedding.yml run build-desktop-production && yarn build:ui:desktop:app", "build:ui:desktop:production": "cd ui/desktop && yarn build:production", "build:ui:desktop:app": "cd ui/desktop && yarn build:desktop", - "build:ui:desktop:app:linux": "cd ui/desktop && yarn build:desktop:linux", "lint": "npm-run-all lint:*", "lint:addons-api": "cd addons/api && yarn lint", "lint:addons-auth": "cd addons/auth && yarn lint", diff --git a/ui/desktop/README.md b/ui/desktop/README.md index ef99c9b0d..860405c7f 100644 --- a/ui/desktop/README.md +++ b/ui/desktop/README.md @@ -76,6 +76,7 @@ These environment variables may be used to customized the build. | `APP_UPDATER_CURRENT_VERSION` | Version of client. | | `APP_UPDATER_LATEST_VERSION_TAG` | Next version for comparison with current version. | | `APP_UPDATER_LATEST_VERSION_LOCATION` | Location of app release to use for updating client. Can be a filepath or url. | +| `BUILD_DEBIAN` | Enable to build debian artifacts on MacOS. | | `BYPASS_CLI_SETUP` | Disable download and extraction of cli. For development use only. | ### Building for Production diff --git a/ui/desktop/electron-app/config/cli.js b/ui/desktop/electron-app/config/cli.js index 24f34e169..2cb9a4174 100644 --- a/ui/desktop/electron-app/config/cli.js +++ b/ui/desktop/electron-app/config/cli.js @@ -9,7 +9,6 @@ const artifactDestination = path.resolve(__dirname, '..', 'cli'); const downloadArtifact = (version) => { const archivePlatform = {}; - // TODO: Support all available build machines if (isMac()) { archivePlatform.name = 'darwin'; archivePlatform.arch = 'amd64'; @@ -20,11 +19,24 @@ const downloadArtifact = (version) => { archivePlatform.arch = 'amd64'; } - if (isLinux() || process.env.CLI_LINUX_DEBIAN_SUPPORT) { + if (isLinux()) { + let arch = os.arch(); + // Map x64 to amd64 cli artifact + if (arch.match(/(x64)/i)) arch = 'amd64'; + archivePlatform.name = os.platform(); + archivePlatform.arch = arch; + } + + // Set cli artifact to linux-amd64 when building debian artifacts on macOS + if (process.env.BUILD_DEBIAN) { archivePlatform.name = 'linux'; archivePlatform.arch = 'amd64'; } + console.log( + `Download cli for platform: ${archivePlatform.name} arch: ${archivePlatform.arch}` + ); + const archiveName = `boundary_${version}_${archivePlatform.name}_${archivePlatform.arch}.zip`; const url = `https://releases.hashicorp.com/boundary/${version}/${archiveName}`; return new Promise((resolve, reject) => { diff --git a/ui/desktop/electron-app/config/desktop.js b/ui/desktop/electron-app/config/desktop.js index 0e9748503..fe3651478 100644 --- a/ui/desktop/electron-app/config/desktop.js +++ b/ui/desktop/electron-app/config/desktop.js @@ -1,5 +1,6 @@ const fs = require('fs'); const path = require('path'); +const { isLinux } = require('../src/helpers/platform.js'); // Create config const createConfig = () => { @@ -11,7 +12,7 @@ const createConfig = () => { releaseCommit: process.env.RELEASE_COMMIT, }; - if (process.env.CLI_LINUX_DEBIAN_SUPPORT) { + if (isLinux() || process.env.BUILD_DEBIAN) { config.name = 'boundary-desktop'; config.productName = 'boundary-desktop'; } diff --git a/ui/desktop/electron-app/config/forge.config.js b/ui/desktop/electron-app/config/forge.config.js index a1acbbe82..478c7e0e9 100644 --- a/ui/desktop/electron-app/config/forge.config.js +++ b/ui/desktop/electron-app/config/forge.config.js @@ -12,7 +12,7 @@ console.log(`[forge-config] Release version: ${config.releaseVersion}`); if ( isMac() && !process.env.BOUNDARY_DESKTOP_SIGNING_IDENTITY && - !process.env.CLI_LINUX_DEBIAN_SUPPORT + !process.env.BUILD_DEBIAN ) console.warn( '[forge-config] WARNING: Could not find signing identity. Proceeding without signing.' @@ -63,29 +63,28 @@ module.exports = { postPackage: async (forgeConfig, options) => { if (options.spinner) { options.spinner.info( - `Completed packaging for platform: ${options.platform} arch: ${options.arch} at ${options.outputPaths[0]}` + `Packaged for ${options.platform}-${options.arch} at ${options.outputPaths[0]}` ); } }, postMake: (forgeConfig, options) => { // Copy artifacts into release folder options.forEach(({ artifacts, platform, arch }) => { - // Generate platform arch folder name - const folder = `boundary-desktop_${forgeConfig.packagerConfig.appVersion}_${platform}_${arch}`; - const destination = path.join('out', 'artifacts', folder); + // Generate release name + const version = forgeConfig.packagerConfig.appVersion; + const destination = path.join('out', 'release', version); if (!fs.existsSync(destination)) fs.mkdirSync(destination, { recursive: true }); // Copy artifacts artifacts.forEach(async (artifact) => { - const artifactDestination = path.join( - destination, - path.basename(artifact) - ); - console.log(`Copy ${artifact} into ${artifactDestination}.`); + const name = `boundary-desktop_${version}_${platform}_${arch}${path.extname(artifact)}`; + const artifactDestination = path.join(destination, name); + console.log(`[release] Found artifact: ${artifact}`); try { await fs.promises.copyFile(artifact, artifactDestination); + console.log(`[release] Copied artifact: ${path.resolve(artifactDestination)}`); } catch (e) { - console.log(`Could not copy ${artifact}`, e); + console.warn(`[release] Could not copy ${artifact}`, e); } }); }); diff --git a/ui/desktop/electron-app/tests/environments/ubuntu-focal64/Vagrantfile b/ui/desktop/electron-app/tests/environments/ubuntu-focal64/Vagrantfile index 31225577d..7abe99c79 100644 --- a/ui/desktop/electron-app/tests/environments/ubuntu-focal64/Vagrantfile +++ b/ui/desktop/electron-app/tests/environments/ubuntu-focal64/Vagrantfile @@ -4,7 +4,8 @@ Vagrant.configure("2") do |config| config.vm.box = "ubuntu/focal64" - config.vm.synced_folder "../../../out/artifacts", "/vagrant-desktop-app", create: true, owner: "vagrant", group: "vagrant", automount: true + # Share desktop artifacts folder + config.vm.synced_folder "../../../out/release", "/vagrant-desktop-app", create: true, owner: "vagrant", group: "vagrant", automount: true config.vm.provider "virtualbox" do |vb| # Display the VirtualBox GUI when booting the machine @@ -13,6 +14,7 @@ Vagrant.configure("2") do |config| vb.memory = "4096" end + # Setup for testing desktop config.vm.provision "shell", inline: <<-SHELL sudo apt update -y sudo apt upgrade -y @@ -38,5 +40,21 @@ Vagrant.configure("2") do |config| sudo shutdown -r now SHELL - config.vm.post_up_message = "Login using username/password: vagrant/vagrant. Boundary Desktop artifacts: /media/sf_vagrant-boundary-desktop-app. Boundary CLI: /home/vagrant/Desktop." + # Setup for developing desktop + config.vm.provision "shell", inline: <<-SHELL + sudo apt remove cmdtest + sudo apt install -y npm curl git + + git clone https://github.com/hashicorp/boundary-ui.git /home/vagrant/Desktop/boundary-ui + sudo npm install yarn + # Setup node 12 source + curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - + sudo apt install -y nodejs + + # Install boundary-ui dependencies + cd /home/vagrant/Desktop/boundary-ui + yarn install + SHELL + + config.vm.post_up_message = "Login using username/password: vagrant/vagrant.\nBoundary Desktop: /media/sf_vagrant-boundary-desktop-app.\nBoundary CLI: /home/vagrant/Desktop." end diff --git a/ui/desktop/package.json b/ui/desktop/package.json index d6eca93da..13e2ed6db 100755 --- a/ui/desktop/package.json +++ b/ui/desktop/package.json @@ -16,7 +16,7 @@ "build:development": "ember build", "prebuild:desktop": "cross-os prebuild:desktop", "build:desktop": "yarn build:desktop:install && yarn --cwd electron-app make", - "build:desktop:linux": "yarn build:desktop:install && CLI_LINUX_DEBIAN_SUPPORT=true yarn --cwd electron-app make --platform linux --arch x64", + "build:desktop:debian": "yarn build:desktop:install && BUILD_DEBIAN=true yarn --cwd electron-app make --platform linux --arch x64", "build:desktop:install": "yarn install --cwd electron-app", "lint": "npm-run-all --aggregate-output --continue-on-error --parallel 'lint:!(fix)'", "lint:fix": "npm-run-all --aggregate-output --continue-on-error --parallel lint:*:fix",