Skip to content

Commit

Permalink
Show nightly builds
Browse files Browse the repository at this point in the history
  • Loading branch information
mmosca committed Jun 17, 2024
1 parent e17965d commit a223660
Showing 1 changed file with 99 additions and 3 deletions.
102 changes: 99 additions & 3 deletions tabs/firmware_flasher.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,26 @@ TABS.firmware_flasher.initialize = function (callback) {
worker.postMessage(str);
}

function parseDevFilename(filename) {
//var targetFromFilenameExpression = /inav_([\d.]+)?_?([^.]+)\.(.*)/;
// inav_8.0.0_TUNERCF405_dev-20240617-88fb1d0.hex
var targetFromFilenameExpression = /^inav_([\d.]+)_([A-Z0-9_]+)_dev-(\d{4})(\d{2})(\d{2})-(\w+)\.(hex)$/;
var match = targetFromFilenameExpression.exec(filename);

if (!match) {
GUI.log("no match: dev filename: " + filename);
return null;
}

GUI.log("non dev: match[2]: " + match[2] + " match[7]: " + match[7]);

return {
raw_target: match[2],
target: match[2].replace("_", " "),
format: match[7],
};
}

function parseFilename(filename) {
//var targetFromFilenameExpression = /inav_([\d.]+)?_?([^.]+)\.(.*)/;
var targetFromFilenameExpression = /inav_([\d.]+(?:-rc\d+)?)?_?([^.]+)\.(.*)/;
Expand All @@ -64,6 +84,8 @@ TABS.firmware_flasher.initialize = function (callback) {
return null;
}

//GUI.log("non dev: match[2]: " + match[2] + " match[3]: " + match[3]);

return {
raw_target: match[2],
target: match[2].replace("_", " "),
Expand Down Expand Up @@ -102,7 +124,7 @@ TABS.firmware_flasher.initialize = function (callback) {
});
});

var buildBoardOptions = function(){
var buildBoardOptions = function(releasesData){
var boards_e = $('select[name="board"]').empty();
var versions_e = $('select[name="firmware_version"]').empty();
var showDevReleases = ($('input.show_development_releases').is(':checked'));
Expand All @@ -113,6 +135,11 @@ TABS.firmware_flasher.initialize = function (callback) {
var releases = {};
var sortedTargets = [];
var unsortedTargets = [];

var processRelease = function(release) {

}

TABS.firmware_flasher.releasesData.forEach(function(release){
release.assets.forEach(function(asset){
var result = parseFilename(asset.name);
Expand All @@ -126,6 +153,21 @@ TABS.firmware_flasher.initialize = function (callback) {
});
sortedTargets = unsortedTargets.sort();
});

TABS.firmware_flasher.devReleasesData.forEach(function(release){
release.assets.forEach(function(asset){
var result = parseDevFilename(asset.name);

if ((!showDevReleases && release.prerelease) || !result) {
return;
}
if($.inArray(result.target, unsortedTargets) == -1) {
unsortedTargets.push(result.target);
}
});
sortedTargets = unsortedTargets.sort();
});

sortedTargets.forEach(function(release) {
releases[release] = [];
});
Expand Down Expand Up @@ -154,7 +196,7 @@ TABS.firmware_flasher.initialize = function (callback) {
date.getUTCHours(),
date.getMinutes()
);

var descriptor = {
"releaseUrl": release.html_url,
"name" : semver.clean(release.name),
Expand All @@ -170,6 +212,47 @@ TABS.firmware_flasher.initialize = function (callback) {
releases[result.target].push(descriptor);
});
});

TABS.firmware_flasher.devReleasesData.forEach(function(release){

var versionFromTagExpression = /v?(.*)/;
var matchVersionFromTag = versionFromTagExpression.exec(release.tag_name);
var version = matchVersionFromTag[1];

release.assets.forEach(function(asset){
var result = parseDevFilename(asset.name);
if ((!showDevReleases && release.prerelease) || !result) {
return;
}

if (result.format != 'hex') {
return;
}

var date = new Date(release.published_at);
var formattedDate = "{0}-{1}-{2} {3}:{4}".format(
date.getFullYear(),
date.getMonth() + 1,
date.getDate(),
date.getUTCHours(),
date.getMinutes()
);

var descriptor = {
"releaseUrl": release.html_url,
"name" : semver.clean(release.name),
"version" : release.tag_name,
"url" : asset.browser_download_url,
"file" : asset.name,
"raw_target": result.raw_target,
"target" : result.target,
"date" : formattedDate,
"notes" : release.body,
"status" : release.prerelease ? "nightly" : "stable"
};
releases[result.target].push(descriptor);
});
});

var selectTargets = [];
Object.keys(releases)
Expand All @@ -192,9 +275,22 @@ TABS.firmware_flasher.initialize = function (callback) {
return;
};

$.get('https://api.github.com/repos/iNavFlight/inav-nightly/releases?per_page=10', function(releasesData) {
TABS.firmware_flasher.devReleasesData = releasesData;
}).fail(function (data){
TABS.firmware_flasher.devReleasesData = {};
if (data["responseJSON"]){
GUI.log("<b>GITHUB Query Failed: <code>{0}</code></b>".format(data["responseJSON"].message));
}
$('select[name="board"]').empty().append('<option value="0">Offline</option>');
$('select[name="firmware_version"]').empty().append('<option value="0">Offline</option>');
$('a.auto_select_target').addClass('disabled');
});


$.get('https://api.github.com/repos/iNavFlight/inav/releases?per_page=10', function (releasesData){
TABS.firmware_flasher.releasesData = releasesData;
buildBoardOptions();
buildBoardOptions(releasesData);

// bind events
$('select[name="board"]').on('change', function () {
Expand Down

0 comments on commit a223660

Please sign in to comment.