Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: NPM registry package for garden #5087

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
7 changes: 4 additions & 3 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
# The workflow will run once the release has been published (i.e. is not in draft state anymore)
# and it will only run if it is not a pre-release. See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#release
types: [released]
workflow_dispatch:

permissions:
contents: read
Expand Down Expand Up @@ -33,13 +34,13 @@ jobs:
working-directory: ./core
run: |
CURRENT_CORE_VERSION="$(node -e "console.log(require('./package.json').version);")"
npm version "$CURRENT_CORE_VERSION-edge.$SHORT_SHA"
npm publish --tag edge
lerna version "$CURRENT_CORE_VERSION-edge.$SHORT_SHA" --no-git-tag-version --no-push --yes
lerna publish -from-package --dist-tag edge --yes
- name: Publish stable version if normal release
if: github.event.release.prerelease != true
working-directory: ./core
run: |
npm publish
lerna publish from-package --yes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add some documentation how exactly the process works that increments the package version to the correct version number?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TimBeyer sure! In a code comment?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could leave a few short comments in here and then more detailed in https://github.com/garden-io/garden/blob/main/RELEASE_PROCESS.md


release-homebrew:
uses: ./.github/workflows/reusable-create-homebrew-pr.yml
Expand Down
1 change: 1 addition & 0 deletions cli/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
static
19 changes: 19 additions & 0 deletions cli/bin/garden
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
#!/usr/bin/env node
const path = require('path');

process.env.NODE_OPTIONS = "max-old-space-size=4096 max-semi-space-size=64";
process.env.STATIC_DIR = path.join(__dirname, '..', 'static');

const fs = require('fs');
const exec = require('child_process').exec;

const gitDir = path.join(process.env.STATIC_DIR, '.git');

if (!fs.existsSync(gitDir)) {
exec(`git init ${process.env.STATIC_DIR}`, (error, stdout, stderr) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a little early in the code to call git init; Also if we generally call git init on the static directory if it isn't a git repository yet (until we fixed #4477) we also fix a windows issue (#5030 and #2614)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stefreak, where would you move this call?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should finalize and merge #5120 before merging this, so we don't have to call it at all.

if (error) {
console.error(`Error: ${error.message}`);
}
if (stderr) {
console.error(`Stderr: ${stderr}`);
}
});
}

