diff --git a/.circleci/config.yml b/.circleci/config.yml index 41f64aa..3fb5c52 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,10 +1,6 @@ # Use the latest 2.1 version of CircleCI pipeline process engine. # See: https://circleci.com/docs/configuration-reference version: 2.1 -# set the filter to allow a build for any sha tag -filters: - tags: - only: /.*/ parameters: run_build: type: boolean @@ -76,3 +72,7 @@ workflows: when: << pipeline.parameters.run_build >> jobs: - pio-build + # set the filter to allow a build for any sha tag + filters: + tags: + only: /.*/ diff --git a/webinstall/cibuild.html b/webinstall/cibuild.html index deea2fb..98530d6 100644 --- a/webinstall/cibuild.html +++ b/webinstall/cibuild.html @@ -10,6 +10,14 @@

Build your own ESP32-NMEA2000

New Build

+
+ + --- +
+
+ GitSha + --- +
diff --git a/webinstall/cibuild.js b/webinstall/cibuild.js index 0a034e9..5143c7a 100644 --- a/webinstall/cibuild.js +++ b/webinstall/cibuild.js @@ -4,7 +4,10 @@ import fileDownload from "https://cdn.skypack.dev/js-file-download@0.4.12" (function(){ const STATUS_INTERVAL=2000; const CURRENT_PIPELINE='pipeline'; - let API="cibuild.php"; + const API="cibuild.php"; + const GITAPI="install.php"; + const GITUSER="wellenvogel"; + const GITREPO="esp32-nmea2000"; let currentPipeline=undefined; let downloadUrl=undefined; let timer=undefined; @@ -15,6 +18,7 @@ import fileDownload from "https://cdn.skypack.dev/js-file-download@0.4.12" let displayMode='last'; let delayedSearch=undefined; let running=false; + let gitSha=undefined; if (! branch) branch='master'; const modeStrings={ last: 'Last Build', @@ -123,6 +127,7 @@ import fileDownload from "https://cdn.skypack.dev/js-file-download@0.4.12" setValue('status','requested'); setValue('pipeline',''); setRunning(true); + if (gitSha !== undefined) param.tag=gitSha; param.config=JSON.stringify(config); fetchJson(API,Object.assign({ api:'start'},param)) @@ -324,6 +329,7 @@ import fileDownload from "https://cdn.skypack.dev/js-file-download@0.4.12" } let param={find:1}; fillValues(param,['environment','buildflags']); + if (gitSha !== undefined) param.tag=gitSha; fetchJson(API,param) .then((res)=>{ setCurrentPipeline(res.pipeline); @@ -347,6 +353,56 @@ import fileDownload from "https://cdn.skypack.dev/js-file-download@0.4.12" } structure=await loadConfig("build.yaml"); buildSelectors(ROOT_PATH,structure.config.children,true); - //buildValues(); + let gitParam={user:GITUSER,repo:GITREPO}; + let branch=getParam('branch'); + if (branch){ + try{ + let info=await fetchJson(GITAPI,Object.assign({},gitParam,{branch:branch})); + if (info.object){ + gitSha=info.object.sha; + setValue('branchOrTag','branch'); + setValue('branchOrTagValue',branch); + } + }catch (e){ + console.log("branch query error",e); + } + } + if (gitSha === undefined) { + let tag = getParam('tag'); + if (!tag) { + try { + let relinfo = await fetchJson(GITAPI, Object.assign({}, gitParam, { api: 1 })); + if (relinfo.tag_name) { + tag = relinfo.tag_name; + } + else { + alert("unable to query latest release"); + } + } catch (e) { + alert("unable to query release info " + e); + } + } + if (tag){ + try{ + let info=await fetchJson(GITAPI,Object.assign({},gitParam,{tag:tag})); + if (info.object){ + gitSha=info.object.sha; + setValue('branchOrTag','tag'); + setValue('branchOrTagValue',tag); + } + }catch(e){ + alert("cannot get sha for tag "+tag+": "+e); + } + } + } + if (gitSha === undefined){ + //last resort: no sha, let the CI pick up latest + setValue('gitSha','unknown'); + setValue('branchOrTag','branch'); + setValue('branchOrTagValue','master'); + } + else{ + setValue('gitSha',gitSha); + } } })(); \ No newline at end of file diff --git a/webinstall/helper.js b/webinstall/helper.js index 857427c..68dce53 100644 --- a/webinstall/helper.js +++ b/webinstall/helper.js @@ -57,7 +57,7 @@ const fillValues=(values,items)=>{ const setValue=(id,value)=>{ let el=document.getElementById(id); if (! el) return; - if (el.tagName == 'DIV'){ + if (el.tagName == 'DIV' || el.tagName == 'SPAN' || el.tagName == 'P'){ el.textContent=value; return; } diff --git a/webinstall/install.php b/webinstall/install.php index ed5281e..c3fd6a8 100644 --- a/webinstall/install.php +++ b/webinstall/install.php @@ -1,7 +1,10 @@