Skip to content

Commit

Permalink
feat(deployment): Added automatic version release process and editorc…
Browse files Browse the repository at this point in the history
…onfig (#81)
  • Loading branch information
fragsalat authored Sep 1, 2017
1 parent 095e083 commit d917683
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 18 deletions.
25 changes: 25 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
; EditorConfig helps developers define and maintain consistent
; coding styles between different editors and IDEs.

; For more visit http://editorconfig.org.
root = true

; Choose between lf or rf on "end_of_line" property
[*]
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{js,css,scss}]
indent_size = 2

[*.html]
indent_style = space

[*.{py,html,md}]
indent_size = 2

[*.md]
trim_trailing_whitespace = true
Empty file added CHANGELOG.md
Empty file.
15 changes: 14 additions & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,20 @@ test:
- gulp lint-sass

deployment:
master:
release:
branch: master
commands:
- gulp bump-version changelog
- git add package.json doc dist
- git commit -m "Bumped version to $(jq -r .version package.json) [skip ci]"
- git tag -f -a $(jq -r .version package.json) -m "Automatic release via CircleCI"
- git push origin $CIRCLE_BRANCH
- gulp release --branch="${CIRCLE_BRANCH}"
- au build:
pwd: styleguide
- au publish --commit ${CIRCLE_SHA1} --repo "${CIRCLE_PROJECT_REPONAME}/${CIRCLE_BRANCH}" --target "${TARGET}":
pwd: styleguide
styleguide:
branch: /.*/
commands:
- au build:
Expand Down
113 changes: 97 additions & 16 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,103 @@
var gulp = require('gulp');
var sass = require('gulp-sass');
var gulpStylelint = require('gulp-stylelint');
const gulp = require('gulp');
const sass = require('gulp-sass');
const gulpStylelint = require('gulp-stylelint');
const runSequence = require('run-sequence');
const conventionalChangelog = require('gulp-conventional-changelog');
const conventionalGitHubReleaser = require('conventional-github-releaser');
const bump = require('gulp-bump');
const argv = require('yargs').argv;
const validBumpTypes = 'major|minor|patch|prerelease'.split('|');
const bumpType = (argv.bump || 'patch').toLowerCase();

if (validBumpTypes.indexOf(bumpType) === -1) {
throw new Error('Unrecognized bump "' + bumpType + '".');
}

const args = {
bump: bumpType,
depth: parseInt(argv.depth || '0', 10),
token: argv.token,
branch: argv.branch
};

const changelogOpts = {
preset: 'angular',
releaseCount: 1,
targetCommitish: args.branch
};

// utilizes the bump plugin to bump the
// semver for the repo
gulp.task('bump-version', () =>
gulp.src(['./package.json'])
.pipe(bump({type: args.bump}))
.pipe(gulp.dest('./'))
);

// generates the CHANGELOG.md file based on commit
// from git commit messages
gulp.task('changelog', () =>
gulp.src(`./CHANGELOG.md`)
.pipe(conventionalChangelog(changelogOpts))
.pipe(gulp.dest('./'))
);

// calls the listed sequence of tasks in order
gulp.task('prepare-release', callback =>
runSequence(
'build',
'lint',
'bump-version',
'changelog',
callback
)
);

gulp.task('release', callback => {
conventionalGitHubReleaser({
type: 'oauth',
token: args.token || process.env.CONVENTIONAL_GITHUB_RELEASER_TOKEN
}, changelogOpts, {}, {}, {}, {}, (err, data) => {
if (err) {
console.error(err.toString());
return callback();
}

if (!data.length) {
console.log('No GitHub releases created because no git tags available to work with.');
return callback();
}

let allRejected = true;
for (let i = data.length - 1; i >= 0; i--) {
if (data[i].state === 'fulfilled') {
allRejected = false;
break;
}
}

if (allRejected) {
console.error(data);
} else {
console.log(data);
}
return callback();
});
});

gulp.task('lint-sass', function() {
return gulp.src(['./*.scss', './custom/*.scss', './components/*.scss', './components/**/*.scss'])
.pipe(gulpStylelint({
reporters: [
{formatter: 'string', console: true}
]
}));
return gulp.src(['./*.scss', './custom/*.scss', './components/*.scss', './components/**/*.scss'])
.pipe(gulpStylelint({
reporters: [
{formatter: 'string', console: true}
]
}));
});

// This is only used to validate the code is able to compile
gulp.task('sass', function () {
return gulp.src('./index.scss')
.pipe(sass().on('error', sass.logError));
});
gulp.task('sass', () =>
gulp.src('./index.scss')
.pipe(sass().on('error', sass.logError))
);

gulp.task('default', function() {
return gulp.parallel('sass', 'lint-sass')
});
gulp.task('default', () => gulp.parallel('sass', 'lint-sass'));
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fabric-scss",
"version": "0.0.1",
"version": "1.0.0",
"description": "",
"homepage": "https://fabric-design.github.io/styleguide/#/general/1-intro",
"main": "README.md",
Expand Down Expand Up @@ -29,9 +29,13 @@
"registry": "npm"
},
"devDependencies": {
"conventional-github-releaser": "^1.1.12",
"gulp": "github:gulpjs/gulp#4.0",
"gulp-bump": "^2.7.0",
"gulp-conventional-changelog": "^1.1.4",
"gulp-sass": "^2.3.1",
"gulp-stylelint": "^3.9.0",
"run-sequence": "^2.1.0",
"stylelint": "^7.9.0",
"stylelint-config-sass-guidelines": "^2.0.0",
"stylelint-scss": "^1.4.3"
Expand Down

0 comments on commit d917683

Please sign in to comment.