8000 Merge branch 'main' into add_publish_ci · vscode-arduino/vscode-arduino@c06aa0e · GitHub
[go: up one dir, main page]

Skip to content

Commit c06aa0e

Browse files
authored
Merge branch 'main' into add_publish_ci
2 parents 315f611 + fce3105 commit c06aa0e

File tree

4 files changed

+559
-14176
lines changed

4 files changed

+559
-14176
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,3 @@ on:
1212
jobs:
1313
build:
1414
uses: ./.github/workflows/templates/build.yml
15-

build/downloadAssets.js

Lines changed: 42 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
const { execSync } = require("child_process");
99
const { createHash } = require("crypto");
10-
const { readFileSync, mkdirSync, rmSync, renameSync } = require("fs");
10+
const { readFileSync, mkdirSync, rmSync, renameSync, existsSync } = require("fs");
1111
const { resolve } = require("path");
1212

1313
function run(command) {
@@ -24,48 +24,52 @@ for (const asset in config.assets) {
2424
for (const platform of platforms) {
2525
const directory = resolve(__dirname, "..", "assets", "platform", platform);
2626
const destination = resolve(directory, asset);
27+
const extractDirectory = resolve(directory, "arduino-cli");
28+
// Check if the asset has already been downloaded
29+
if (!existsSync(extractDirectory)) {
2730

28-
// Download the asset.
29-
run([
30-
"curl",
31-
`https://github.com/arduino/arduino-cli/releases/download/${config.version}/${asset}`,
32-
"--location",
33-
`--output-dir ${directory}`,
34-
`--remote-name`,
35-
"--silent",
36-
"--show-error",
37-
].join(" "));
31+
// Download the asset.
32+
run([
33+
"curl",
34+
`https://github.com/arduino/arduino-cli/releases/download/${config.version}/${asset}`,
35+
"--location",
36+
`--output-dir ${directory}`,
37+
`--remote-name`,
38+
"--silent",
39+
"--show-error",
40+
].join(" "));
3841

39-
// Verify the hash.
40-
const actualHash = createHash("sha256")
41-
.update(readFileSync(destination))
42-
.digest("hex");
43-
if (actualHash !== hash) {
44-
throw new Error(
45-
`Hash mismatch for ${asset} on ${platform}. Expected ${hash} but got ${actualHash}.`
46-
);
47-
}
42+
// Verify the hash.
43+
const actualHash = createHash("sha256")
44+
.update(readFileSync(destination))
45+
.digest("hex");
46+
if (actualHash !== hash) {
47+
throw new Error(
48+
`Hash mismatch for ${asset} on ${platform}. Expected ${hash} but got ${actualHash}.`
49+
);
50+
}
51+
4852

49-
// Extract to an "arduino-cli" directory.
50-
const extractDirectory = resolve(directory, "arduino-cli");
51-
mkdirSync(extractDirectory, { recursive: true });
52-
// tar on Linux doesn't understand zip files.
53-
if (asset.endsWith(".zip") && process.platform === 'linux') {
54-
run(`unzip ${destination} -d ${extractDirectory}`);
55-
} else {
56-
run(`tar -xf ${destination} -C ${extractDirectory}`);
57-
}
53+
// Extract to an "arduino-cli" directory.
54+
mkdirSync(extractDirectory, { recursive: true });
55+
// tar on Linux doesn't understand zip files.
56+
if (asset.endsWith(".zip") && process.platform === 'linux') {
57+
run(`unzip ${destination} -d ${extractDirectory}`);
58+
} else {
59+
run(`tar -xf ${destination} -C ${extractDirectory}`);
60+
}
5861

59-
// Remove the downloaded archive. We don't need to ship it.
60-
rmSync(destination);
62+
// Remove the downloaded archive. We don't need to ship it.
63+
rmSync(destination);
6164

62-
// VSIX signing will silently strip any extensionless files. Artificially
63-
// add a ".app" extension to extensionless executables.
64-
const executable = resolve(extractDirectory, "arduino-cli");
65-
try {
66-
renameSync(executable, `${executable}.app`);
67-
} catch {
68-
// The file might not exist. This is expected for Windows.
65+
// VSIX signing will silently strip any extensionless files. Artificially
66+
// add a ".app" extension to extensionless executables.
67+
const executable = resolve(extractDirectory, "arduino-cli");
68+
try {
69+
renameSync(executable, `${executable}.app`);
70+
} catch {
71+
// The file might not exist. This is expected for Windows.
72+
}
6973
}
7074
}
7175
}

0 commit comments

Comments
 (0)
0