import git from '@nice-labs/git-rev' ; import zip from 'gulp-zip' ; import { extension as buildBaseVersion , ExtensionBuildArgs } from './normal' ; import { dest , src , series , parallel , TaskFunction } from 'gulp' ; import { BUILD_PATH , ROOT_PATH , task } from '../utils' ; import { codegen } from '../codegen' ; import path from 'path' ; export const ciBuild = series ( printBranchName , codegen , buildBaseVersion , ( process . env . CI ? series : parallel ) ( zipTo ( BUILD_PATH , 'MaskNetwork.base.zip' ) , zipTo ( BUILD_PATH , 'MaskNetwork.chromium.zip' ) , buildTarget ( 'Firefox' , { firefox : true , 'output-path' : 'build-firefox' } , 'MaskNetwork.firefox.zip' ) , buildTarget ( 'Android' , { android : true , 'output-path' : 'build-android' } , 'MaskNetwork.gecko.zip' ) , buildTarget ( 'iOS' , { iOS : true , 'output-path' : 'build-iOS' } , 'MaskNetwork.iOS.zip' ) , buildTarget ( 'Firefox' , { firefox : true , 'output-path' : 'build-firefox' } , 'MaskNetwork.firefox.zip' ) , buildTarget ( 'Chromium-beta' , { chromium : true , beta : true , 'output-path' : 'build-chromium-beta' } , 'MaskNetwork.chromium-beta.zip' ) ) ) ; task ( ciBuild , 'build-ci' , 'Build the extension on CI' ) ; function buildTarget ( name , options , outFile ) { options . readonlyCache = true ; options [ 'output-path' ] = path . join ( ROOT_PATH , options [ 'output-path' ] ! ) ; return series ( buildWith ( name , options ) , zipTo ( options [ 'output-path' ] ! , outFile ) ) ; } function zipTo ( absBuildDir , fileName ) { const f = ( ) => src ( `./**/*` , { cwd : absBuildDir } ) . pipe ( zip ( fileName ) ) . pipe ( dest ( './' , { cwd : ROOT_PATH } ) ) ; f . displayName = `zip ${ absBuildDir } into ${ fileName }` ; return f ; } function buildWith ( name , buildArgs ) { const f = ( ) => buildBaseVersion ( buildArgs ) ; f . displayName = `Build target ${ name }` ; return f ; } async function printBranchName ( ) { console . log ( 'Building on branch: ' , git . branchName ( ) ) ; }