Skip to content

Add task for packaging release #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ node_modules
dist
out
.DS_Store
release
18 changes: 11 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
language: node_js
node_js:
- 8.9.3
env:
- VERSION="1.31.1-$TRAVIS_BUILD_NUMBER"
matrix:
include:
- os: linux
Expand All @@ -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
26 changes: 26 additions & 0 deletions build/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`]);
Copy link
Contributor

@MichaelDesantis MichaelDesantis Mar 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For our use case, is tar preferable to zip? And if so, is there any way for us to set a conditional based on whether or not said commands are installed rather than OS platform? Or is it inconsequential and/or not worth the time?

Copy link
Member Author

@code-asher code-asher Mar 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal is to provide tarballs for Linux builds and zips for Mac & Windows builds. This runs in the CI and is what will be available for download on the releases page.

});

run();
5 changes: 3 additions & 2 deletions packages/runner/src/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions packages/server/scripts/nexe.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/**/*"),
],
Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion packages/server/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = merge(
},
resolve: {
alias: {
"node-pty": "node-pty-prebuilt",
"node-pty": "node-pty-prebuilt",
},
},
externals: ["tslib", "trash"],
Expand Down
1 change: 1 addition & 0 deletions scripts/webpack.general.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down