Skip to content

Instantly share code, notes, and snippets.

@weeksdev
Created May 3, 2016 01:40
Show Gist options
  • Select an option

  • Save weeksdev/2e0e251deb94ae7b5070b0c1da8ff706 to your computer and use it in GitHub Desktop.

Select an option

Save weeksdev/2e0e251deb94ae7b5070b0c1da8ff706 to your computer and use it in GitHub Desktop.
Gulpfile to Build .net projects and deploy to github
var gulp = require('gulp'),
msbuild = require('gulp-msbuild'),
githubRelease = require('gulp-github-release'),
zip = require('gulp-zip'),
series = require('run-sequence'),
fs = require('fs');
gulp.task('build', function () {
return gulp.src('./SOLUTION_NAME.sln')
.pipe(msbuild({
Configuration: 'Release',
errorOnFail: true,
}));
});
gulp.task('zip', function () {
return gulp.src('PATH_TO/bin/Release/*')
.pipe(zip('FILENAME.zip'))
.pipe(gulp.dest('dist'));
})
gulp.task('github-release', function () {
var token = fs.readFileSync('PATH/TO/TOKEN.TXT'); //obtain a github token here: https://github.com/settings/tokens
//request generation of a new token with repo access
return gulp.src('dist/FILENAME.zip')
.pipe(githubRelease({
token: token,
owner: 'OWNER_NAME',
repo: 'GITHUB_REPO_NAME',
tag: 'v1.0.0',
name: 'NAME v1.0.0',
notes: 'NOTES_HERE',
draft: false,
prerelease: false
}))
});
gulp.task('deploy', function () {
series('build', 'zip', 'github-release')
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment