@leverege/build-tools 2.68.2 → 2.68.3-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leverege/build-tools",
3
- "version": "2.68.2",
3
+ "version": "2.68.3-beta.1",
4
4
  "description": "A collection of build / support tools for Leverege developers",
5
5
  "main": "index.js",
6
6
  "repository": {
package/src/Docker.mjs CHANGED
@@ -47,7 +47,8 @@ const bashrcPluginTemplate = `
47
47
  #
48
48
  `
49
49
  const bashrcTemplate = fs.readFileSync( path.join( DIRNAME, './templates/bashrcTemplate.hbs' ), 'utf8' )
50
- const cloudBuildSteps = fs.readFileSync( path.join( DIRNAME, './templates/cloudBuildTargetGKE.hbs' ), 'utf8' )
50
+ const cloudBuildStepsSingleArch = fs.readFileSync( path.join( DIRNAME, './templates/cloudBuildSingleArch.hbs' ), 'utf8' )
51
+ const cloudBuildStepsMultiArch = fs.readFileSync( path.join( DIRNAME, './templates/cloudBuildMultiArch.hbs' ), 'utf8' )
51
52
 
52
53
  const defaultSettings = {
53
54
  apkadds : '',
@@ -178,6 +179,7 @@ const buildContainerImage = async ( repoDescr ) => {
178
179
  artifactProject,
179
180
  artifactRegistry,
180
181
  containerName,
182
+ imagePlatform,
181
183
  imageVersion,
182
184
  isNodeJsProject,
183
185
  isNpmWorkspace,
@@ -226,8 +228,17 @@ const buildContainerImage = async ( repoDescr ) => {
226
228
 
227
229
  // build the cloudbuild.yaml from the handlebars template
228
230
  const cloudBuildFile = './build/cloudbuild.yaml'
231
+ let cloudBuildSteps
232
+ let imagePlatformString
233
+ if ( !imagePlatform || imagePlatform[0] === 'linux/amd64' ) {
234
+ cloudBuildSteps = cloudBuildStepsSingleArch
235
+ imagePlatformString = 'linux/amd64'
236
+ } else {
237
+ cloudBuildSteps = cloudBuildStepsMultiArch
238
+ imagePlatformString = imagePlatform.join( ',' )
239
+ }
229
240
  const cbst = handlebars.compile( cloudBuildSteps, { noEscape : true } )
230
- const cbs = cbst( { artifactProject, artifactRegistry, imageName, imageVersion, imageInfoTag, } )
241
+ const cbs = cbst( { artifactProject, artifactRegistry, imageName, imagePlatform : imagePlatformString, imageVersion, imageInfoTag, } )
231
242
  fs.writeFileSync( cloudBuildFile, cbs )
232
243
 
233
244
  // build up the cloud build command and options
package/src/Utils.mjs CHANGED
@@ -565,10 +565,11 @@ export const analyzeRepository = async ( giveGuidance ) => {
565
565
  // if the build tools version is still undefined then assume we are using a globally installed bt
566
566
  if ( buildToolsVersion === undefined ) {
567
567
  const fromBuildTools = await shellCmd( 'build-tools --version' )
568
- buildToolsVersion = fromBuildTools.match( /\d+\.\d+\.\d+$/ )[0]
568
+ buildToolsVersion = fromBuildTools.match( /\d+\.\d+\.\d+(?:-[a-zA-Z0-9.-]+)?$/ )[0]
569
569
  }
570
570
 
571
571
  const containerName = closestPackageJson?.name.replace( /^@[^/]+\//, '' ) || rootPyProjectToml?.project.name
572
+ const imagePlatform = closestPackageJson?.leverege.imagePlatform || rootPyProjectToml?.leverege['image-platform']
572
573
  const artifactRegistry = closestPackageJson?.leverege.registry || rootPyProjectToml?.leverege.registry
573
574
  const artifactProject = closestPackageJson?.artifactRegistry.project || rootPyProjectToml?.artifactRegistry.project || 'unknown'
574
575
  const packageVersion = `v${closestPackageJson?.version || rootPyProjectToml?.project.version}`
@@ -595,6 +596,7 @@ export const analyzeRepository = async ( giveGuidance ) => {
595
596
  artifactRegistry,
596
597
  buildToolsVersion,
597
598
  containerName,
599
+ imagePlatform,
598
600
  currentDir,
599
601
  closestPkg,
600
602
  gitRoot,
@@ -0,0 +1,27 @@
1
+ options:
2
+ machineType: E2_HIGHCPU_8
3
+
4
+ steps:
5
+ - name: 'gcr.io/cloud-builders/docker'
6
+ args: ['buildx', 'create', '--driver', 'docker-container', '--name', 'container', '--driver-opt', 'network=cloudbuild', '--buildkitd-flags', '--allow-insecure-entitlement=network.host', '--use']
7
+
8
+ - name: 'gcr.io/cloud-builders/docker'
9
+ args:
10
+ - 'buildx'
11
+ - 'build'
12
+ - '--builder=container'
13
+ - '--network=host'
14
+ - '--platform'
15
+ - '{{imagePlatform}}'
16
+ - '--cache-from'
17
+ - 'type=registry,ref={{imageName}}:cache,mode=max'
18
+ - '--cache-to'
19
+ - 'type=registry,ref={{imageName}}:cache,mode=max'
20
+ - '--tag'
21
+ - '{{imageName}}:{{imageInfoTag}}'
22
+ - '--tag'
23
+ - '{{imageName}}:{{imageVersion}}'
24
+ - '--tag'
25
+ - '{{imageName}}:latest'
26
+ - '--push'
27
+ - '.'