Skip to content

Commit a60d799

Browse files
committed
Merge branch 'feature/CG-426' into 'master'
Homebrew release code Closes CG-426 See merge request auto-cloud/cloudgraph/cli!190
2 parents 953f519 + 9c11296 commit a60d799

8 files changed

Lines changed: 1497 additions & 53 deletions

File tree

.gitlab-ci.yml

Lines changed: 70 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
---
2+
.install-packages: &install-packages
3+
- apk --quiet --no-progress --update --no-cache add git openssh curl
4+
- ln -s /usr/bin/sha256sum /usr/bin/shasum
5+
26
.configure-registry: &configure-registry
3-
- apk --quiet --no-progress --update --no-cache add git openssh
47
- |
58
{
69
echo "//registry.npmjs.com/:_authToken=${NPM_TOKEN}"
@@ -12,9 +15,31 @@
1215
echo "\"//registry.npmjs.com/:_authToken\" \"${NPM_TOKEN}\""
1316
} | tee -a .yarnrc
1417
- NODE_ENV=cicd yarn install --frozen-lockfile --cache-folder .npm --prefer-offline
18+
19+
.configure-ssh: &configure-ssh
20+
- mkdir -p ~/.ssh
21+
- chmod 700 ~/.ssh
22+
- echo "$GITHUB_SSH_KEY" | tr -d '\r' > ~/.ssh/github_autodeploy
23+
- chmod 600 ~/.ssh/github_autodeploy
24+
- |
25+
{
26+
echo "Host github.com"
27+
echo "HostName github.com"
28+
echo "User git"
29+
echo "PreferredAuthentications publickey"
30+
echo "Port 22"
31+
echo "TCPKeepAlive yes"
32+
echo "IdentitiesOnly yes"
33+
echo "AddKeysToAgent yes"
34+
echo "IdentityFile ~/.ssh/github_autodeploy"
35+
echo "StrictHostKeyChecking no"
36+
} | tee -a /root/.ssh/config
37+
- chmod 0600 /root/.ssh/config
38+
1539
default:
1640
image: node:16-alpine
1741
before_script:
42+
- *install-packages
1843
- *configure-registry
1944
cache:
2045
key: ${CI_COMMIT_REF_SLUG}
@@ -37,7 +62,6 @@ stages:
3762
- notify
3863

3964
build:
40-
image: node:16-alpine
4165
stage: build
4266
rules:
4367
- if: $CI_COMMIT_TAG
@@ -50,7 +74,6 @@ build:
5074
- yarn prepack
5175

5276
lint:
53-
image: node:16-alpine
5477
stage: test
5578
rules:
5679
- when: always
@@ -66,7 +89,6 @@ lint:
6689
# - yarn test
6790

6891
semantic release:
69-
image: node:16-alpine
7092
stage: release
7193
rules:
7294
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_COMMIT_MESSAGE =~ /^chore\(release\)/'
@@ -83,10 +105,53 @@ semantic release:
83105
# Disable Husky for the git step of semantic release (handles all versions, env var name changed in v6)
84106
HUSKY_SKIP_HOOKS: 1
85107
HUSKY: 0
108+
script:
109+
- npx semantic-release -r $CI_PROJECT_URL
110+
111+
homebrew:
112+
image: node:16
113+
stage: release
114+
rules:
115+
- if: $CI_COMMIT_BRANCH
116+
when: never
117+
- if: $CI_COMMIT_TAG =~ /alpha/
118+
when: never
119+
- if: $CI_COMMIT_TAG =~ /beta/
120+
when: never
121+
- if: $CI_COMMIT_TAG
122+
when: always
123+
variables:
124+
# Set git commit identity
125+
GIT_AUTHOR_NAME: 'AutoCloud Deploy Bot'
126+
GIT_AUTHOR_EMAIL: 'no-reply@loudcloud.dev'
127+
GIT_COMMITTER_NAME: 'AutoCloud Deploy Bot'
128+
GIT_COMMITTER_EMAIL: 'no-reply@loudcloud.dev'
86129
before_script:
130+
# - *install-packages
87131
- *configure-registry
132+
- *configure-ssh
133+
- mkdir -p /root/.aws
134+
- |
135+
cat << EOF > /root/.aws/config
136+
[default]
137+
region=us-east-1
138+
output=json
139+
140+
[profile autocloud-iac]
141+
role_arn = ${AWS_ROLE_ARN}
142+
source_profile = default
143+
EOF
144+
- |
145+
cat << EOF > /root/.aws/credentials
146+
[default]
147+
aws_access_key_id = ${AWS_ACCESS_KEY_ID}
148+
aws_secret_access_key = ${AWS_SECRET_ACCESS_KEY}
149+
EOF
150+
- export AWS_SDK_LOAD_CONFIG=true
151+
- export AWS_PROFILE=autocloud-iac
88152
script:
89-
- npx semantic-release -r $CI_PROJECT_URL
153+
- yarn build
154+
- yarn homebrew
90155

