Skip to content

Enable deploying from 'main' branch #4702

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 1 commit into from
Jul 21, 2020
Merged
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
24 changes: 22 additions & 2 deletions tasks/release/release-p5.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,34 @@

const open = require('open');
const spawn = require('child_process').spawnSync;
const simpleGit = require('simple-git/promise');

module.exports = function(grunt) {
// Register the Release Task
grunt.registerTask(
'release-p5',
'Drafts and Publishes a fresh release of p5.js',
function(args) {
async function(args) {
const done = this.async();

// Check we are currently on the 'main' branch, refuse to continue
// if not and preview is not true.
// This section should be removed once support for 'main' branch
// is added to np
const git = simpleGit();
const branches = await git.branchLocal();
if (branches.current !== 'main' && !grunt.option('preview')) {
console.log('Not on "main" branch, refusing to deploy.');
console.log('Preview the release step with the "--preview" flag.');
done();
return;
}

spawn(
'npx np',
grunt.option('preview') ? ['--any-branch', '--preview'] : [],
grunt.option('preview')
? ['--any-branch', '--preview']
: ['--any-branch'],
{
stdio: 'inherit',
shell: true
Expand Down Expand Up @@ -45,6 +63,8 @@ module.exports = function(grunt) {
// 3. Push the docs out to the website
grunt.task.run('yui');
grunt.task.run('release-docs');

done();
}
);
};