Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions scripts/helpers/downloads.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
const extend = require('util')._extend

const downloads = [
{
'title': 'Windows 32-bit Installer',
'templateUrl': 'https://nodejs.org/dist/v%version%/node-v%version%-x86.msi'
},
{
'title': 'Windows 64-bit Installer',
'templateUrl': 'https://nodejs.org/dist/v%version%/node-v%version%-x64.msi'
},
{
'title': 'Windows 32-bit Binary',
'templateUrl': 'https://nodejs.org/dist/v%version%/win-x86/node.exe'
},
{
'title': 'Windows 64-bit Binary',
'templateUrl': 'https://nodejs.org/dist/v%version%/win-x64/node.exe'
},
{
'title': 'Mac OS X 64-bit Installer',
'templateUrl': 'https://nodejs.org/dist/v%version%/node-v%version%.pkg'
},
{
'title': 'Mac OS X 64-bit Binary',
'templateUrl': 'https://nodejs.org/dist/v%version%/node-v%version%-darwin-x64.tar.gz'
},
{
'title': 'Linux 32-bit Binary',
'templateUrl': 'https://nodejs.org/dist/v%version%/node-v%version%-linux-x86.tar.gz'
},
{
'title': 'Linux 64-bit Binary',
'templateUrl': 'https://nodejs.org/dist/v%version%/node-v%version%-linux-x64.tar.gz'
},
{
'title': 'SunOS 32-bit Binary',
'templateUrl': 'https://nodejs.org/dist/v%version%/node-v%version%-sunos-x86.tar.gz'
},
{
'title': 'SunOS 64-bit Binary',
'templateUrl': 'https://nodejs.org/dist/v%version%/node-v%version%-sunos-x64.tar.gz'
},
{
'title': 'ARMv6 32-bit Binary',
'templateUrl': 'https://nodejs.org/dist/v%version%/node-v%version%-linux-armv6l.tar.gz'
},
{
'title': 'ARMv7 32-bit Binary',
'templateUrl': 'https://nodejs.org/dist/v%version%/node-v%version%-linux-armv7.tar.gz'
},
{
'title': 'ARMv8 64-bit Binary',
'templateUrl': 'https://nodejs.org/dist/v%version%/node-v%version%-linux-arm64.tar.gz'
},
{
'title': 'Source Code',
'templateUrl': 'https://nodejs.org/dist/v%version%/node-v%version%.tar.gz'
}
]

function resolveUrl (item, version) {
const url = item.templateUrl.replace(/%version%/g, version)
return extend({url}, item)
}

module.exports = (version) => {
return downloads.map((item) => resolveUrl(item, version))
}
39 changes: 33 additions & 6 deletions scripts/release-post.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,32 @@ const fs = require('fs')
const path = require('path')
const extend = require('util')._extend
const Handlebars = require('handlebars')
const url = require('url')

function download (url, cb) {
const downloads = require('./helpers/downloads')

function request (uri, method, cb) {
return new Promise(function (resolve, reject) {
const opts = extend({ method }, url.parse(uri))
let data = ''
https.get(url, function (res) {

https.request(opts, function (res) {
if (res.statusCode !== 200) {
return reject(new Error('Invalid status code (!= 200) while retrieving ' + url + ': ' + res.statusCode))
}

res.on('data', function (chunk) { data += chunk })
res.on('end', function () { resolve(data) })
}).on('error', function (err) {
reject(new Error('Error downloading file from %s: %s', url, err.message))
})
reject(new Error('Error requesting URL %s: %s', url, err.message))
}).end()
})
}

function download (url) {
return request(url, 'GET')
}

// matches a complete release section, support both old node and iojs releases:
// ## 2015-07-09, Version 0.12.7 (Stable)
// ## 2015-08-04, Version 3.0.0, @rvagg
Expand All @@ -61,14 +70,20 @@ function findLatestVersion (cb) {
}

function fetchDocs (version) {
return Promise.all([ fetchChangelog(version), fetchShasums(version) ]).then(function (results) {
return Promise.all([
fetchChangelog(version),
fetchShasums(version),
verifyDownloads(version)
]).then(function (results) {
const changelog = results[0]
const shasums = results[1]
const files = results[2]

return {
version,
changelog,
shasums
shasums,
files
}
})
}
Expand Down Expand Up @@ -96,6 +111,18 @@ function fetchShasums (version) {
.then(null, () => '[INSERT SHASUMS HERE]')
}

function verifyDownloads (version) {
const allDownloads = downloads(version)
const reqs = allDownloads.map(urlOrComingSoon)
return Promise.all(reqs)
}

function urlOrComingSoon (binary) {
return request(binary.url, 'HEAD').then(
() => `${binary.title}: ${binary.url}`,
() => `${binary.title}: *Coming soon*`)
}

function renderPost (results) {
const templateStr = fs.readFileSync(path.resolve(__dirname, 'release.hbs')).toString('utf8')
const template = Handlebars.compile(templateStr, { noEscape: true })
Expand Down
17 changes: 3 additions & 14 deletions scripts/release.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,9 @@ layout: blog-post.hbs

{{changelog}}

Windows 32-bit Installer: https://nodejs.org/dist/v{{version}}/node-v{{version}}-x86.msi<br>
Windows 64-bit Installer: https://nodejs.org/dist/v{{version}}/node-v{{version}}-x64.msi<br>
Windows 32-bit Binary: https://nodejs.org/dist/v{{version}}/win-x86/node.exe<br>
Windows 64-bit Binary: https://nodejs.org/dist/v{{version}}/win-x64/node.exe<br>
Mac OS X 64-bit Installer: https://nodejs.org/dist/v{{version}}/node-v{{version}}.pkg<br>
Mac OS X 64-bit Binary: https://nodejs.org/dist/v{{version}}/node-v{{version}}-darwin-x64.tar.gz<br>
Linux 32-bit Binary: https://nodejs.org/dist/v{{version}}/node-v{{version}}-linux-x86.tar.gz<br>
Linux 64-bit Binary: https://nodejs.org/dist/v{{version}}/node-v{{version}}-linux-x64.tar.gz<br>
SunOS 32-bit Binary: https://nodejs.org/dist/v{{version}}/node-v{{version}}-sunos-x86.tar.gz<br>
SunOS 64-bit Binary: https://nodejs.org/dist/v{{version}}/node-v{{version}}-sunos-x64.tar.gz<br>
ARMv6 32-bit Binary: https://nodejs.org/dist/v{{version}}/node-v{{version}}-linux-armv6l.tar.gz<br>
ARMv7 32-bit Binary: https://nodejs.org/dist/v{{version}}/node-v{{version}}-linux-armv7l.tar.gz<br>
ARMv8 64-bit Binary: https://nodejs.org/dist/v{{version}}/node-v{{version}}-linux-arm64.tar.gz<br>
Source Code: https://nodejs.org/dist/v{{version}}/node-v{{version}}.tar.gz<br>
{{#files}}
{{.}}<br>
{{/files}}
Other release files: https://nodejs.org/dist/v{{version}}/<br>
Documentation: https://nodejs.org/docs/v{{version}}/api/

Expand Down