Created
July 22, 2018 13:27
-
-
Save Skn0tt/fb37be4693c6a10a88aa3f9ce3dba59e to your computer and use it in GitHub Desktop.
Get the latest GitHub Release of a Project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const https = require('https'); | |
const getContent = function(host, path) { | |
return new Promise((resolve, reject) => { | |
const request = https.get({ | |
headers: { | |
"User-Agent": "Node" | |
}, | |
host, | |
path | |
}, (response) => { | |
const body = []; | |
response.on('data', (chunk) => body.push(chunk)); | |
response.on('end', () => resolve(body.join(''))); | |
}); | |
request.on('error', (err) => reject(err)) | |
}); | |
}; | |
const REPO = "docker/app" | |
(async () => { | |
const res = await getContent("api.github.com", `/repos/${REPO}/releases`); | |
const json = JSON.parse(res); | |
const newest = json[0]; | |
const newestVersion = newest.tag_name; | |
console.log(newestVersion); | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment