mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Create a PR for website update after a release
This commit is contained in:
+19
-1
@@ -5,6 +5,7 @@
|
||||
|
||||
const cp = require('child_process');
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
|
||||
// Setup auth
|
||||
@@ -18,8 +19,9 @@ if (isDryRun) {
|
||||
const changedFiles = getChangedFilesInCommit('HEAD');
|
||||
|
||||
// Publish xterm if any files were changed outside of the addons directory
|
||||
let isStableRelease = false;
|
||||
if (changedFiles.some(e => e.search(/^addons\//) === -1)) {
|
||||
checkAndPublishPackage(path.resolve(__dirname, '..'));
|
||||
isStableRelease = checkAndPublishPackage(path.resolve(__dirname, '..'));
|
||||
}
|
||||
|
||||
// Publish addons if any files were changed inside of the addon
|
||||
@@ -39,6 +41,11 @@ addonPackageDirs.forEach(p => {
|
||||
}
|
||||
});
|
||||
|
||||
// Publish website if it's a stable release
|
||||
if (isStableRelease) {
|
||||
updateWebsite();
|
||||
}
|
||||
|
||||
function checkAndPublishPackage(packageDir) {
|
||||
const packageJson = require(path.join(packageDir, 'package.json'));
|
||||
|
||||
@@ -76,6 +83,8 @@ function checkAndPublishPackage(packageDir) {
|
||||
}
|
||||
|
||||
console.groupEnd();
|
||||
|
||||
return isStableRelease;
|
||||
}
|
||||
|
||||
function getNextBetaVersion(packageJson) {
|
||||
@@ -115,3 +124,12 @@ function getChangedFilesInCommit(commit) {
|
||||
const changedFiles = output.split('\n').filter(e => e.length > 0);
|
||||
return changedFiles;
|
||||
}
|
||||
|
||||
function updateWebsite() {
|
||||
console.log('Updating website');
|
||||
const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'website-'));
|
||||
const packageJson = require(path.join(path.resolve(__dirname, '..'), 'package.json'));
|
||||
if (!isDryRun) {
|
||||
cp.spawnSync('sh', [path.join(__dirname, 'update-website.sh'), packageJson.version], { cwd, stdio: [process.stdin, process.stdout, process.stderr] });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Name the arguments
|
||||
VERSION=$1
|
||||
|
||||
# Clone docs repo and update the documentation
|
||||
git clone https://github.com/xtermjs/xtermjs.org
|
||||
cd xtermjs.org
|
||||
yarn
|
||||
./bin/update-docs
|
||||
|
||||
# Add changes to index and only proceed if there are changes to commit
|
||||
touch test-file
|
||||
git add .
|
||||
if ! git diff-index --quiet HEAD --; then
|
||||
|
||||
# Delete the upstream branch if it exists for some reason
|
||||
export BRANCH_NAME=update-$VERSION
|
||||
git branch -D $BRANCH_NAME || true
|
||||
git push origin :$BRANCH_NAME || true
|
||||
|
||||
# Create commit and push it to update-x.y.z
|
||||
git checkout -b $BRANCH_NAME
|
||||
git config --global user.name Daniel Imms
|
||||
git config --global user.email tyriar@tyriar.com
|
||||
git commit -m 'Update docs for v$VERSION'
|
||||
git push --set-upstream origin update-4.2.0
|
||||
git push -f
|
||||
|
||||
# Create a PR in the GitHub repo
|
||||
curl \
|
||||
-H "Authorization: token $GITHUB_TOKEN" \
|
||||
-X POST \
|
||||
-d "{\"title\":\"Update docs for v$VERSION\",\"base\":\"master\",\"head\":\"xtermjs:$BRANCH_NAME\"}" \
|
||||
https://api.github.com/repos/xtermjs/xtermjs.org/pulls
|
||||
|
||||
else
|
||||
|
||||
echo "No changes to commit"
|
||||
|
||||
fi
|
||||
Reference in New Issue
Block a user