From 6416ef5b05f4c93ed2cd1aab4b6fc7c4f0f32ae6 Mon Sep 17 00:00:00 2001 From: Asher Date: Tue, 5 Mar 2019 12:37:16 -0600 Subject: [PATCH 1/7] Add task for packaging release --- .gitignore | 1 + build/tasks.ts | 39 +++++++++++++++++++++++++++++++++++ packages/runner/src/runner.ts | 5 +++-- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 647d88c54044..9ced34fb847c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ node_modules dist out .DS_Store +release diff --git a/build/tasks.ts b/build/tasks.ts index 431fe502f841..3175cc1e115d 100644 --- a/build/tasks.ts +++ b/build/tasks.ts @@ -260,4 +260,43 @@ const ensurePatched = register("vscode:patch", async (runner) => { } }); +register("package", async (runner, releaseTag, binLocation) => { + if (!releaseTag) { + throw new Error("Please specify the release tag."); + } + if (!binLocation) { + throw new Error("Please specify the location of the binaries."); + } + + const releasePath = path.resolve(__dirname, `../release/${releaseTag}`); + fse.removeSync(releasePath); + fse.mkdirpSync(releasePath); + + await Promise.all([{ + bin: "cli-linux", + name: "linux", + }, { + bin: "cli-osx", + name: "apple-darwin", + }].map(async (pkg) => { + const archiveName = `code-server-${releaseTag}-x86_64-${pkg.name}`; + const archiveDir = path.join(releasePath, archiveName); + fse.mkdirpSync(archiveDir); + + const binaryPath = path.join(binLocation, pkg.bin); + const binaryDestination = path.join(archiveDir, "code-server"); + fse.copySync(binaryPath, binaryDestination); + fs.chmodSync(binaryDestination, "755"); + ["README.md", "LICENSE"].forEach((fileName) => { + fse.copySync(path.resolve(__dirname, `../${fileName}`), path.join(archiveDir, fileName)); + }); + + runner.cwd = releasePath; + await Promise.all([ + runner.execute("tar", ["-cvzf", `${archiveName}.tar.gz`, `${archiveName}`]), + runner.execute("zip", ["-r", `${archiveName}.zip`, `${archiveName}`]), + ]); + })); +}); + run(); diff --git a/packages/runner/src/runner.ts b/packages/runner/src/runner.ts index f057aa1b0b2e..93bea4837a20 100644 --- a/packages/runner/src/runner.ts +++ b/packages/runner/src/runner.ts @@ -40,7 +40,8 @@ const execute = (command: string, args: string[] = [], options: cp.SpawnOptions, return prom; }; -export type TaskFunction = (runner: Runner) => void | Promise; +// tslint:disable-next-line no-any +export type TaskFunction = (runner: Runner, ...args: any[]) => void | Promise; export interface Runner { cwd: string; @@ -95,7 +96,7 @@ export const run = (name: string = process.argv[2]): void | Promise => { env: env as NodeJS.ProcessEnv, }, log); }, - }); + }, ...process.argv.slice(3)); if (prom) { activated.set(name, prom); From fc5cb0fca1d37c1fc32d39d5abd637d6669c96c9 Mon Sep 17 00:00:00 2001 From: Asher Date: Wed, 6 Mar 2019 10:58:08 -0600 Subject: [PATCH 2/7] Modify package task to package a single binary This is so it can be used as part of the build/release script. --- build/tasks.ts | 50 ++++++++++++++++++++++---------------------------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/build/tasks.ts b/build/tasks.ts index 3175cc1e115d..653eb353cd4f 100644 --- a/build/tasks.ts +++ b/build/tasks.ts @@ -260,43 +260,37 @@ const ensurePatched = register("vscode:patch", async (runner) => { } }); -register("package", async (runner, releaseTag, binLocation) => { +register("package", async (runner, binaryPath, releaseTag, platform) => { + if (!binaryPath) { + throw new Error("Please specify the location of the binary."); + } if (!releaseTag) { throw new Error("Please specify the release tag."); } - if (!binLocation) { - throw new Error("Please specify the location of the binaries."); + if (!platform) { + throw new Error("Please specify the platform."); } const releasePath = path.resolve(__dirname, `../release/${releaseTag}`); - fse.removeSync(releasePath); fse.mkdirpSync(releasePath); - await Promise.all([{ - bin: "cli-linux", - name: "linux", - }, { - bin: "cli-osx", - name: "apple-darwin", - }].map(async (pkg) => { - const archiveName = `code-server-${releaseTag}-x86_64-${pkg.name}`; - const archiveDir = path.join(releasePath, archiveName); - fse.mkdirpSync(archiveDir); - - const binaryPath = path.join(binLocation, pkg.bin); - const binaryDestination = path.join(archiveDir, "code-server"); - fse.copySync(binaryPath, binaryDestination); - fs.chmodSync(binaryDestination, "755"); - ["README.md", "LICENSE"].forEach((fileName) => { - fse.copySync(path.resolve(__dirname, `../${fileName}`), path.join(archiveDir, fileName)); - }); + const archiveName = `code-server-${releaseTag}-${platform}`; + const archiveDir = path.join(releasePath, archiveName); + fse.removeSync(archiveDir); + fse.mkdirpSync(archiveDir); + + const binaryDestination = path.join(archiveDir, "code-server"); + fse.copySync(binaryPath, binaryDestination); + fs.chmodSync(binaryDestination, "755"); + ["README.md", "LICENSE"].forEach((fileName) => { + fse.copySync(path.resolve(__dirname, `../${fileName}`), path.join(archiveDir, fileName)); + }); - runner.cwd = releasePath; - await Promise.all([ - runner.execute("tar", ["-cvzf", `${archiveName}.tar.gz`, `${archiveName}`]), - runner.execute("zip", ["-r", `${archiveName}.zip`, `${archiveName}`]), - ]); - })); + runner.cwd = releasePath; + await Promise.all([ + runner.execute("tar", ["-cvzf", `${archiveName}.tar.gz`, `${archiveName}`]), + runner.execute("zip", ["-r", `${archiveName}.zip`, `${archiveName}`]), + ]); }); run(); From 5d1d4df16eb7b5ce93a35fe4e16a5d9aa4513ead Mon Sep 17 00:00:00 2001 From: Asher Date: Wed, 6 Mar 2019 12:54:20 -0600 Subject: [PATCH 3/7] Package release as part of Travis deploy --- .travis.yml | 5 ++++- build/tasks.ts | 9 +++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 540780cf2af4..bef2aba10ba3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,7 @@ before_deploy: - git config --local user.name "$USER_NAME" - git config --local user.email "$USER_EMAIL" - git tag "$TRAVIS_TAG" "$TRAVIS_COMMIT" +- yarn task package "$TRAVIS_TAG" "$TRAVIS_OS_NAME" deploy: provider: releases file_glob: true @@ -27,7 +28,9 @@ deploy: skip_cleanup: true api_key: secure: YL/x24KjYjgYXPcJWk3FV7FGxI79Mh6gBECQEcdlf3fkLEoKFVgzHBoUNWrFPzyR4tgLyWNAgcpD9Lkme1TRWTom7UPjXcwMNyLcLa+uec7ciSAnYD9ntLTpiCuPDD1u0LtRGclSi/EHQ+F8YVq+HZJpXTsJeAmOmihma3GVbGKSZr+BRum+0YZSG4w+o4TOlYzw/4bLWS52MogZcwpjd+hemBbgXLuGU2ziKv2vEKCZFbEeA16II4x1WLI4mutDdCeh7+3aLzGLwDa49NxtsVYNjyNFF75JhCTCNA55e2YMiLz9Uq69IXe/mi5F7xUaFfhIqqLNyKBnKeEOzu3dYnc+8n3LjnQ+00PmkF05nx9kBn3UfV1kwQGh6QbyDmTtBP07rtUMyI14aeQqHjxsaVRdMnwj9Q2DjXRr8UDqESZF0rmK3pHCXS2fBhIzLE8tLVW5Heiba2pQRFMHMZW+KBE97FzcFh7is90Ait3T8enfcd/PWFPYoBejDAdjwxwOkezh5N5ZkYquEfDYuWrFi6zRFCktsruaAcA+xGtTf9oilBBzUqu8Ie+YFWH5me83xakcblJWdaW/D2rLJAJH3m6LFm8lBqyUgDX5t/etob6CpDuYHu5D1J3XINOj/+aLAcadq6qlh70PMZS3zYffUu3JlzaD2amlSHIT8b5YXFc= - file: packages/server/cli-* + file: + - release/*.tar.gz + - release/*.zip on: repo: codercom/code-server branch: master diff --git a/build/tasks.ts b/build/tasks.ts index 653eb353cd4f..37ed10511c76 100644 --- a/build/tasks.ts +++ b/build/tasks.ts @@ -260,10 +260,7 @@ const ensurePatched = register("vscode:patch", async (runner) => { } }); -register("package", async (runner, binaryPath, releaseTag, platform) => { - if (!binaryPath) { - throw new Error("Please specify the location of the binary."); - } +register("package", async (runner, releaseTag, platform) => { if (!releaseTag) { throw new Error("Please specify the release tag."); } @@ -271,14 +268,14 @@ register("package", async (runner, binaryPath, releaseTag, platform) => { throw new Error("Please specify the platform."); } - const releasePath = path.resolve(__dirname, `../release/${releaseTag}`); - fse.mkdirpSync(releasePath); + const releasePath = path.resolve(__dirname, `../release`); const archiveName = `code-server-${releaseTag}-${platform}`; const archiveDir = path.join(releasePath, archiveName); fse.removeSync(archiveDir); fse.mkdirpSync(archiveDir); + const binaryPath = path.join(__dirname, `../packages/server/cli-${platform}`); const binaryDestination = path.join(archiveDir, "code-server"); fse.copySync(binaryPath, binaryDestination); fs.chmodSync(binaryDestination, "755"); From f7df16deadebcb275767af00ba78bc0c148b6635 Mon Sep 17 00:00:00 2001 From: Asher Date: Wed, 6 Mar 2019 13:27:34 -0600 Subject: [PATCH 4/7] Set platform env var --- .travis.yml | 6 +++++- packages/server/scripts/nexe.js | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index bef2aba10ba3..141667ce5fd8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,11 @@ matrix: include: - os: linux dist: ubuntu + env: + - PLATFORM="x86_64-linux" - os: osx + env: + - PLATFORM="x86_64-apple-darwin" before_install: - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install libxkbfile-dev libsecret-1-dev; fi @@ -17,7 +21,7 @@ before_deploy: - git config --local user.name "$USER_NAME" - git config --local user.email "$USER_EMAIL" - git tag "$TRAVIS_TAG" "$TRAVIS_COMMIT" -- yarn task package "$TRAVIS_TAG" "$TRAVIS_OS_NAME" +- yarn task package "$TRAVIS_TAG" "$PLATFORM" deploy: provider: releases file_glob: true diff --git a/packages/server/scripts/nexe.js b/packages/server/scripts/nexe.js index 8c1a29fb1ded..efdea4c436a5 100644 --- a/packages/server/scripts/nexe.js +++ b/packages/server/scripts/nexe.js @@ -17,7 +17,7 @@ const nexe = require("nexe"); nexe.compile({ debugBundle: true, input: path.join(__dirname, "../out/cli.js"), - output: `cli-${process.env.TRAVIS_OS_NAME || os.platform()}`, + output: `cli-${process.env.PLATFORM || os.platform()}`, targets: [os.platform()], /** * To include native extensions, do NOT install node_modules for each one. They From daeff144fe6f97922534330938fe9113a718bca1 Mon Sep 17 00:00:00 2001 From: Asher Date: Wed, 6 Mar 2019 16:06:02 -0600 Subject: [PATCH 5/7] Add arch env var --- .travis.yml | 8 +++++--- packages/server/scripts/nexe.js | 7 ++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 141667ce5fd8..c507355dc48d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,10 +6,12 @@ matrix: - os: linux dist: ubuntu env: - - PLATFORM="x86_64-linux" + - PLATFORM=linux + - ARCH=x64 - os: osx env: - - PLATFORM="x86_64-apple-darwin" + - PLATFORM=darwin + - ARCH=x64 before_install: - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install libxkbfile-dev libsecret-1-dev; fi @@ -21,7 +23,7 @@ before_deploy: - git config --local user.name "$USER_NAME" - git config --local user.email "$USER_EMAIL" - git tag "$TRAVIS_TAG" "$TRAVIS_COMMIT" -- yarn task package "$TRAVIS_TAG" "$PLATFORM" +- yarn task package "$TRAVIS_TAG" "$PLATFORM-$ARCH" deploy: provider: releases file_glob: true diff --git a/packages/server/scripts/nexe.js b/packages/server/scripts/nexe.js index efdea4c436a5..06860a05ffd0 100644 --- a/packages/server/scripts/nexe.js +++ b/packages/server/scripts/nexe.js @@ -14,16 +14,17 @@ fs.writeFileSync(shimPath, shimContent); const nexe = require("nexe"); +const target = `${process.env.PLATFORM || os.platform()}${process.env.ARCH ? `-${process.env.ARCH}` : ""}`; nexe.compile({ debugBundle: true, input: path.join(__dirname, "../out/cli.js"), - output: `cli-${process.env.PLATFORM || os.platform()}`, - targets: [os.platform()], + output: `cli-${target}`, + targets: [target], /** * To include native extensions, do NOT install node_modules for each one. They * are not required as each extension is built using webpack. */ -resources: [ + resources: [ path.join(__dirname, "../package.json"), path.join(__dirname, "../build/**/*"), ], From 85c192ef649797001f596462ba2704f84a96d7f1 Mon Sep 17 00:00:00 2001 From: Asher Date: Wed, 6 Mar 2019 16:24:55 -0600 Subject: [PATCH 6/7] Make version available to the code --- .travis.yml | 21 ++++++++------------- build/tasks.ts | 11 ++++------- packages/server/scripts/nexe.js | 2 +- packages/server/src/cli.ts | 2 +- packages/server/webpack.config.js | 2 +- scripts/webpack.general.config.js | 1 + 6 files changed, 16 insertions(+), 23 deletions(-) diff --git a/.travis.yml b/.travis.yml index c507355dc48d..8b6f956db876 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,36 +1,31 @@ language: node_js node_js: - 8.9.3 +env: + - VERSION="1.31.1-$TRAVIS_BUILD_NUMBER" matrix: include: - os: linux dist: ubuntu - env: - - PLATFORM=linux - - ARCH=x64 - os: osx - env: - - PLATFORM=darwin - - ARCH=x64 before_install: - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install libxkbfile-dev libsecret-1-dev; fi script: - scripts/build.sh before_deploy: -- export TRAVIS_TAG="1.31.1-$TRAVIS_BUILD_NUMBER" -- echo "$TRAVIS_TAG" "$TRAVIS_COMMIT" +- echo "$VERSION" "$TRAVIS_COMMIT" - git config --local user.name "$USER_NAME" - git config --local user.email "$USER_EMAIL" -- git tag "$TRAVIS_TAG" "$TRAVIS_COMMIT" -- yarn task package "$TRAVIS_TAG" "$PLATFORM-$ARCH" +- git tag "$VERSION" "$TRAVIS_COMMIT" +- yarn task package "$VERSION" deploy: provider: releases file_glob: true draft: true - tag_name: $TRAVIS_TAG - target_commitish: $TRAVIS_COMMIT - name: $TRAVIS_TAG + tag_name: "$VERSION" + target_commitish: "$TRAVIS_COMMIT" + name: "$VERSION" skip_cleanup: true api_key: secure: YL/x24KjYjgYXPcJWk3FV7FGxI79Mh6gBECQEcdlf3fkLEoKFVgzHBoUNWrFPzyR4tgLyWNAgcpD9Lkme1TRWTom7UPjXcwMNyLcLa+uec7ciSAnYD9ntLTpiCuPDD1u0LtRGclSi/EHQ+F8YVq+HZJpXTsJeAmOmihma3GVbGKSZr+BRum+0YZSG4w+o4TOlYzw/4bLWS52MogZcwpjd+hemBbgXLuGU2ziKv2vEKCZFbEeA16II4x1WLI4mutDdCeh7+3aLzGLwDa49NxtsVYNjyNFF75JhCTCNA55e2YMiLz9Uq69IXe/mi5F7xUaFfhIqqLNyKBnKeEOzu3dYnc+8n3LjnQ+00PmkF05nx9kBn3UfV1kwQGh6QbyDmTtBP07rtUMyI14aeQqHjxsaVRdMnwj9Q2DjXRr8UDqESZF0rmK3pHCXS2fBhIzLE8tLVW5Heiba2pQRFMHMZW+KBE97FzcFh7is90Ait3T8enfcd/PWFPYoBejDAdjwxwOkezh5N5ZkYquEfDYuWrFi6zRFCktsruaAcA+xGtTf9oilBBzUqu8Ie+YFWH5me83xakcblJWdaW/D2rLJAJH3m6LFm8lBqyUgDX5t/etob6CpDuYHu5D1J3XINOj/+aLAcadq6qlh70PMZS3zYffUu3JlzaD2amlSHIT8b5YXFc= diff --git a/build/tasks.ts b/build/tasks.ts index 37ed10511c76..79d0af847596 100644 --- a/build/tasks.ts +++ b/build/tasks.ts @@ -260,22 +260,19 @@ const ensurePatched = register("vscode:patch", async (runner) => { } }); -register("package", async (runner, releaseTag, platform) => { +register("package", async (runner, releaseTag) => { if (!releaseTag) { throw new Error("Please specify the release tag."); } - if (!platform) { - throw new Error("Please specify the platform."); - } - const releasePath = path.resolve(__dirname, `../release`); + const releasePath = path.resolve(__dirname, "../release"); - const archiveName = `code-server-${releaseTag}-${platform}`; + const archiveName = `code-server-${releaseTag}-${os.platform()}-${os.arch()}`; const archiveDir = path.join(releasePath, archiveName); fse.removeSync(archiveDir); fse.mkdirpSync(archiveDir); - const binaryPath = path.join(__dirname, `../packages/server/cli-${platform}`); + const binaryPath = path.join(__dirname, `../packages/server/cli-${os.platform()}-${os.arch()}`); const binaryDestination = path.join(archiveDir, "code-server"); fse.copySync(binaryPath, binaryDestination); fs.chmodSync(binaryDestination, "755"); diff --git a/packages/server/scripts/nexe.js b/packages/server/scripts/nexe.js index 06860a05ffd0..5de18bd4c1d9 100644 --- a/packages/server/scripts/nexe.js +++ b/packages/server/scripts/nexe.js @@ -14,7 +14,7 @@ fs.writeFileSync(shimPath, shimContent); const nexe = require("nexe"); -const target = `${process.env.PLATFORM || os.platform()}${process.env.ARCH ? `-${process.env.ARCH}` : ""}`; +const target = `${os.platform()}-${os.arch()}`; nexe.compile({ debugBundle: true, input: path.join(__dirname, "../out/cli.js"), diff --git a/packages/server/src/cli.ts b/packages/server/src/cli.ts index 7bedae71f75a..2f1da114a954 100644 --- a/packages/server/src/cli.ts +++ b/packages/server/src/cli.ts @@ -114,7 +114,7 @@ export class Entry extends Command { } } - logger.info("\u001B[1mcode-server v1.0.0"); + logger.info(`\u001B[1mcode-server ${process.env.VERSION ? `v${process.env.VERSION}` : "development"}`); // TODO: fill in appropriate doc url logger.info("Additional documentation: http://github.com/codercom/code-server"); logger.info("Initializing", field("data-dir", dataDir), field("working-dir", workingDir), field("log-dir", logDir)); diff --git a/packages/server/webpack.config.js b/packages/server/webpack.config.js index 0df82de3feb0..596ff0be3a2e 100644 --- a/packages/server/webpack.config.js +++ b/packages/server/webpack.config.js @@ -24,7 +24,7 @@ module.exports = merge( }, resolve: { alias: { - "node-pty": "node-pty-prebuilt", + "node-pty": "node-pty-prebuilt", }, }, externals: ["tslib", "trash"], diff --git a/scripts/webpack.general.config.js b/scripts/webpack.general.config.js index 26587519a48d..83215fa8cd28 100644 --- a/scripts/webpack.general.config.js +++ b/scripts/webpack.general.config.js @@ -118,6 +118,7 @@ module.exports = (options = {}) => ({ "process.env.NODE_ENV": `"${environment}"`, "process.env.LOG_LEVEL": `"${process.env.LOG_LEVEL || ""}"`, "process.env.SERVICE_URL": `"${process.env.SERVICE_URL || ""}"`, + "process.env.VERSION": `"${process.env.VERSION || ""}"`, }), ], stats: { From f11fa9c3f1d23b1451d971ac8ff98fd43298a478 Mon Sep 17 00:00:00 2001 From: Asher Date: Wed, 6 Mar 2019 17:22:23 -0600 Subject: [PATCH 7/7] Use tar for Linux and zip for Mac & Windows --- build/tasks.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/build/tasks.ts b/build/tasks.ts index 79d0af847596..0831fb5f43b4 100644 --- a/build/tasks.ts +++ b/build/tasks.ts @@ -281,10 +281,9 @@ register("package", async (runner, releaseTag) => { }); runner.cwd = releasePath; - await Promise.all([ - runner.execute("tar", ["-cvzf", `${archiveName}.tar.gz`, `${archiveName}`]), - runner.execute("zip", ["-r", `${archiveName}.zip`, `${archiveName}`]), - ]); + await os.platform() === "linux" + ? runner.execute("tar", ["-cvzf", `${archiveName}.tar.gz`, `${archiveName}`]) + : runner.execute("zip", ["-r", `${archiveName}.zip`, `${archiveName}`]); }); run();