mirror of
https://github.com/ViViDboarder/Vivid-Casper.git
synced 2024-12-22 19:47:38 +00:00
Removed the need for config.json when releasing
no issue - we previously needed a config.json to provide the GitHub token for publishing new Casper releases - this commit removes the need for this file by pulling the token from the environment variable, which everyone in the Core team has set up
This commit is contained in:
parent
44e33120cb
commit
f12ce05454
60
gulpfile.js
60
gulpfile.js
@ -96,10 +96,10 @@ exports.build = build;
|
||||
exports.zip = series(build, zipper);
|
||||
exports.default = series(build, serve, watcher);
|
||||
|
||||
exports.release = () => {
|
||||
exports.release = async () => {
|
||||
// @NOTE: https://yarnpkg.com/lang/en/docs/cli/version/
|
||||
// require(./package.json) can run into caching issues, this re-reads from file everytime on release
|
||||
var packageJSON = JSON.parse(fs.readFileSync('./package.json'));
|
||||
let packageJSON = JSON.parse(fs.readFileSync('./package.json'));
|
||||
const newVersion = packageJSON.version;
|
||||
|
||||
if (!newVersion || newVersion === '') {
|
||||
@ -109,45 +109,36 @@ exports.release = () => {
|
||||
|
||||
console.log(`\nCreating release for ${newVersion}...`);
|
||||
|
||||
let config;
|
||||
try {
|
||||
config = require('./config');
|
||||
} catch (err) {
|
||||
config = null;
|
||||
}
|
||||
const githubToken = process.env.GST_TOKEN;
|
||||
|
||||
if (!config || !config.github || !config.github.token) {
|
||||
console.log('Please copy config.example.json and configure Github token.');
|
||||
if (githubToken) {
|
||||
console.log('Please configure your environment with a Github token located in GST_TOKEN');
|
||||
return;
|
||||
}
|
||||
|
||||
let compatibleWithGhost;
|
||||
|
||||
return inquirer.prompt([{
|
||||
try {
|
||||
const result = await inquirer.prompt([{
|
||||
type: 'input',
|
||||
name: 'compatibleWithGhost',
|
||||
message: 'Which version of Ghost is it compatible with?',
|
||||
default: '3.0.0'
|
||||
}])
|
||||
.then(result => {
|
||||
compatibleWithGhost = result.compatibleWithGhost;
|
||||
return Promise.resolve();
|
||||
})
|
||||
.then(() => releaseUtils.releases.get({
|
||||
}]);
|
||||
|
||||
const compatibleWithGhost = result.compatibleWithGhost;
|
||||
|
||||
const releasesResponse = await releaseUtils.releases.get({
|
||||
userAgent: 'Casper',
|
||||
uri: `https://api.github.com/repos/${REPO_READONLY}/releases`
|
||||
}))
|
||||
.then((response) => {
|
||||
if (!response || !response.length) {
|
||||
});
|
||||
|
||||
if (!releasesResponse || !releasesResponse) {
|
||||
console.log('No releases found. Skipping...');
|
||||
return;
|
||||
}
|
||||
|
||||
let previousVersion = response[0].tag_name || response[0].name;
|
||||
let previousVersion = releasesResponse[0].tag_name || releasesResponse[0].name;
|
||||
console.log(`Previous version: ${previousVersion}`);
|
||||
return Promise.resolve(previousVersion);
|
||||
})
|
||||
.then((previousVersion) => {
|
||||
|
||||
const changelog = new releaseUtils.Changelog({
|
||||
changelogPath: CHANGELOG_PATH,
|
||||
folder: path.join(process.cwd(), '.')
|
||||
@ -161,9 +152,7 @@ exports.release = () => {
|
||||
.sort()
|
||||
.clean();
|
||||
|
||||
return Promise.resolve();
|
||||
})
|
||||
.then(() => releaseUtils.releases.create({
|
||||
const newReleaseResponse = await releaseUtils.releases.create({
|
||||
draft: true,
|
||||
preRelease: false,
|
||||
tagName: newVersion,
|
||||
@ -171,17 +160,14 @@ exports.release = () => {
|
||||
userAgent: 'Casper',
|
||||
uri: `https://api.github.com/repos/${REPO}/releases`,
|
||||
github: {
|
||||
token: config.github.token
|
||||
token: githubToken
|
||||
},
|
||||
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.log(`\nRelease draft generated: ${newReleaseResponse.releaseUrl}\n`);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user