@@ -5,9 +5,12 @@ const request = require('request');
55const async = require ( 'async' ) ;
66const nodeUnzip = require ( 'node-unzip-2' ) ;
77const archiver = require ( 'archiver' ) ;
8+ const os = require ( 'os' ) ;
89
910const bundleName = "nodeodm-windows-x64.zip" ;
1011
12+ const scratch = 'RUNNER_TEMP' in process . env ? process . env . RUNNER_TEMP : os . tmpdir ( ) ;
13+
1114const download = function ( uri , filename , callback ) {
1215 console . log ( `Downloading ${ uri } ` ) ;
1316 request . head ( uri , function ( err , res , body ) {
@@ -68,13 +71,42 @@ async.series([
6871 cb => {
6972 downloadApp ( path . join ( "apps" , "unzip" ) , "https://github.com/OpenDroneMap/NodeODM/releases/download/v2.1.0/unzip600.zip" , cb ) ;
7073 } ,
74+ cb => {
75+ downloadApp ( path . join ( scratch , "azuresigning" ) , "https://www.nuget.org/api/v2/package/Microsoft.ArtifactSigning.Client/1.0.115" , cb ) ;
76+ } ,
7177 cb => {
7278 console . log ( "Building executable" ) ;
73- const code = spawnSync ( 'nexe.cmd' , [ 'index.js' , '-t' , 'windows-x64-12.16.3' , '-o' , 'nodeodm.exe' ] , { stdio : "pipe" } ) . status ;
79+ const code = spawnSync ( 'nexe.cmd' , [ 'index.js' , '-t' , 'windows-x64-12.16.3' , '-o' , 'nodeodm.exe' ] , { stdio : "inherit" , shell : true } ) . status ;
7480
7581 if ( code === 0 ) cb ( ) ;
7682 else cb ( new Error ( `nexe returned non-zero error code: ${ code } ` ) ) ;
7783 } ,
84+ cb => {
85+ let signtoolPath = null ;
86+ let metadataPath = null ;
87+
88+ const signtoolPathArgIndex = process . argv . indexOf ( "--signtool-path" ) ;
89+ if ( signtoolPathArgIndex !== - 1 && signtoolPathArgIndex + 1 < process . argv . length ) {
90+ signtoolPath = process . argv [ signtoolPathArgIndex + 1 ] ;
91+ }
92+
93+ const metadataPathArgIndex = process . argv . indexOf ( "--azure-signing-metadata" ) ;
94+ if ( metadataPathArgIndex !== - 1 && metadataPathArgIndex + 1 < process . argv . length ) {
95+ metadataPath = process . argv [ metadataPathArgIndex + 1 ] ;
96+ }
97+
98+ if ( signtoolPath && metadataPath ) {
99+ console . log ( "Signing executable" ) ;
100+
101+ const dlibPath = path . join ( scratch , "azuresigning" , "bin" , "x64" , "Azure.CodeSigning.Dlib.dll" ) ;
102+ const code = spawnSync ( signtoolPath , [ 'sign' , '/v' , '/debug' , '/fd' , 'SHA256' , '/tr' , 'http://timestamp.acs.microsoft.com' , '/td' , 'SHA256' , '/dlib' , dlibPath , '/dmdf' , metadataPath , 'nodeodm.exe' ] , { stdio : "inherit" } ) . status ;
103+
104+ if ( code === 0 ) cb ( ) ;
105+ else cb ( new Error ( `signtool returned non-zero error code: ${ code } ` ) ) ;
106+ } else {
107+ cb ( ) ;
108+ }
109+ } ,
78110 cb => {
79111 // Zip
80112 const outFile = path . join ( "dist" , bundleName ) ;
0 commit comments