Skip to content

Instantly share code, notes, and snippets.

@Skn0tt
Created July 22, 2018 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Skn0tt/fb37be4693c6a10a88aa3f9ce3dba59e to your computer and use it in GitHub Desktop.
Save Skn0tt/fb37be4693c6a10a88aa3f9ce3dba59e to your computer and use it in GitHub Desktop.
Get the latest GitHub Release of a Project
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