Skip to content

Commit 5478f3a

Browse files
committed
Add task for packaging release
1 parent 4028e33 commit 5478f3a

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
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

build/tasks.ts

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

263+
register("package", async (runner, releaseTag, binLocation) => {
264+
if (!releaseTag) {
265+
throw new Error("Please specify the release tag.");
266+
}
267+
if (!binLocation) {
268+
throw new Error("Please specify the location of the binaries.");
269+
}
270+
271+
const releasePath = path.resolve(__dirname, `../release/${releaseTag}`);
272+
fse.removeSync(releasePath);
273+
fse.mkdirpSync(releasePath);
274+
275+
await Promise.all([{
276+
bin: "cli-linux",
277+
name: "linux",
278+
}, {
279+
bin: "cli-osx",
280+
name: "apple-darwin",
281+
}].map(async (pkg) => {
282+
const archiveName = `code-server-${releaseTag}-x86_64-${pkg.name}`;
283+
const archiveDir = path.join(releasePath, archiveName);
284+
fse.mkdirpSync(archiveDir);
285+
286+
const binaryPath = path.join(binLocation, pkg.bin);
287+
const binaryDestination = path.join(archiveDir, "code-server");
288+
fse.copySync(binaryPath, binaryDestination);
289+
fs.chmodSync(binaryDestination, "755");
290+
["README.md", "LICENSE"].forEach((fileName) => {
291+
fse.copySync(path.resolve(__dirname, `../${fileName}`), path.join(archiveDir, fileName));
292+
});
293+
294+
runner.cwd = releasePath;
295+
await Promise.all([
296+
runner.execute("tar", ["-cvzf", `${archiveName}.tar.gz`, `${archiveName}`]),
297+
runner.execute("zip", ["-r", `${archiveName}.zip`, `${archiveName}`]),
298+
]);
299+
}));
300+
});
301+
263302
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);

0 commit comments

Comments
 (0)