From 4d8eee8c64e47b7b390f2e387771f09582a9ff90 Mon Sep 17 00:00:00 2001 From: Ben McMorran Date: Thu, 26 Jan 2023 17:03:49 -0800 Subject: [PATCH 1/9] Add packaging script and placeholder files --- .vscodeignore | 6 ++- assets/platform/alpine-arm64/placeholder.txt | 1 + assets/platform/alpine-x64/placeholder.txt | 1 + assets/platform/darwin-arm64/placeholder.txt | 1 + assets/platform/darwin-x64/placeholder.txt | 1 + assets/platform/linux-arm64/placeholder.txt | 1 + assets/platform/linux-armhf/placeholder.txt | 1 + assets/platform/linux-x64/placeholder.txt | 1 + assets/platform/win32-arm64/placeholder.txt | 1 + assets/platform/win32-ia32/placeholder.txt | 1 + assets/platform/win32-x64/placeholder.txt | 1 + azure-pipelines.yml | 8 ++-- build/package.js | 41 ++++++++++++++++++++ package.json | 7 +++- 14 files changed, 65 insertions(+), 7 deletions(-) create mode 100644 assets/platform/alpine-arm64/placeholder.txt create mode 100644 assets/platform/alpine-x64/placeholder.txt create mode 100644 assets/platform/darwin-arm64/placeholder.txt create mode 100644 assets/platform/darwin-x64/placeholder.txt create mode 100644 assets/platform/linux-arm64/placeholder.txt create mode 100644 assets/platform/linux-armhf/placeholder.txt create mode 100644 assets/platform/linux-x64/placeholder.txt create mode 100644 assets/platform/win32-arm64/placeholder.txt create mode 100644 assets/platform/win32-ia32/placeholder.txt create mode 100644 assets/platform/win32-x64/placeholder.txt create mode 100644 build/package.js diff --git a/.vscodeignore b/.vscodeignore index 5e07e3aa..1afd33a2 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -17,4 +17,8 @@ webpack.config.js node_modules/** vendor/** azure-pipelines.yml -build/** \ No newline at end of file +build/** +assets/platform/** + +# A platform-specific directory in assets/platform/ will be added to the end of +# this file by the packaging script. diff --git a/assets/platform/alpine-arm64/placeholder.txt b/assets/platform/alpine-arm64/placeholder.txt new file mode 100644 index 00000000..bc3c9397 --- /dev/null +++ b/assets/platform/alpine-arm64/placeholder.txt @@ -0,0 +1 @@ +This is a placeholder file that should only be installed on alpine-arm64. \ No newline at end of file diff --git a/assets/platform/alpine-x64/placeholder.txt b/assets/platform/alpine-x64/placeholder.txt new file mode 100644 index 00000000..05c4cfe8 --- /dev/null +++ b/assets/platform/alpine-x64/placeholder.txt @@ -0,0 +1 @@ +This is a placeholder file that should only be installed on alpine-x64. \ No newline at end of file diff --git a/assets/platform/darwin-arm64/placeholder.txt b/assets/platform/darwin-arm64/placeholder.txt new file mode 100644 index 00000000..41442272 --- /dev/null +++ b/assets/platform/darwin-arm64/placeholder.txt @@ -0,0 +1 @@ +This is a placeholder file that should only be installed on darwin-arm64. \ No newline at end of file diff --git a/assets/platform/darwin-x64/placeholder.txt b/assets/platform/darwin-x64/placeholder.txt new file mode 100644 index 00000000..67cb4ac7 --- /dev/null +++ b/assets/platform/darwin-x64/placeholder.txt @@ -0,0 +1 @@ +This is a placeholder file that should only be installed on darwin-x64. \ No newline at end of file diff --git a/assets/platform/linux-arm64/placeholder.txt b/assets/platform/linux-arm64/placeholder.txt new file mode 100644 index 00000000..6a3c7585 --- /dev/null +++ b/assets/platform/linux-arm64/placeholder.txt @@ -0,0 +1 @@ +This is a placeholder file that should only be installed on linux-arm64. \ No newline at end of file diff --git a/assets/platform/linux-armhf/placeholder.txt b/assets/platform/linux-armhf/placeholder.txt new file mode 100644 index 00000000..314c0e59 --- /dev/null +++ b/assets/platform/linux-armhf/placeholder.txt @@ -0,0 +1 @@ +This is a placeholder file that should only be installed on linux-armhf. \ No newline at end of file diff --git a/assets/platform/linux-x64/placeholder.txt b/assets/platform/linux-x64/placeholder.txt new file mode 100644 index 00000000..cf43d0e0 --- /dev/null +++ b/assets/platform/linux-x64/placeholder.txt @@ -0,0 +1 @@ +This is a placeholder file that should only be installed on linux-x64. \ No newline at end of file diff --git a/assets/platform/win32-arm64/placeholder.txt b/assets/platform/win32-arm64/placeholder.txt new file mode 100644 index 00000000..504e46bc --- /dev/null +++ b/assets/platform/win32-arm64/placeholder.txt @@ -0,0 +1 @@ +This is a placeholder file that should only be installed on win32-arm64. \ No newline at end of file diff --git a/assets/platform/win32-ia32/placeholder.txt b/assets/platform/win32-ia32/placeholder.txt new file mode 100644 index 00000000..c41550da --- /dev/null +++ b/assets/platform/win32-ia32/placeholder.txt @@ -0,0 +1 @@ +This is a placeholder file that should only be installed on win32-ia32. \ No newline at end of file diff --git a/assets/platform/win32-x64/placeholder.txt b/assets/platform/win32-x64/placeholder.txt new file mode 100644 index 00000000..26131075 --- /dev/null +++ b/assets/platform/win32-x64/placeholder.txt @@ -0,0 +1 @@ +This is a placeholder file that should only be installed on win32-x64. \ No newline at end of file diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 93bfddd8..991c62ca 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -66,7 +66,7 @@ steps: displayName: Use Node 16.x inputs: versionSpec: 16.x - - script: npm install --global gulp node-gyp vsce + - script: npm install --global gulp node-gyp @vscode/vsce displayName: Install global dependencies - script: npm install displayName: Install project dependencies @@ -87,14 +87,14 @@ steps: # Pack the extension now even though it's unsigned so that we ignore files # from .vscodeignore. This will reduce load on the signing server later and # ensure we only attempt to sign shipping files. - - script: vsce package --out vscode-arduino.vsix + - script: node build/package.js displayName: Build and pack extension - # Extract the VSIX, sign what we can, then pack it back up and publish it. + # Extract the VSIXes, sign what we can, then pack it back up and publish it. - task: ExtractFiles@1 displayName: Extract extension for signing inputs: - archiveFilePatterns: vscode-arduino.vsix + archiveFilePatterns: out\vsix\*.vsix destinationFolder: $(Build.StagingDirectory)\vscode-arduino - task: NuGetToolInstaller@1 displayName: Install NuGet diff --git a/build/package.js b/build/package.js new file mode 100644 index 00000000..daf0562b --- /dev/null +++ b/build/package.js @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. + +const { execSync } = require("child_process"); +const { mkdirSync, readFileSync, writeFileSync } = require("fs"); +const { resolve } = require("path"); +const { argv } = require("process"); + +const flags = argv.slice(2).join(" "); + +// Taken from https://code.visualstudio.com/api/working-with-extensions/publishing-extension#platformspecific-extensions +const platforms = [ + "win32-x64", + "win32-ia32", + "win32-arm64", + "linux-x64", + "linux-arm64", + "linux-armhf", + "alpine-x64", + "alpine-arm64", + "darwin-x64", + "darwin-arm64", +]; + +// We include different files for each platform, so we need to build a custom +// .vscodeignore file based on common file and platform-specific path. +const ignoreFile = readFileSync(resolve(__dirname, "..", ".vscodeignore"), "utf8"); +const customIgnoreFilePath = resolve(__dirname, "..", "out", ".vscodeignore"); + +execSync('npm run build', { cwd: resolve(__dirname, ".."), stdio: "inherit" }); +mkdirSync(resolve(__dirname, "..", "out", "vsix"), { recursive: true }); +for (const platform of platforms) { + writeFileSync( + customIgnoreFilePath, + ignoreFile + `!assets/platform/${platform}/**` + ); + const command = `vsce package --target ${platform} --out out/vsix/vscode-arduino-${platform}.vsix ${flags}`; + execSync(command, { + cwd: resolve(__dirname, ".."), + stdio: "inherit", + }); +} diff --git a/package.json b/package.json index 2f847047..b2ebfec4 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "publisher": "vsciot-vscode", "preview": true, "engines": { - "vscode": "^1.56.0" + "vscode": "^1.61.0" }, "icon": "images/arduino.png", "license": "SEE LICENSE IN LICENSE.txt", @@ -595,7 +595,7 @@ ] }, "scripts": { - "vscode:prepublish": "gulp build --mode=production", + "build": "gulp build --mode=production", "postinstall": "cd ./src/views && npm install", "test": "gulp test" }, @@ -669,5 +669,8 @@ "node-sass": "^7.0.0", "es5-ext": "0.10.53", "string_decoder": "https://github.com/microsoft/vscode-arduino/releases/download/v0.4.12-rc2/string_decoder-10.0.0.tgz" + }, + "vsce": { + "ignoreFile": "out/.vscodeignore" } } From 503c80c44b235fa322b88b702dd4d8a5c388c47f Mon Sep 17 00:00:00 2001 From: Ben McMorran Date: Fri, 27 Jan 2023 11:55:49 -0800 Subject: [PATCH 2/9] Sign multiple VSIXes --- azure-pipelines.yml | 22 +++++++--------------- build/SignFiles.proj | 2 +- build/SignVsix.proj | 4 ++-- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 991c62ca..c5e57ce1 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -91,11 +91,8 @@ steps: displayName: Build and pack extension # Extract the VSIXes, sign what we can, then pack it back up and publish it. - - task: ExtractFiles@1 + - pwsh: Get-ChildItem out\vsix | Foreach-Object { 7z e $_.FullName -o$(Build.StagingDirectory)\vscode-arduino\$_.BaseName } displayName: Extract extension for signing - inputs: - archiveFilePatterns: out\vsix\*.vsix - destinationFolder: $(Build.StagingDirectory)\vscode-arduino - task: NuGetToolInstaller@1 displayName: Install NuGet - task: NuGetAuthenticate@0 @@ -111,23 +108,18 @@ steps: msbuildArguments: /p:SignType=$(SignType) # MicroBuild signing will always fail on public PRs. condition: ne(variables['Build.Reason'], 'PullRequest') - - task: ArchiveFiles@2 + - pwsh: Get-ChildItem -Directory $(Build.StagingDirectory)\vscode-arduino | Foreach-Object { 7z a ($_.FullName + ".vsix") $_.FullName\* -tzip } displayName: Pack signed files - inputs: - rootFolderOrFile: $(Build.StagingDirectory)\vscode-arduino - includeRootFolder: false - archiveType: zip - archiveFile: $(Build.StagingDirectory)\vscode-arduino.vsix - task: MSBuild@1 - displayName: Sign VSIX + displayName: Sign VSIXes inputs: solution: .\build\SignVsix.proj msbuildArguments: /p:SignType=$(SignType) # MicroBuild signing will always fail on public PRs. condition: ne(variables['Build.Reason'], 'PullRequest') - - publish: $(Build.StagingDirectory)\vscode-arduino.vsix - artifact: VS Code extension VSIX - displayName: Publish extension VSIX as artifact + - publish: $(Build.StagingDirectory)\vscode-arduino + artifact: VS Code extension VSIXes + displayName: Publish extension VSIXes as artifact # Install the Arduino IDE and run tests. - script: curl -LO https://downloads.arduino.cc/arduino-1.8.19-windows.zip @@ -186,7 +178,7 @@ steps: action: create target: $(Build.SourceVersion) tagSource: auto - assets: $(Build.StagingDirectory)\vscode-arduino.vsix + assets: $(Build.StagingDirectory)\vscode-arduino\*.vsix isPreRelease: $[contains(variables['Build.SourceBranch'], '-rc')] condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags')) diff --git a/build/SignFiles.proj b/build/SignFiles.proj index 953c4acb..8cc6f90e 100644 --- a/build/SignFiles.proj +++ b/build/SignFiles.proj @@ -3,7 +3,7 @@ - $(BUILD_STAGINGDIRECTORY)\vscode-arduino\extension + $(BUILD_STAGINGDIRECTORY)\vscode-arduino $(BaseOutputDirectory) $(BaseOutputDirectory) diff --git a/build/SignVsix.proj b/build/SignVsix.proj index bf9b6047..1e7b0527 100644 --- a/build/SignVsix.proj +++ b/build/SignVsix.proj @@ -3,14 +3,14 @@ - $(BUILD_STAGINGDIRECTORY) + $(BUILD_STAGINGDIRECTORY)\vscode-arduino $(BaseOutputDirectory) $(BaseOutputDirectory) - + VsixSHA2 From 5e682d60f59e7b5a64ae70558643c1a6d387568e Mon Sep 17 00:00:00 2001 From: Ben McMorran Date: Fri, 27 Jan 2023 16:24:35 -0800 Subject: [PATCH 3/9] Install 7zip first --- azure-pipelines.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index c5e57ce1..7192e41a 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -91,6 +91,12 @@ steps: displayName: Build and pack extension # Extract the VSIXes, sign what we can, then pack it back up and publish it. + - pwsh: | + $path = Join-Path $Env:TEMP "7z-installer.exe" + Invoke-WebRequest https://www.7-zip.org/a/7z2201-x64.exe -OutFile $path + Start-Process -FilePath $path -Args "/S" -Verb RunAs -Wait + Remove-Item $path + displayName: Install 7zip - pwsh: Get-ChildItem out\vsix | Foreach-Object { 7z e $_.FullName -o$(Build.StagingDirectory)\vscode-arduino\$_.BaseName } displayName: Extract extension for signing - task: NuGetToolInstaller@1 From 9f393ec4a4026f27591101a1a0ef83ae9a1b0c80 Mon Sep 17 00:00:00 2001 From: Ben McMorran Date: Thu, 2 Feb 2023 12:05:33 -0800 Subject: [PATCH 4/9] Add 7-zip to PATH --- azure-pipelines.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 7192e41a..2e89f85e 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -96,6 +96,7 @@ steps: Invoke-WebRequest https://www.7-zip.org/a/7z2201-x64.exe -OutFile $path Start-Process -FilePath $path -Args "/S" -Verb RunAs -Wait Remove-Item $path + Echo "##vso[task.prependpath]$Env:PROGRAMFILES\7-Zip\" displayName: Install 7zip - pwsh: Get-ChildItem out\vsix | Foreach-Object { 7z e $_.FullName -o$(Build.StagingDirectory)\vscode-arduino\$_.BaseName } displayName: Extract extension for signing From 20a9e76458449c9890711c7d368dc35378138ddc Mon Sep 17 00:00:00 2001 From: Ben McMorran Date: Thu, 2 Feb 2023 12:22:14 -0800 Subject: [PATCH 5/9] Try using subexpression --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 2e89f85e..57251790 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -98,7 +98,7 @@ steps: Remove-Item $path Echo "##vso[task.prependpath]$Env:PROGRAMFILES\7-Zip\" displayName: Install 7zip - - pwsh: Get-ChildItem out\vsix | Foreach-Object { 7z e $_.FullName -o$(Build.StagingDirectory)\vscode-arduino\$_.BaseName } + - pwsh: Get-ChildItem out\vsix | Foreach-Object { 7z e $_.FullName -o$(Build.StagingDirectory)\vscode-arduino\$($_.BaseName) } displayName: Extract extension for signing - task: NuGetToolInstaller@1 displayName: Install NuGet From b15e8ea75c2948c376a27218837acc10e855d463 Mon Sep 17 00:00:00 2001 From: Ben McMorran Date: Thu, 2 Feb 2023 12:32:18 -0800 Subject: [PATCH 6/9] Extract with full paths --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 57251790..a6c12587 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -98,7 +98,7 @@ steps: Remove-Item $path Echo "##vso[task.prependpath]$Env:PROGRAMFILES\7-Zip\" displayName: Install 7zip - - pwsh: Get-ChildItem out\vsix | Foreach-Object { 7z e $_.FullName -o$(Build.StagingDirectory)\vscode-arduino\$($_.BaseName) } + - pwsh: Get-ChildItem out\vsix | Foreach-Object { 7z x $_.FullName -o$(Build.StagingDirectory)\vscode-arduino\$($_.BaseName) } displayName: Extract extension for signing - task: NuGetToolInstaller@1 displayName: Install NuGet From 99cfc7f28046a7eaf0b06f3c630ed89e433cfc57 Mon Sep 17 00:00:00 2001 From: Ben McMorran Date: Thu, 2 Feb 2023 13:34:02 -0800 Subject: [PATCH 7/9] Add parens --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a6c12587..6fe5c249 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -115,7 +115,7 @@ steps: msbuildArguments: /p:SignType=$(SignType) # MicroBuild signing will always fail on public PRs. condition: ne(variables['Build.Reason'], 'PullRequest') - - pwsh: Get-ChildItem -Directory $(Build.StagingDirectory)\vscode-arduino | Foreach-Object { 7z a ($_.FullName + ".vsix") $_.FullName\* -tzip } + - pwsh: Get-ChildItem -Directory $(Build.StagingDirectory)\vscode-arduino | Foreach-Object { 7z a ($_.FullName + ".vsix") ($_.FullName + "\*") -tzip } displayName: Pack signed files - task: MSBuild@1 displayName: Sign VSIXes From 560591901892eb867b252f29a113fe9e0cda2011 Mon Sep 17 00:00:00 2001 From: Ben McMorran Date: Thu, 2 Feb 2023 14:02:19 -0800 Subject: [PATCH 8/9] Use separate VSIX directory --- azure-pipelines.yml | 9 ++++++--- build/SignVsix.proj | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 6fe5c249..4623b8e8 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -115,7 +115,10 @@ steps: msbuildArguments: /p:SignType=$(SignType) # MicroBuild signing will always fail on public PRs. condition: ne(variables['Build.Reason'], 'PullRequest') - - pwsh: Get-ChildItem -Directory $(Build.StagingDirectory)\vscode-arduino | Foreach-Object { 7z a ($_.FullName + ".vsix") ($_.FullName + "\*") -tzip } + - pwsh: | + Get-ChildItem -Directory $(Build.StagingDirectory)\vscode-arduino | Foreach-Object { 7z a ($_.FullName + ".vsix") ($_.FullName + "\*") -tzip } + New-Item -Path $(Build.StagingDirectory)\vscode-arduino\vsix -ItemType Directory + Get-Item $(Build.StagingDirectory)\vscode-arduino\*.vsix | Move-Item -Destination $(Build.StagingDirectory)\vscode-arduino\vsix displayName: Pack signed files - task: MSBuild@1 displayName: Sign VSIXes @@ -124,7 +127,7 @@ steps: msbuildArguments: /p:SignType=$(SignType) # MicroBuild signing will always fail on public PRs. condition: ne(variables['Build.Reason'], 'PullRequest') - - publish: $(Build.StagingDirectory)\vscode-arduino + - publish: $(Build.StagingDirectory)\vscode-arduino\vsix artifact: VS Code extension VSIXes displayName: Publish extension VSIXes as artifact @@ -185,7 +188,7 @@ steps: action: create target: $(Build.SourceVersion) tagSource: auto - assets: $(Build.StagingDirectory)\vscode-arduino\*.vsix + assets: $(Build.StagingDirectory)\vscode-arduino\vsix\*.vsix isPreRelease: $[contains(variables['Build.SourceBranch'], '-rc')] condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags')) diff --git a/build/SignVsix.proj b/build/SignVsix.proj index 1e7b0527..e1ffd4d0 100644 --- a/build/SignVsix.proj +++ b/build/SignVsix.proj @@ -3,7 +3,7 @@ - $(BUILD_STAGINGDIRECTORY)\vscode-arduino + $(BUILD_STAGINGDIRECTORY)\vscode-arduino\vsix $(BaseOutputDirectory) $(BaseOutputDirectory) From d86f98078eea18a5b9ad866821b1d811d9917d06 Mon Sep 17 00:00:00 2001 From: Ben McMorran Date: Thu, 2 Feb 2023 14:58:18 -0800 Subject: [PATCH 9/9] Fix GH workflows --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b62cc826..924a70b4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -72,12 +72,12 @@ jobs: - name: Check for linting errors run: gulp tslint - name: Build and pack extension - run: vsce package --out vscode-arduino.vsix + run: node build/package.js - name: Publish extension VSIX as artifact uses: actions/upload-artifact@v2 with: - name: VS Code extension VSIX (${{ matrix.os }}) - path: vscode-arduino.vsix + name: VS Code extension VSIXes (${{ matrix.os }}) + path: out/vsix - name: Run tests uses: GabrielBB/xvfb-action@v1