Add task for packaging release (#6)

* Add task for packaging release

* Modify package task to package a single binary

This is so it can be used as part of the build/release script.

* Package release as part of Travis deploy

* Set platform env var

* Add arch env var

* Make version available to the code

* Use tar for Linux and zip for Mac & Windows
This commit is contained in:
Asher 2019-03-06 18:15:52 -06:00 committed by GitHub
parent 8916cb9bb2
commit 994531d8bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 48 additions and 14 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@ node_modules
dist dist
out out
.DS_Store .DS_Store
release

View File

@ -1,6 +1,8 @@
language: node_js language: node_js
node_js: node_js:
- 8.9.3 - 8.9.3
env:
- VERSION="1.31.1-$TRAVIS_BUILD_NUMBER"
matrix: matrix:
include: include:
- os: linux - os: linux
@ -12,22 +14,24 @@ before_install:
script: script:
- scripts/build.sh - scripts/build.sh
before_deploy: before_deploy:
- export TRAVIS_TAG="1.31.1-$TRAVIS_BUILD_NUMBER" - echo "$VERSION" "$TRAVIS_COMMIT"
- echo "$TRAVIS_TAG" "$TRAVIS_COMMIT"
- git config --local user.name "$USER_NAME" - git config --local user.name "$USER_NAME"
- git config --local user.email "$USER_EMAIL" - git config --local user.email "$USER_EMAIL"
- git tag "$TRAVIS_TAG" "$TRAVIS_COMMIT" - git tag "$VERSION" "$TRAVIS_COMMIT"
- yarn task package "$VERSION"
deploy: deploy:
provider: releases provider: releases
file_glob: true file_glob: true
draft: true draft: true
tag_name: $TRAVIS_TAG tag_name: "$VERSION"
target_commitish: $TRAVIS_COMMIT target_commitish: "$TRAVIS_COMMIT"
name: $TRAVIS_TAG name: "$VERSION"
skip_cleanup: true skip_cleanup: true
api_key: api_key:
secure: YL/x24KjYjgYXPcJWk3FV7FGxI79Mh6gBECQEcdlf3fkLEoKFVgzHBoUNWrFPzyR4tgLyWNAgcpD9Lkme1TRWTom7UPjXcwMNyLcLa+uec7ciSAnYD9ntLTpiCuPDD1u0LtRGclSi/EHQ+F8YVq+HZJpXTsJeAmOmihma3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ie+YFWH5me83xakcblJWdaW/D2rLJAJH3m6LFm8lBqyUgDX5t/etob6CpDuYHu5D1J3XINOj/+aLAcadq6qlh70PMZS3zYffUu3JlzaD2amlSHIT8b5YXFc=
file: packages/server/cli-* file:
- release/*.tar.gz
- release/*.zip
on: on:
repo: codercom/code-server repo: codercom/code-server
branch: master branch: master

View File

@ -260,4 +260,30 @@ const ensurePatched = register("vscode:patch", async (runner) => {
} }
}); });
register("package", async (runner, releaseTag) => {
if (!releaseTag) {
throw new Error("Please specify the release tag.");
}
const releasePath = path.resolve(__dirname, "../release");
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-${os.platform()}-${os.arch()}`);
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 os.platform() === "linux"
? runner.execute("tar", ["-cvzf", `${archiveName}.tar.gz`, `${archiveName}`])
: runner.execute("zip", ["-r", `${archiveName}.zip`, `${archiveName}`]);
});
run(); run();

View File

@ -40,7 +40,8 @@ const execute = (command: string, args: string[] = [], options: cp.SpawnOptions,
return prom; return prom;
}; };
export type TaskFunction = (runner: Runner) => void | Promise<void>; // tslint:disable-next-line no-any
export type TaskFunction = (runner: Runner, ...args: any[]) => void | Promise<void>;
export interface Runner { export interface Runner {
cwd: string; cwd: string;
@ -95,7 +96,7 @@ export const run = (name: string = process.argv[2]): void | Promise<void> => {
env: env as NodeJS.ProcessEnv, env: env as NodeJS.ProcessEnv,
}, log); }, log);
}, },
}); }, ...process.argv.slice(3));
if (prom) { if (prom) {
activated.set(name, prom); activated.set(name, prom);

View File

@ -14,16 +14,17 @@ fs.writeFileSync(shimPath, shimContent);
const nexe = require("nexe"); const nexe = require("nexe");
const target = `${os.platform()}-${os.arch()}`;
nexe.compile({ nexe.compile({
debugBundle: true, debugBundle: true,
input: path.join(__dirname, "../out/cli.js"), input: path.join(__dirname, "../out/cli.js"),
output: `cli-${process.env.TRAVIS_OS_NAME || os.platform()}`, output: `cli-${target}`,
targets: [os.platform()], targets: [target],
/** /**
* To include native extensions, do NOT install node_modules for each one. They * To include native extensions, do NOT install node_modules for each one. They
* are not required as each extension is built using webpack. * are not required as each extension is built using webpack.
*/ */
resources: [ resources: [
path.join(__dirname, "../package.json"), path.join(__dirname, "../package.json"),
path.join(__dirname, "../build/**/*"), path.join(__dirname, "../build/**/*"),
], ],

View File

@ -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 // TODO: fill in appropriate doc url
logger.info("Additional documentation: http://github.com/codercom/code-server"); 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)); logger.info("Initializing", field("data-dir", dataDir), field("working-dir", workingDir), field("log-dir", logDir));

View File

@ -24,7 +24,7 @@ module.exports = merge(
}, },
resolve: { resolve: {
alias: { alias: {
"node-pty": "node-pty-prebuilt", "node-pty": "node-pty-prebuilt",
}, },
}, },
externals: ["tslib", "trash"], externals: ["tslib", "trash"],

View File

@ -118,6 +118,7 @@ module.exports = (options = {}) => ({
"process.env.NODE_ENV": `"${environment}"`, "process.env.NODE_ENV": `"${environment}"`,
"process.env.LOG_LEVEL": `"${process.env.LOG_LEVEL || ""}"`, "process.env.LOG_LEVEL": `"${process.env.LOG_LEVEL || ""}"`,
"process.env.SERVICE_URL": `"${process.env.SERVICE_URL || ""}"`, "process.env.SERVICE_URL": `"${process.env.SERVICE_URL || ""}"`,
"process.env.VERSION": `"${process.env.VERSION || ""}"`,
}), }),
], ],
stats: { stats: {