This repository was archived by the owner on Apr 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Gulp release #104
Open
lejoe
wants to merge
13
commits into
master
Choose a base branch
from
gulp-release
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Gulp release #104
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
a20d1e6
First concept of the release task
lejoe ba2d44e
Refactors the release task
lejoe f667385
Improves the error logging of npm version
lejoe 9cca7ad
Adds propper error exits for the release task
lejoe 937908e
Removes error catching
lejoe ee15b6b
Renames cb to done for consistency
lejoe 2ecc307
Removes the spaw options.
lejoe fcb1727
Adds display of next steps after a version bump
lejoe 46b2ffb
Adds the npm log to git ignore
lejoe 6c3bb7f
Better error logging of the npm errors
lejoe 2e5132e
Re-instore the branch proof before release
lejoe a7d4d01
updates the current skeleton version
lejoe 1e82149
Corrects a typo in a function name
lejoe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,3 +4,4 @@ node_modules | |
| .DS_Store | ||
| *.orig | ||
| .tmp | ||
| npm-debug.log | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| 'use strict'; | ||
|
|
||
| var gulp = require('gulp'); | ||
| var $ = require('gulp-load-plugins')(); | ||
| var logger = require('gulplog'); | ||
| var inquirer = require('inquirer'); | ||
| var exec = require('child_process').spawn; | ||
|
|
||
| var allowedBranch = 'master'; | ||
| var bumpTypeQuestion = { | ||
| type: 'list', | ||
| name: 'bump', | ||
| message: 'What type of bump would you like to do?', | ||
| default: 'minor', | ||
| choices: ['patch', 'minor', 'major'] | ||
| }; | ||
|
|
||
| // Makes sure we do this on the master branch | ||
| var assertBranchAllowed = function(done) { | ||
| $.git.revParse({args:'--abbrev-ref HEAD', quiet: true}, function(err, currentBranch) { | ||
| if (currentBranch != allowedBranch) { | ||
| logger.error('ERR: You need to be on the %s branch to be able to deploy', allowedBranch); | ||
| process.exit(1); | ||
| } | ||
| done(); | ||
| }); | ||
| } | ||
| assertBranchAllowed.displayName = 'Verify branch'; | ||
|
|
||
| // Asks for the bump type | ||
| var askBumpType = function(done) { | ||
| inquirer.prompt([bumpTypeQuestion], function( answers ) { | ||
| if (answers !== null && answers[bumpTypeQuestion.name] !== null) { | ||
| bumpVersion(answers[bumpTypeQuestion.name], done); | ||
| } else { | ||
| logger.error('ERR: There was an error with the provided bump type'); | ||
| process.exit(1); | ||
| } | ||
| }); | ||
| } | ||
| askBumpType.displayName = 'Ask bump type'; | ||
|
|
||
| // Bumps the version of the project | ||
| var bumpVersion = function(bumpType, done) { | ||
| var p = exec('npm', ['version', bumpType], { cwd: process.cwd()}); | ||
| var stderr = ''; | ||
|
|
||
| p.stderr.on('data', function(buf) { | ||
| stderr += buf; | ||
| }); | ||
|
|
||
| p.on('close', function(code){ | ||
| if (code !== 0) { | ||
| logger.error('ERR: There was an error running \'npm version\' && git push && git push --tags:'); | ||
| logger.error('Details:'); | ||
| logger.error('%s', stderr); | ||
| process.exit(1); | ||
| } else { | ||
| done(); | ||
| } | ||
| }); | ||
| } | ||
| bumpVersion.displayName = 'Bump Version'; | ||
|
|
||
| // Display the next release steps | ||
| var displayNextReleaseSteps = function(done) { | ||
| logger.info('The project now has a new version and was pushed to master'); | ||
| logger.info('Next steps:'); | ||
| logger.info(' 1. Got to github and create a pull request from master to release'); | ||
| logger.info(' 2. Somebody else should review the PR and merge it'); | ||
| logger.info(' 3. The CI will publish it and create a release on github'); | ||
| done(); | ||
| } | ||
| bumpVersion.displayName = 'Display next release steps'; | ||
|
|
||
| // Bumps the version on package.json and commits it locally and pushes to master | ||
| var releaseTask = function(done) { | ||
| return new Promise(gulp.series(assertBranchAllowed, askBumpType, displayNextReleaseSteps)); | ||
| } | ||
| releaseTask.description = 'Bumps the npm version'; | ||
|
|
||
| module.exports = function(gulp, $, config) { | ||
| return releaseTask; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have an actual skeleton release number? Seeing as we had a skeleton 2 branch? We should at least have a major release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All I did was matching to the current release number on github:
https://github.com/ginetta/skeleton/releases
Will take care of proper releases once this is in and the CI part is done