91156
.curlcmd: &curlcmd >
92157
curl
@@ -96,7 +161,6 @@ semantic release:
96161
$SLACK_API_ENDPOINT
97162

98163
notify:
99-
image: alpine:latest
100164
stage: notify
101165
rules:
102166
- if: $CI_COMMIT_TAG

package.json

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"live-plugin-manager": "0.15.1",
4242
"lodash": "^4.17.21",
4343
"npm": "^8.1.2",
44+
"oclif": "^2.3.0",
4445
"open": "^8.2.1",
4546
"semver": "^7.3.5",
4647
"tslib": "^1"
@@ -65,6 +66,7 @@
6566
"@types/pino": "^6.3.8",
6667
"@typescript-eslint/eslint-plugin": "^4.28.5",
6768
"@typescript-eslint/parser": "^4.28.5",
69+
"aws-sdk": "^2.1060.0",
6870
"chai": "^4.3.4",
6971
"cpx": "^1.5.0",
7072
"cross-env": "^7.0.3",
@@ -77,6 +79,8 @@
7779
"jest": "^27.1.0",
7880
"jest-diff": "^27.1.0",
7981
"lint-staged": "^11.1.1",
82+
"mkdirp": "^1.0.4",
83+
"rimraf": "^3.0.2",
8084
"semantic-release": "^17.4.4",
8185
"ts-jest": "^27.0.5",
8286
"ts-node": "^10.2.1",
@@ -102,15 +106,23 @@
102106
"plugins": [
103107
"@oclif/plugin-help",
104108
"@tiagonapoli/oclif-plugin-spaced-commands"
105-
]
109+
],
110+
"update": {
111+
"s3": {
112+
"bucket": "cloudgraph-production-cli-assets"
113+
},
114+
"node": {
115+
"version": "16.0.0"
116+
}
117+
}
106118
},
107119
"repository": "github:cloudgraphdev/cli",
108120
"scripts": {
109-
"build": "yarn prepack",
121+
"build": "yarn prepack && oclif-dev pack -t linux-x64,linux-arm,darwin-x64,darwin-arm64 && yarn postpack",
110122
"launch": "./bin/run launch",
111123
"postpack": "rm -f oclif.manifest.json",
112124
"posttest": "eslint . --ext .ts --config .eslintrc.json",
113-
"prepack": "rm -rf lib && tsc -b && oclif-dev manifest && oclif-dev readme && yarn cpx 'src/scripts/*' lib/scripts",
125+
"prepack": "rm -rf lib && npx tsc -b --force && oclif-dev manifest && oclif-dev readme && yarn cpx 'src/scripts/*' lib/scripts",
114126
"run:init": "cross-env NODE_ENV=development ./bin/run init",
115127
"run:init:aws": "cross-env NODE_ENV=development ./bin/run init aws",
116128
"run:load": "cross-env NODE_ENV=development ./bin/run load",
@@ -124,9 +136,10 @@
124136
"run:policy": "cross-env NODE_ENV=test ./bin/run policy",
125137
"test": "cross-env CG_DEBUG=-1 NODE_ENV=test jest --coverage=true --detectOpenHandles --runInBand --forceExit",
126138
"test:debug": "cross-env CG_DEBUG=5 NODE_ENV=test jest --coverage=false --detectOpenHandles --runInBand --forceExit",
127-
"version": "oclif-dev readme && git add README.md",
139+
"version": "oclif readme && git add README.md",
128140
"lint": "eslint --config .eslintrc.json --ext .js,.ts ./",
129-
"lint:fix": "eslint --fix --config .eslintrc.json --ext .js,.ts ./"
141+
"lint:fix": "eslint --fix --config .eslintrc.json --ext .js,.ts ./",
142+
"homebrew": "node release/scripts/homebrew.js"
130143
},
131144
"husky": {
132145
"hooks": {

release/scripts/_github_setup

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
# if [[ "${CIRCLECI:-}" != "true" ]]; then
6+
# echo "skipping github setup since not on circle"
7+
# exit
8+
# fi
9+
10+
git config --global user.email "149658+cloudgraph-cli@users.noreply.github.com"
11+
git config --global user.name "cloudgraph-cli"

0 commit comments

Comments
 (0)