mirror of
https://github.com/goreleaser/goreleaser-action.git
synced 2026-05-18 00:11:53 +00:00
Initial commit
This commit is contained in:
commit
e28e23212c
778 changed files with 75786 additions and 0 deletions
37
lib/github_release.js
Normal file
37
lib/github_release.js
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
"use strict";
|
||||
var GitHubApi = require('github');
|
||||
var semver = require('semver');
|
||||
module.exports = function (user, repo, opts) {
|
||||
opts = opts || {};
|
||||
return new Promise(function (resolve, reject) {
|
||||
var github = new GitHubApi({
|
||||
// debug: true,
|
||||
protocol: 'https',
|
||||
host: 'api.github.com',
|
||||
headers: {
|
||||
'user-agent': 'http://npmjs.com/package/latest-github-tag' // required, can be whatever
|
||||
},
|
||||
timeout: opts.timeout || 5000
|
||||
});
|
||||
if (opts.auth) {
|
||||
github.authenticate(opts.auth);
|
||||
}
|
||||
github.repos.getTags({
|
||||
user: user,
|
||||
repo: repo
|
||||
}, function (err, tags) {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
if (!tags.length) {
|
||||
return reject(new Error('No tags found for ' + user + '/' + repo));
|
||||
}
|
||||
var tagsSorted = tags.map(function (item) {
|
||||
return item.name;
|
||||
})
|
||||
.filter(semver.valid)
|
||||
.sort(semver.rcompare);
|
||||
resolve(tagsSorted[0]);
|
||||
});
|
||||
});
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue