Skip to content

Commit 994531d

Browse files
authored
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
1 parent 8916cb9 commit 994531d

File tree

8 files changed

+48
-14
lines changed

8 files changed

+48
-14
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ node_modules
33
dist
44
out
55
.DS_Store
6+
release

.travis.yml

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
language: node_js
22
node_js:
33
- 8.9.3
4+
env:
5+
- VERSION="1.31.1-$TRAVIS_BUILD_NUMBER"
46
matrix:
57
include:
68
- os: linux
@@ -12,22 +14,24 @@ before_install:
1214
script:
1315
- scripts/build.sh
1416
before_deploy:
15-
- export TRAVIS_TAG="1.31.1-$TRAVIS_BUILD_NUMBER"
16-
- echo "$TRAVIS_TAG" "$TRAVIS_COMMIT"
17+
- echo "$VERSION" "$TRAVIS_COMMIT"
1718
- git config --local user.name "$USER_NAME"
1819
- git config --local user.email "$USER_EMAIL"
19-
- git tag "$TRAVIS_TAG" "$TRAVIS_COMMIT"
20+
- git tag "$VERSION" "$TRAVIS_COMMIT"
21+
- yarn task package "$VERSION"
2022
deploy:
2123
provider: releases
2224
file_glob: true
2325
draft: true
24-
tag_name: $TRAVIS_TAG
25-
target_commitish: $TRAVIS_COMMIT
26-
name: $TRAVIS_TAG
26+
tag_name: "$VERSION"
27+
target_commitish: "$TRAVIS_COMMIT"
28+
name: "$VERSION"
2729
skip_cleanup: true
2830
api_key:
2931
secure: YL/x24KjYjgYXPcJWk3FV7FGxI79Mh6gBECQEcdlf3fkLEoKFVgzHBoUNWrFPzyR4tgLyWNAgcpD9Lkme1TRWTom7UPjXcwMNyLcLa+uec7ciSAnYD9ntLTpiCuPDD1u0LtRGclSi/EHQ+F8YVq+HZJpXTsJeAmOmihma3GVbGKSZr+BRum+0YZSG4w+o4TOlYzw/4bLWS52MogZcwpjd+hemBbgXLuGU2ziKv2vEKCZFbEeA16II4x1WLI4mutDdCeh7+3aLzGLwDa49NxtsVYNjyNFF75JhCTCNA55e2YMiLz9Uq69IXe/mi5F7xUaFfhIqqLNyKBnKeEOzu3dYnc+8n3LjnQ+00PmkF05nx9kBn3UfV1kwQGh6QbyDmTtBP07rtUMyI14aeQqHjxsaVRdMnwj9Q2DjXRr8UDqESZF0rmK3pHCXS2fBhIzLE8tLVW5Heiba2pQRFMHMZW+KBE97FzcFh7is90Ait3T8enfcd/PWFPYoBejDAdjwxwOkezh5N5ZkYquEfDYuWrFi6zRFCktsruaAcA+xGtTf9oilBBzUqu8Ie+YFWH5me83xakcblJWdaW/D2rLJAJH3m6LFm8lBqyUgDX5t/etob6CpDuYHu5D1J3XINOj/+aLAcadq6qlh70PMZS3zYffUu3JlzaD2amlSHIT8b5YXFc=
30-
file: packages/server/cli-*
32+
file:
33+
- release/*.tar.gz
34+
- release/*.zip
3135
on:
3236
repo: codercom/code-server
3337
branch: master

build/tasks.ts

+26
Original file line numberDiff line numberDiff line change
@@ -260,4 +260,30 @@ const ensurePatched = register("vscode:patch", async (runner) => {
260260
}
261261
});
262262

263+
register("package", async (runner, releaseTag) => {
264+
if (!releaseTag) {
265+
throw new Error("Please specify the release tag.");
266+
}
267+
268+
const releasePath = path.resolve(__dirname, "../release");
269+
270+
const archiveName = `code-server-${releaseTag}-${os.platform()}-${os.arch()}`;
271+
const archiveDir = path.join(releasePath, archiveName);
272+
fse.removeSync(archiveDir);
273+
fse.mkdirpSync(archiveDir);
274+
275+
const binaryPath = path.join(__dirname, `../packages/server/cli-${os.platform()}-${os.arch()}`);
276+
const binaryDestination = path.join(archiveDir, "code-server");
277+
fse.copySync(binaryPath, binaryDestination);
278+
fs.chmodSync(binaryDestination, "755");
279+
["README.md", "LICENSE"].forEach((fileName) => {
280+
fse.copySync(path.resolve(__dirname, `../${fileName}`), path.join(archiveDir, fileName));
281+
});
282+
283+
runner.cwd = releasePath;
284+
await os.platform() === "linux"
285+
? runner.execute("tar", ["-cvzf", `${archiveName}.tar.gz`, `${archiveName}`])
286+
: runner.execute("zip", ["-r", `${archiveName}.zip`, `${archiveName}`]);
287+
});
288+
263289
run();

packages/runner/src/runner.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ const execute = (command: string, args: string[] = [], options: cp.SpawnOptions,
4040
return prom;
4141
};
4242

43-
export type TaskFunction = (runner: Runner) => void | Promise<void>;
43+
// tslint:disable-next-line no-any
44+
export type TaskFunction = (runner: Runner, ...args: any[]) => void | Promise<void>;
4445

4546
export interface Runner {
4647
cwd: string;
@@ -95,7 +96,7 @@ export const run = (name: string = process.argv[2]): void | Promise<void> => {
9596
env: env as NodeJS.ProcessEnv,
9697
}, log);
9798
},
98-
});
99+
}, ...process.argv.slice(3));
99100

100101
if (prom) {
101102
activated.set(name, prom);

packages/server/scripts/nexe.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,17 @@ fs.writeFileSync(shimPath, shimContent);
1414

1515
const nexe = require("nexe");
1616

17+
const target = `${os.platform()}-${os.arch()}`;
1718
nexe.compile({
1819
debugBundle: true,
1920
input: path.join(__dirname, "../out/cli.js"),
20-
output: `cli-${process.env.TRAVIS_OS_NAME || os.platform()}`,
21-
targets: [os.platform()],
21+
output: `cli-${target}`,
22+
targets: [target],
2223
/**
2324
* To include native extensions, do NOT install node_modules for each one. They
2425
* are not required as each extension is built using webpack.
2526
*/
26-
resources: [
27+
resources: [
2728
path.join(__dirname, "../package.json"),
2829
path.join(__dirname, "../build/**/*"),
2930
],

packages/server/src/cli.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export class Entry extends Command {
114114
}
115115
}
116116

117-
logger.info("\u001B[1mcode-server v1.0.0");
117+
logger.info(`\u001B[1mcode-server ${process.env.VERSION ? `v${process.env.VERSION}` : "development"}`);
118118
// TODO: fill in appropriate doc url
119119
logger.info("Additional documentation: http://github.com/codercom/code-server");
120120
logger.info("Initializing", field("data-dir", dataDir), field("working-dir", workingDir), field("log-dir", logDir));

packages/server/webpack.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module.exports = merge(
2424
},
2525
resolve: {
2626
alias: {
27-
"node-pty": "node-pty-prebuilt",
27+
"node-pty": "node-pty-prebuilt",
2828
},
2929
},
3030
externals: ["tslib", "trash"],

scripts/webpack.general.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ module.exports = (options = {}) => ({
118118
"process.env.NODE_ENV": `"${environment}"`,
119119
"process.env.LOG_LEVEL": `"${process.env.LOG_LEVEL || ""}"`,
120120
"process.env.SERVICE_URL": `"${process.env.SERVICE_URL || ""}"`,
121+
"process.env.VERSION": `"${process.env.VERSION || ""}"`,
121122
}),
122123
],
123124
stats: {

0 commit comments

Comments
 (0)