chore(release): make discourse task work

This commit is contained in:
Andrew
2014-08-06 14:40:33 -06:00
parent d3ed66e0cd
commit 50ee67763d
6 changed files with 99 additions and 24 deletions

View File

@@ -0,0 +1 @@
http://forum.ionicframework.com/t/1-0-0-beta-10-hafnium-heron-released/7326/

View File

@@ -1 +0,0 @@
http://forum.ionicframework.com/t/v1-0-0-beta-5b-cadmium-camel-released/4277

View File

@@ -1,9 +1,12 @@
var pkg = require('../package.json');
var fs = require('fs');
var DISCOURSE_FILE = __dirname + '/DISCOURSE_POST_URL';
module.exports = {
dist: 'dist',
releasePostUrl: fs.readFileSync('config/RELEASE_POST_URL'),
releasePostUrl: fs.readFileSync(DISCOURSE_FILE).toString(),
releasePostFile: DISCOURSE_FILE,
protractorPort: 8876,

View File

@@ -1,6 +1,8 @@
var gulp = require('gulp');
var path = require('canonical-path');
var pkg = require('./package.json');
var request = require('request');
var q = require('q');
var semver = require('semver');
var through = require('through');
@@ -59,7 +61,6 @@ gulp.task('default', ['build']);
gulp.task('build', ['bundle', 'sass']);
gulp.task('validate', ['jshint', 'ddescribe-iit', 'karma']);
var IS_WATCH = false;
gulp.task('watch', ['build'], function() {
IS_WATCH = true;
@@ -67,31 +68,39 @@ gulp.task('watch', ['build'], function() {
gulp.watch('scss/**/*.scss', ['sass']);
});
gulp.task('changelog', function(done) {
var codename = pkg.codename;
var file = argv.standalone ? '' : __dirname + '/CHANGELOG.md';
var subtitle = argv.subtitle || '"' + codename + '"';
var toHtml = !!argv.html;
gulp.task('changelog', function() {
var dest = argv.dest || 'CHANGELOG.md';
var from = argv.from;
changelog({
repository: 'https://github.com/driftyco/ionic',
version: pkg.version,
subtitle: subtitle,
file: file,
from: from
}, function(err, data) {
if (err) return done(err);
var toHtml = !!argv.html;
return makeChangelog(argv).then(function(log) {
if (toHtml) {
data = marked(data, {
log = marked(log, {
gfm: true
});
}
fs.writeFileSync(dest, data);
done();
fs.writeFileSync(dest, log);
});
});
function makeChangelog(options) {
var codename = pkg.codename;
var file = options.standalone ? '' : __dirname + '/CHANGELOG.md';
var subtitle = options.subtitle || '"' + codename + '"';
var from = options.from;
var version = options.version || pkg.version;
var deferred = q.defer();
changelog({
repository: 'https://github.com/driftyco/ionic',
version: version,
subtitle: subtitle,
file: file,
from: from
}, function(err, log) {
if (err) deferred.reject(err);
else deferred.resolve(log);
});
return deferred.promise;
}
gulp.task('bundle', [
'scripts',
'scripts-ng',
@@ -220,7 +229,11 @@ gulp.task('release-tweet', function(done) {
var client = new twitter(oauth);
client.statuses(
'update',
{ status: buildConfig.releaseMessage() },
{
status: argv.test ?
'This is a test.' :
buildConfig.releaseMessage()
},
oauth.accessToken,
oauth.accessTokenSecret,
done
@@ -236,12 +249,62 @@ gulp.task('release-irc', function(done) {
realName: 'ionitron',
channels: ['#ionic']
}, function() {
client.say('#ionic', buildConfig.releaseMessage(), function() {
client.say('#ionic', argv.test ? 'This is a test.' : buildConfig.releaseMessage(), function() {
client.quit('', done);
});
});
});
gulp.task('release-discourse', function(done) {
var oldPostUrl = buildConfig.releasePostUrl;
var newPostUrl;
return makeChangelog({
standalone: true
})
.then(function(changelog) {
var content = 'Download Instructions: https://github.com/driftyco/ionic#quick-start\n\n' + changelog;
return qRequest({
url: 'http://forum.ionicframework.com/posts',
method: 'post',
form: {
api_key: process.env.DISCOURSE_TOKEN,
api_username: 'Ionitron',
title: argv.test ?
('This is a test. ' + Date.now()) :
'v' + pkg.version + ' "' + pkg.codename + '" released!',
raw: argv.test ?
('This is a test. Again! ' + Date.now()) :
content
}
});
})
.then(function(res) {
var body = JSON.parse(res.body);
newPostUrl = 'http://forum.ionicframework.com/t/' + body.topic_slug + '/' + body.topic_id;
fs.writeFileSync(buildConfig.releasePostFile, newPostUrl);
return q.all([
updatePost(newPostUrl, 'closed', true),
updatePost(newPostUrl, 'visible', false),
oldPostUrl && updatePost(oldPostUrl, 'pinned', true)
]);
});
function updatePost(url, statusType, isEnabled) {
return qRequest({
url: url + '/status',
method: 'put',
form: {
api_key: process.env.DISCOURSE_TOKEN,
api_username: 'Ionitron',
status: statusType,
enabled: !!isEnabled
}
});
}
});
function notContains(disallowed) {
disallowed = disallowed || [];
@@ -274,3 +337,11 @@ function pad(n) {
if (n<10) { return '0' + n; }
return n;
}
function qRequest(opts) {
var deferred = q.defer();
request(opts, function(err, res, body) {
if (err) deferred.reject(err);
else deferred.resolve(res);
});
return deferred.promise;
}

View File

@@ -11,7 +11,7 @@ echo "#####"
function run {
cd ../..
CODENAME=$(cat config/CODENAMES | head -n 1)
CODENAME=$(head -n 1 config/CODENAMES)
echo "$(tail -n +2 config/CODENAMES)" > config/CODENAMES
replaceJsonProp "package.json" "codename" "$CODENAME"

View File

@@ -3,7 +3,6 @@
function init {
RELEASE_DIR=$HOME/ionic-release
../clone/clone.sh --repository="driftyco/ionic" \
--depth="1" \
--directory="$RELEASE_DIR" \
--branch="master"
}
@@ -18,7 +17,9 @@ function run {
node_modules/.bin/gulp build --release --dist="$RELEASE_DIR/release"
node_modules/.bin/gulp changelog --dest="$RELEASE_DIR/CHANGELOG.md"
# Move modified files into the repo copy we're going to push
cp package.json $RELEASE_DIR
cp config/CODENAMES $RELEASE_DIR
cd $RELEASE_DIR