if (process.env.GARDEN_ENABLE_PROFILING === "1" || process.env.GARDEN_ENABLE_PROFILING === "true") {
// Patch require to profile module loading
Expand Down
10 changes: 6 additions & 4 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
"npm": ">=8"
},
"preferGlobal": true,
"private": true,
"private": false,
"files": [
"build"
"build",
"static",
"bin"
],
"bin": {
"garden": "bin/garden"
Expand Down Expand Up @@ -50,7 +52,7 @@
},
"scripts": {
"add-version-files": "node build/src/add-version-files.js",
"build": "tsc --build . --verbose && yarn run add-version-files && yarn run generate-docs",
"build": "shx cp -r ../static ./static && git init ./static && tsc --build . --verbose && yarn run add-version-files && yarn run generate-docs",
"check-package-lock": "git diff-index --quiet HEAD -- yarn.lock || (echo 'yarn.lock is dirty!' && exit 1)",
"clean": "shx rm -rf build dist",
"fix-format": "prettier --write \"{src,test}/**/*.ts\"",
Expand All @@ -72,4 +74,4 @@
"pkg"
]
}
}
}
1 change: 1 addition & 0 deletions core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"access": "public"
},
"main": "build/src/index.js",
"private": false,
"types": "build/src/index.d.ts",
"dependencies": {
"@codenamize/codenamize": "^1.1.1",
Expand Down
2 changes: 1 addition & 1 deletion core/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const defaultGitScanMode: GitScanMode = "subtree"

export const GARDEN_CORE_ROOT = isPkg ? resolve(process.execPath, "..") : resolve(__dirname, "..", "..")
export const GARDEN_CLI_ROOT = isPkg ? resolve(process.execPath, "..") : resolve(GARDEN_CORE_ROOT, "..", "cli")
export const STATIC_DIR = isPkg ? resolve(process.execPath, "..", "static") : resolve(GARDEN_CORE_ROOT, "..", "static")
export const STATIC_DIR = process.env.STATIC_DIR || (isPkg ? resolve(process.execPath, "..", "static") : resolve(GARDEN_CORE_ROOT, "..", "static"))
export const DEFAULT_GARDEN_DIR_NAME = ".garden"
export const MUTAGEN_DIR_NAME = "mutagen"
export const LOGS_DIR_NAME = "logs"
Expand Down
16 changes: 16 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"version": "0.13.13",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this version get updated correctly with every release publishing step?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! lerna can automatically bump versions according to one of a number of strategies.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I mean is, does this number here get updated and committed back or is this just a placeholder of sorts?

"npmClient": "yarn",
"packages": [
"cli",
"core",
"plugins/conftest",
"plugins/conftest-container",
"plugins/conftest-kubernetes",
"plugins/jib",
"plugins/pulumi",
"plugins/terraform",
"sdk"
]
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"gulp": "^4.0.2",
"handlebars": "^4.7.6",
"husky": "^4.2.5",
"lerna": "^7.2.0",
"lodash": "^4.17.21",
"markdown-link-check": "^3.11.2",
"minimatch": "^3.0.4",
Expand Down
1 change: 1 addition & 0 deletions plugins/conftest-container/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.ts
1 change: 1 addition & 0 deletions plugins/conftest-container/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.13.13",
"description": "Auto-generator for the conftest plugin and Garden container modules",
"main": "index.js",
"private": "false",
"dependencies": {
"@garden-io/core": "*",
"@garden-io/garden-conftest": "*",
Expand Down
1 change: 1 addition & 0 deletions plugins/conftest-kubernetes/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.ts
2 changes: 1 addition & 1 deletion plugins/conftest-kubernetes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.13.13",
"description": "Auto-generator for the conftest plugin and Garden kubernetes/helm modules",
"main": "index.js",
"private": true,
"private": false,
"dependencies": {
"@garden-io/core": "*",
"@garden-io/garden-conftest": "*",
Expand Down
1 change: 1 addition & 0 deletions plugins/conftest/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.ts
2 changes: 1 addition & 1 deletion plugins/conftest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.13.13",
"description": "conftest plugin for Garden",
"main": "index.js",
"private": true,
"private": false,
"dependencies": {
"@garden-io/core": "*",
"@garden-io/sdk": "*",
Expand Down
1 change: 1 addition & 0 deletions plugins/jib/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.ts
1 change: 0 additions & 1 deletion plugins/jib/.prettierrc.json

This file was deleted.

8 changes: 8 additions & 0 deletions plugins/jib/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"arrowParens": "always",
"printWidth": 120,
"quoteProps": "consistent",
"semi": false,
"trailingComma": "es5",
"tabWidth": 2
}
1 change: 1 addition & 0 deletions plugins/jib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.13.13",
"description": "Jib container plugin for Garden",
"main": "index.js",
"private": false,
"dependencies": {
"@garden-io/core": "*",
"@garden-io/sdk": "*",
Expand Down
1 change: 1 addition & 0 deletions plugins/pulumi/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.ts
1 change: 1 addition & 0 deletions plugins/pulumi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.13.13",
"description": "Pulumi plugin for Garden",
"main": "index.js",
"private": false,
"dependencies": {
"@garden-io/core": "*",
"@garden-io/sdk": "*",
Expand Down
1 change: 1 addition & 0 deletions plugins/terraform/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.ts
1 change: 1 addition & 0 deletions plugins/terraform/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.13.13",
"description": "Terraform plugin for Garden",
"main": "index.js",
"private": false,
"dependencies": {
"@garden-io/core": "*",
"@garden-io/sdk": "*",
Expand Down
1 change: 0 additions & 1 deletion sdk/.prettierrc.json

This file was deleted.

8 changes: 8 additions & 0 deletions sdk/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"arrowParens": "always",
"printWidth": 120,
"quoteProps": "consistent",
"semi": false,
"trailingComma": "es5",
"tabWidth": 2
}
5 changes: 1 addition & 4 deletions sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
"npm": ">=8"
},
"preferGlobal": true,
"private": true,
"files": [
"build"
],
"private": false,
"main": "index.js",
"dependencies": {
"@garden-io/core": "*",
Expand Down
1 change: 1 addition & 0 deletions support/alpine.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ COPY --chown=$USER:root --from=aws-builder /usr/bin/aws-iam-authenticator /usr/b
#
# gcloud base
#

FROM google/cloud-sdk:445.0.0-alpine@sha256:0e934ffbe78ccceafe352b137d5ae442e2cb57ceda2d5c1c655af51aff53d158 as gcloud-base

RUN gcloud components install kubectl gke-gcloud-auth-plugin --quiet
Expand Down