Skip to content

Commit

Permalink
Release blog post improvements; changelog and explicit version.
Browse files Browse the repository at this point in the history
* Added explicit version argument in case one wants to create the
  blog post *before* the version has been released.

* Fetch changelog from nodejs/node repo tag rather than master
  as it's more likely to have the correct changelog in place.

* Leave [INSERT SHASHUMS HERE] if shasums could not be found
  on nodejs.org/dist. Will happen if one are creating the
  blog post before having released a new version of node.

Refs nodejs#156.
  • Loading branch information
phillipj committed Sep 17, 2015
1 parent 2925d99 commit 90283ca
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions scripts/release-post.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

'use strict';

/**
* What's this?? It will help you create release blog
* posts so you wont have to do the tedious work
* of stitching together data from changelog, shasums etc,
* but get a more or less complete release blog ready to go.
*
* Usage: $ node release-post.js [version]
*
* If the version argument is omitted, the latest version number
* will be picked from https://nodejs.org/dist/index.json.
*
* It'll create a file with the blog post content
* into ../locale/en/blog/release/vX.md ready for you to commit
* or possibly edit by hand before commiting.
*
* Happy releasing!
*/

const https = require('https');
const fs = require('fs');
const path = require('path');
Expand Down Expand Up @@ -29,6 +47,11 @@ function download (url, cb) {
// ## 2015-08-04, Version 3.0.0, @rvagg
const rxReleaseSection = /## \d{4}-\d{2}-\d{2}, Version ([^,( ]+)[\s\S]*?(?=## \d{4})/g;

function explicitVersion() {
const versionArg = process.argv[2];
return versionArg ? Promise.resolve(versionArg) : Promise.reject();
}

function findLatestVersion (cb) {
return download('https://nodejs.org/dist/index.json')
.then(JSON.parse)
Expand All @@ -51,7 +74,7 @@ function fetchDocs (version) {
}

function fetchChangelog (version) {
return download('https://raw.githubusercontent.com/nodejs/node/master/CHANGELOG.md')
return download(`https://raw.githubusercontent.com/nodejs/node/v${version}/CHANGELOG.md`)
.then(function (data) {
let matches;

Expand All @@ -67,7 +90,8 @@ function fetchChangelog (version) {
}

function fetchShasums (version) {
return download(`https://nodejs.org/dist/v${version}/SHASUMS256.txt.asc`);
return download(`https://nodejs.org/dist/v${version}/SHASUMS256.txt.asc`)
.then(null, () => '[INSERT SHASUMS HERE]');
}

function renderPost (results) {
Expand Down Expand Up @@ -98,7 +122,8 @@ function slugify (str) {
return str.replace(/\./g, '-');
}

findLatestVersion()
explicitVersion()
.then(null, findLatestVersion)
.then(fetchDocs)
.then(renderPost)
.then(writeToFile)
Expand Down

0 comments on commit 90283ca

Please sign in to comment.