mirror of
https://github.com/GenZmeY/casper-i18n.git
synced 2024-11-10 02:28:02 +00:00
Updated release script
no issue
This commit is contained in:
parent
14f7cc4e31
commit
31d43860ac
@ -1,6 +1,5 @@
|
|||||||
{
|
{
|
||||||
"github": {
|
"github": {
|
||||||
"username": "<username>",
|
|
||||||
"token": "<gh-personal-access-token>"
|
"token": "<gh-personal-access-token>"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
114
gulpfile.js
114
gulpfile.js
@ -22,7 +22,6 @@ const easyimport = require('postcss-easy-import');
|
|||||||
|
|
||||||
const REPO = 'TryGhost/Casper';
|
const REPO = 'TryGhost/Casper';
|
||||||
const REPO_READONLY = 'TryGhost/Casper';
|
const REPO_READONLY = 'TryGhost/Casper';
|
||||||
const USER_AGENT = 'Casper';
|
|
||||||
const CHANGELOG_PATH = path.join(process.cwd(), '.', 'changelog.md');
|
const CHANGELOG_PATH = path.join(process.cwd(), '.', 'changelog.md');
|
||||||
|
|
||||||
function serve(done) {
|
function serve(done) {
|
||||||
@ -94,25 +93,6 @@ const hbsWatcher = () => watch(['*.hbs', 'partials/**/*.hbs'], hbs);
|
|||||||
const watcher = parallel(cssWatcher, hbsWatcher);
|
const watcher = parallel(cssWatcher, hbsWatcher);
|
||||||
const build = series(css, js);
|
const build = series(css, js);
|
||||||
|
|
||||||
const previousRelease = () => {
|
|
||||||
return releaseUtils
|
|
||||||
.releases
|
|
||||||
.get({
|
|
||||||
userAgent: USER_AGENT,
|
|
||||||
uri: `https://api.github.com/repos/${REPO_READONLY}/releases`
|
|
||||||
})
|
|
||||||
.then(response => {
|
|
||||||
if (!response || !response.length) {
|
|
||||||
console.log('No releases found. Skipping...');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let prevVersion = response[0].tag_name || response[0].name;
|
|
||||||
console.log(`Previous version ${prevVersion}`);
|
|
||||||
return prevVersion;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.build = build;
|
exports.build = build;
|
||||||
exports.zip = series(build, zipper);
|
exports.zip = series(build, zipper);
|
||||||
exports.default = series(build, serve, watcher);
|
exports.default = series(build, serve, watcher);
|
||||||
@ -137,52 +117,72 @@ exports.release = () => {
|
|||||||
config = null;
|
config = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config || !config.github || !config.github.username || !config.github.token) {
|
if (!config || !config.github || !config.github.token) {
|
||||||
console.log('Please copy config.example.json and configure Github token.');
|
console.log('Please copy config.example.json and configure Github token.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
inquirer.prompt([{
|
let compatibleWithGhost;
|
||||||
|
|
||||||
|
return inquirer.prompt([{
|
||||||
type: 'input',
|
type: 'input',
|
||||||
name: 'compatibleWithGhost',
|
name: 'compatibleWithGhost',
|
||||||
message: 'Which version of Ghost is it compatible with?',
|
message: 'Which version of Ghost is it compatible with?',
|
||||||
default: '3.0.0'
|
default: '3.0.0'
|
||||||
}]).then(result => {
|
}])
|
||||||
let compatibleWithGhost = result.compatibleWithGhost;
|
.then(result => {
|
||||||
|
compatibleWithGhost = result.compatibleWithGhost;
|
||||||
|
return Promise.resolve();
|
||||||
|
})
|
||||||
|
.then(() => releaseUtils.releases.get({
|
||||||
|
userAgent: 'Casper',
|
||||||
|
uri: `https://api.github.com/repos/${REPO_READONLY}/releases`
|
||||||
|
}))
|
||||||
|
.then((response) => {
|
||||||
|
if (!response || !response.length) {
|
||||||
|
console.log('No releases found. Skipping...');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
previousRelease().then(previousVersion => {
|
let previousVersion = response[0].tag_name || response[0].name;
|
||||||
const changelog = new releaseUtils.Changelog({
|
console.log(`Previous version: ${previousVersion}`);
|
||||||
changelogPath: CHANGELOG_PATH,
|
return Promise.resolve(previousVersion);
|
||||||
folder: path.join(process.cwd(), '.')
|
})
|
||||||
});
|
.then((previousVersion) => {
|
||||||
|
const changelog = new releaseUtils.Changelog({
|
||||||
changelog
|
changelogPath: CHANGELOG_PATH,
|
||||||
.write({
|
folder: path.join(process.cwd(), '.')
|
||||||
githubRepoPath: `https://github.com/${REPO}`,
|
|
||||||
lastVersion: previousVersion
|
|
||||||
})
|
|
||||||
.sort()
|
|
||||||
.clean();
|
|
||||||
|
|
||||||
releaseUtils
|
|
||||||
.releases
|
|
||||||
.create({
|
|
||||||
draft: true,
|
|
||||||
preRelease: false,
|
|
||||||
tagName: newVersion,
|
|
||||||
releaseName: newVersion,
|
|
||||||
userAgent: USER_AGENT,
|
|
||||||
uri: `https://api.github.com/repos/${REPO}/releases`,
|
|
||||||
github: {
|
|
||||||
username: config.github.username,
|
|
||||||
token: config.github.token
|
|
||||||
},
|
|
||||||
content: [`**Compatible with Ghost ≥ ${compatibleWithGhost}**\n\n`],
|
|
||||||
changelogPath: CHANGELOG_PATH
|
|
||||||
})
|
|
||||||
.then(response => {
|
|
||||||
console.log(`\nRelease draft generated: ${response.releaseUrl}\n`);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
changelog
|
||||||
|
.write({
|
||||||
|
githubRepoPath: `https://github.com/${REPO}`,
|
||||||
|
lastVersion: previousVersion
|
||||||
|
})
|
||||||
|
.sort()
|
||||||
|
.clean();
|
||||||
|
|
||||||
|
return Promise.resolve();
|
||||||
|
})
|
||||||
|
.then(() => releaseUtils.releases.create({
|
||||||
|
draft: true,
|
||||||
|
preRelease: false,
|
||||||
|
tagName: newVersion,
|
||||||
|
releaseName: newVersion + '+banana',
|
||||||
|
userAgent: 'Casper',
|
||||||
|
uri: `https://api.github.com/repos/${REPO}/releases`,
|
||||||
|
github: {
|
||||||
|
token: config.github.token
|
||||||
|
},
|
||||||
|
content: [`**Compatible with Ghost ≥ ${compatibleWithGhost}**\n\n`],
|
||||||
|
changelogPath: CHANGELOG_PATH
|
||||||
|
}))
|
||||||
|
.then((response) => {
|
||||||
|
console.log(`\nRelease draft generated: ${response.releaseUrl}\n`);
|
||||||
|
return Promise.resolve();
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error(err);
|
||||||
|
process.exit(1);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user