1
0
mirror of https://git.tuxpa.in/a/code-server.git synced 2024-12-27 20:55:25 +00:00

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
out
.DS_Store
release

View File

@ -1,6 +1,8 @@
language: node_js
node_js:
- 8.9.3
env:
- VERSION="1.31.1-$TRAVIS_BUILD_NUMBER"
matrix:
include:
- os: linux
@ -12,22 +14,24 @@ before_install:
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"
- 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=
file: packages/server/cli-*
file:
- release/*.tar.gz
- release/*.zip
on:
repo: codercom/code-server
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();

View File

@ -40,7 +40,8 @@ const execute = (command: string, args: string[] = [], options: cp.SpawnOptions,
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 {
cwd: string;
@ -95,7 +96,7 @@ export const run = (name: string = process.argv[2]): void | Promise<void> => {
env: env as NodeJS.ProcessEnv,
}, log);
},
});
}, ...process.argv.slice(3));
if (prom) {
activated.set(name, prom);

View File

@ -14,16 +14,17 @@ fs.writeFileSync(shimPath, shimContent);
const nexe = require("nexe");
const target = `${os.platform()}-${os.arch()}`;
nexe.compile({
debugBundle: true,
input: path.join(__dirname, "../out/cli.js"),
output: `cli-${process.env.TRAVIS_OS_NAME || 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/**/*"),
],

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
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));

View File

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

View File

@ -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: {