Skip to content

Commit

Permalink
Merge 805c02f into 29ff74e
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyriar committed Jan 2, 2019
2 parents 29ff74e + 805c02f commit f2e6c7c
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 1 deletion.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ lib/test/
docs/
/.idea/
.vscode/
bin/
build/
fixtures/
coverage/
Expand Down
24 changes: 24 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,27 @@ jobs:
- script: |
yarn lint
displayName: 'Lint'
- job: Release
dependsOn:
- Linux
- macOS
- Windows
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
pool:
vmImage: 'ubuntu-16.04'
steps:
- task: NodeTool@0
inputs:
versionSpec: '8.x'
displayName: 'Install Node.js'
- task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2
inputs:
versionSpec: "1.9.4"
displayName: 'Install Yarn'
- script: |
yarn
displayName: 'Install dependencies and build'
- script: |
NPM_AUTH_TOKEN="$(NPM_AUTH_TOKEN)" node ./bin/publish.js
displayName: 'Publish to npm'
49 changes: 49 additions & 0 deletions bin/publish.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* Copyright (c) 2019 The xterm.js authors. All rights reserved.
* @license MIT
*/

const cp = require('child_process');
const fs = require('fs');
const path = require('path');
const packageJson = require('../package.json');

// Setup auth
fs.writeFileSync(`${process.env['HOME']}/.npmrc`, `//registry.npmjs.org/:_authToken=${process.env['NPM_AUTH_TOKEN']}`);

// Get the version
const tag = 'beta'
const nextVersion = getNextVersion(tag);
console.log(`Publishing version: ${nextVersion}`);

// Set the version in package.json
const packageJsonFile = path.resolve(__dirname, '..', 'package.json');
let packageJsonRaw = fs.readFileSync(packageJsonFile).toString();
packageJsonRaw = packageJsonRaw.replace(/("version": ")3.10.0(")/, `$1${nextVersion}$2`);
fs.writeFileSync(packageJsonFile, packageJsonRaw);

// Publish
const result = cp.spawn('npm', ['publish', '--tag', tag], {
stdio: 'inherit'
});
result.on('exit', code => process.exit(code));

function getNextVersion(tag) {
if (!/^[0-9]+\.[0-9]+\.[0-9]+$/.exec(packageJson.version)) {
console.error('The package.json version must be of the form x.y.z');
process.exit(1);
}
const publishedVersions = getPublishedVersions(packageJson.version, tag);
if (publishedVersions.length === 0) {
return `${packageJson.version}-${tag}1`;
}
const latestPublishedVersion = publishedVersions.sort((a, b) => b.localeCompare(a))[0];
const latestTagVersion = parseInt(latestPublishedVersion.substr(latestPublishedVersion.search(/[0-9]+$/)), 10);
return `${packageJson.version}-${tag}${latestTagVersion + 1}`;
}

function getPublishedVersions(version, tag) {
const versionsProcess = cp.spawnSync('npm', ['view', 'xterm', 'versions', '--json']);
const versionsJson = JSON.parse(versionsProcess.stdout);
return versionsJson.filter(v => !v.search(new RegExp(`${version}-${tag}[0-9]+`)));
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "xterm",
"description": "Full xterm terminal, in your browser",
"version": "3.9.0",
"version": "3.10.0",
"main": "lib/public/Terminal.js",
"types": "typings/xterm.d.ts",
"repository": "https://github.com/xtermjs/xterm.js",
Expand Down

0 comments on commit f2e6c7c

Please sign in to comment.