@leverege/build-tools 2.53.6 → 2.54.0-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.53.6",
3
+ "version": "2.54.0-beta.1",
4
4
  "description": "A collection of build / support tools for Leverege developers",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -81,4 +81,4 @@
81
81
  "@leverege/eslint-config-leverege": "^4.2.0",
82
82
  "npm": "^10.9.0"
83
83
  }
84
- }
84
+ }
@@ -0,0 +1,83 @@
1
+ #!/bin/bash
2
+
3
+ application_name=$(awk -F'"' '/\[(tool\.poetry|project)\]/{flag=1;next} flag==1 && /^name = /{ print $2; exit }' ./pyproject.toml)
4
+ application_version=$(awk -F'"' '/\[(tool\.poetry|project)\]/{flag=1;next} flag==1 && /^version = /{ print $2; exit }' ./pyproject.toml)
5
+ gcp_project_id=$(awk -F'"' '/\[tool\.docker\]/{flag=1;next} flag==1 && /^gcp-project-id = /{ print $2; exit }' ./pyproject.toml)
6
+ gcp_repository_name=$(awk -F'"' '/\[tool\.docker\]/{flag=1;next} flag==1 && /^gcp-repository-name = /{ print $2; exit }' ./pyproject.toml)
7
+ platform=$(awk -F'[][]' '/\[tool\.docker\]/{flag=1;next} flag==1 && /^platform *=/ { gsub(/"/, "", $2); print $2; exit }' ./pyproject.toml)
8
+
9
+ # Check if the platform is empty
10
+ if [ -z "$platform" ]; then
11
+ platform="linux/amd64,linux/arm64"
12
+ fi
13
+
14
+ # Check if the version contains alpha, beta, rc, or a hyphen
15
+ if [[ $application_version =~ (alpha|beta|rc|-) ]]; then
16
+ is_stable_release="false"
17
+ else
18
+ is_stable_release="true"
19
+ fi
20
+
21
+ cache_path="$HOME/docker/$application_name"
22
+
23
+ echo -e "\n\033[0;32mBuild Information:\033[0m\n"
24
+
25
+ # List application name, application version, GCP project ID, GCP repository name, platform, and if it is a stable release.
26
+ echo -e "\033[0;32mApplication Name:\033[0m $application_name"
27
+ echo -e "\033[0;32mApplication Version:\033[0m $application_version"
28
+ echo -e "\033[0;32mGCP Project ID:\033[0m $gcp_project_id"
29
+ echo -e "\033[0;32mGCP Repository Name:\033[0m $gcp_repository_name"
30
+ echo -e "\033[0;32mPlatform:\033[0m $platform"
31
+ echo -e "\033[0;32mStable Release:\033[0m $is_stable_release"
32
+
33
+ # Prompt for confirmation
34
+ echo -e "\n"
35
+ read -p "Do you wish to proceed? (y/n): " -n 1 -r
36
+ echo -e "\n"
37
+
38
+ if [[ ! $REPLY =~ ^[Yy]$ ]]; then
39
+ echo -e "\033[0;31mExiting...\033[0m\n\n"
40
+ exit 1
41
+ fi
42
+
43
+
44
+ echo -e "\n\033[0;32mBuilding, creating and pushing image(s)...\033[0m\n\n"
45
+
46
+ export GCLOUD_ACCESS_TOKEN=$(gcloud auth print-access-token)
47
+
48
+ if [ "$is_stable_release" = "true" ]; then
49
+ docker buildx build \
50
+ --platform $platform \
51
+ --cache-from type=local,src=$cache_path \
52
+ --cache-to type=local,dest=$cache_path \
53
+ --build-arg APPLICATION_NAME=$application_name \
54
+ --build-arg APPLICATION_VERSION=$application_version \
55
+ --secret id=token,env=GCLOUD_ACCESS_TOKEN \
56
+ --secret="id=creds,src=$HOME/.config/gcloud/application_default_credentials.json" \
57
+ --tag us-docker.pkg.dev/$gcp_project_id/$gcp_repository_name/${application_name}:${application_version} \
58
+ --tag us-docker.pkg.dev/$gcp_project_id/$gcp_repository_name/${application_name}:latest \
59
+ --push \
60
+ .
61
+ else
62
+ docker buildx build \
63
+ --platform $platform \
64
+ --cache-from type=local,src=$cache_path \
65
+ --cache-to type=local,dest=$cache_path \
66
+ --build-arg APPLICATION_NAME=$application_name \
67
+ --build-arg APPLICATION_VERSION=$application_version \
68
+ --secret id=token,env=GCLOUD_ACCESS_TOKEN \
69
+ --secret="id=creds,src=$HOME/.config/gcloud/application_default_credentials.json" \
70
+ --tag us-docker.pkg.dev/$gcp_project_id/$gcp_repository_name/${application_name}:${application_version} \
71
+ --push \
72
+ .
73
+ fi
74
+
75
+ if [ $? -eq 0 ]; then
76
+ echo -e "\n\n\033[0;32mBuilt and pushed us-docker.pkg.dev/$gcp_project_id/$gcp_repository_name/$application_name:$application_version for $platform\033[0m"
77
+ if [ "$is_stable_release" = "true" ]; then
78
+ echo -e "\033[0;32mAlso tagged as 'latest'\033[0m"
79
+ fi
80
+ echo -e "\n\n"
81
+ else
82
+ echo -e "\n\n\033[0;31mBuild and push failed!\033[0m\n\n"
83
+ fi
@@ -1,20 +0,0 @@
1
- registry:
2
- - root: us-docker.pkg.dev
3
- - repositories:
4
- - name: stack
5
- charts:
6
- - api-server
7
- - authz-server
8
- - emailer
9
- - message-processor
10
- - name: leverege
11
- charts:
12
- - pubsub-pulse
13
- - pusher
14
- - overdose
15
- - name: cox-health
16
- charts:
17
- - actions-server
18
- - analytics-server
19
- - centrak-healthz
20
- - centrak-ingestor
@@ -1,96 +0,0 @@
1
- #!/usr/bin/env node
2
- /*
3
- * chart-to-registry will...
4
- */
5
- import fs from 'node:fs'
6
-
7
- import chalk from 'chalk'
8
- import commandLineArgs from 'command-line-args'
9
- import commandLineUsage from 'command-line-usage'
10
- import { lt as semverLt } from 'semver'
11
- import YAML from 'js-yaml'
12
-
13
- import {
14
- condir,
15
- debug,
16
- errorExit,
17
- log,
18
- warning,
19
- getGitRootDirectory,
20
- parsePackageJson,
21
- parseHelmChart,
22
- shellCmd } from './Utils.mjs'
23
-
24
- const commandLineOptions = [ // Use commandLineOptions to tie into the Usage statements
25
- /* eslint-disable max-len */
26
- {
27
- name : 'location',
28
- type : String,
29
- description : '{green the location of the artifact registry the chart will be pushed to (default us-docker.pkg.dev)}',
30
- },
31
- {
32
- name : 'project',
33
- type : String,
34
- description : '{green the name of the google project containing the npmrc and slack config secrets (default leverege-registry)}',
35
- },
36
- {
37
- name : 'repository',
38
- type : String,
39
- description : '{green the target repository to receive the pushed chart}',
40
- },
41
- {
42
- name : 'dry-run',
43
- type : Boolean,
44
- description : '{yellow perform everything except the actual chart push}',
45
- },
46
- {
47
- name : 'help',
48
- type : Boolean,
49
- description : '{green display this help screen}',
50
- },
51
- /* eslint-enable max-len */
52
- ]
53
-
54
- const sections = [
55
- {
56
- header : 'Leverege Helm Chart Compass (for helmup)',
57
- content : `{green This tool helps helmup navigate the helm charts stored in the
58
- artifact-registries.}`
59
- },
60
- { header : 'Options',
61
- optionList : commandLineOptions,
62
- },
63
- ]
64
-
65
- const args = commandLineArgs( commandLineOptions, { camelCase : true, partial : true } )
66
- const usage = commandLineUsage( sections )
67
-
68
- if ( args.help ) {
69
- log( usage )
70
- process.exit( 0 )
71
- }
72
-
73
- /* eslint-disable no-underscore-dangle */
74
- if ( args._unknown ) {
75
- log( usage )
76
- log( `\nUnrecognized argument [${chalk.bold.red( args._unknown )}]\n` )
77
- process.exit( 1 )
78
- }
79
- /* eslint-enable no-underscore-dangle */
80
-
81
- const minNodejsVersion = '18.0.0'
82
- if ( semverLt( process.version, minNodejsVersion ) ) {
83
- errorExit( `\n***ERROR: must be running at least node ${minNodejsVersion}\n` )
84
- }
85
-
86
- // First of all, fail if we are not in a git repository
87
- let gitRoot
88
- try {
89
- gitRoot = await getGitRootDirectory()
90
- } catch ( error ) {
91
- errorExit( chalk.red.bold( error ), { errorCode : 5 } )
92
- }
93
-
94
- const chartCompass = YAML.load( fs.readFileSync( './registry-compass.yaml', 'utf8' ) )
95
-
96
- condir( { chartCompass }, '<==Navigation' )