From d6e223938780a721e65d48f59e31efff08e3301a Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Mon, 8 Apr 2024 11:39:51 +0200 Subject: [PATCH 01/15] wip --- Dockerfile | 30 ++++++++++++++++++++++++++++++ docker/setup.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 Dockerfile create mode 100755 docker/setup.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..2772b29a16 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +FROM golang:alpine as builder + +RUN apk add jq + +WORKDIR /build + +# # Copy repo to wd +# COPY . . + +# # Build CLI binary +# RUN go mod download && go mod verify +# RUN CGO_ENABLED=0 go build -o /build/databricks + +COPY ./docker/setup.sh ./docker/setup.sh +COPY ./databricks ./databricks + +ENV BUILD_ARCH "arm64" +RUN ./docker/setup.sh + +# Construct final image +FROM alpine:3.19 + + + +# # COPY --from=builder /build/databricks /app/databricks +# # COPY --from=builder /build/bundle/internal/tf/codegen/tmp/bin/terraform /app/terraform/terraform +# # COPY --from=builder /build/bundle/internal/tf/codegen/tmp/ + +# # CONTINUE: stop using the Go script. It does not work. Instead rely on a new shell +# # script that I write. diff --git a/docker/setup.sh b/docker/setup.sh new file mode 100755 index 0000000000..3a0818c85d --- /dev/null +++ b/docker/setup.sh @@ -0,0 +1,26 @@ +#!/bin/sh +set -euo pipefail + +# TODO: Add assertions that this script is build called from /build + + + +TF_VERSION=$(/build/databricks bundle debug terraform --output json | jq .terraform.version -r) +PROVIDER_VERSION=$(/build/databricks bundle debug terraform --output json | jq .terraform.providerVersion -r) +# BUILD_ARCH="${1:-invalid}" + +# TODO: Test this +# if [ "$BUILD_ARCH" = "invalid" ]; then +# exit 1 +# fi + +# TODO: add check that build arch is either amd64 or arm64 +mkdir -p zip + +# Download the terraform binary +wget https://releases.hashicorp.com/terraform/${TF_VERSION}/terraform_${TF_VERSION}_linux_${BUILD_ARCH}.zip -O zip/terraform.zip +unzip zip/terraform.zip -d zip/terraform + +# Download the databricks terraform provider +wget https://github.com/databricks/terraform-provider-databricks/releases/download/v${PROVIDER_VERSION}/terraform-provider-databricks_${PROVIDER_VERSION}_linux_${BUILD_ARCH}.zip -O zip/provider.zip +unzip zip/provider.zip -d zip/provider From e4e000b3354ea14a09c369bf35ae898b17f48125 Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Tue, 9 Apr 2024 18:40:37 +0200 Subject: [PATCH 02/15] Add docker containers for the CLI --- .github/workflows/release.yml | 184 ++++++++++++++------------- .goreleaser.yaml | 28 ++++ Dockerfile | 34 +++-- bundle/deploy/terraform/init.go | 27 +++- bundle/deploy/terraform/init_test.go | 58 +++++++++ docker/config.tfrc | 6 + docker/setup.sh | 38 +++--- 7 files changed, 245 insertions(+), 130 deletions(-) create mode 100644 docker/config.tfrc diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 43ceea2cdd..8df02ef748 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,6 +24,12 @@ jobs: with: go-version: 1.21.x + - uses: "docker/login-action@v3" + with: + registry: "ghcr.io" + username: "${{ github.actor }}" + password: "${{ secrets.GITHUB_TOKEN }}" + - name: Run GoReleaser id: releaser uses: goreleaser/goreleaser-action@v4 @@ -33,99 +39,99 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - create-setup-cli-release-pr: - needs: goreleaser - runs-on: ubuntu-latest - steps: - - name: Set VERSION variable from tag - run: | - VERSION=${{ github.ref_name }} - echo "VERSION=${VERSION:1}" >> $GITHUB_ENV + # create-setup-cli-release-pr: + # needs: goreleaser + # runs-on: ubuntu-latest + # steps: + # - name: Set VERSION variable from tag + # run: | + # VERSION=${{ github.ref_name }} + # echo "VERSION=${VERSION:1}" >> $GITHUB_ENV - - name: Update setup-cli - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.DECO_GITHUB_TOKEN }} - script: | - await github.rest.actions.createWorkflowDispatch({ - owner: 'databricks', - repo: 'setup-cli', - workflow_id: 'release-pr.yml', - ref: 'main', - inputs: { - version: "${{ env.VERSION }}", - } - }); + # - name: Update setup-cli + # uses: actions/github-script@v6 + # with: + # github-token: ${{ secrets.DECO_GITHUB_TOKEN }} + # script: | + # await github.rest.actions.createWorkflowDispatch({ + # owner: 'databricks', + # repo: 'setup-cli', + # workflow_id: 'release-pr.yml', + # ref: 'main', + # inputs: { + # version: "${{ env.VERSION }}", + # } + # }); - create-homebrew-tap-release-pr: - needs: goreleaser - runs-on: ubuntu-latest - steps: - - name: Set VERSION variable from tag - run: | - VERSION=${{ github.ref_name }} - echo "VERSION=${VERSION:1}" >> $GITHUB_ENV + # create-homebrew-tap-release-pr: + # needs: goreleaser + # runs-on: ubuntu-latest + # steps: + # - name: Set VERSION variable from tag + # run: | + # VERSION=${{ github.ref_name }} + # echo "VERSION=${VERSION:1}" >> $GITHUB_ENV - - name: Update homebrew-tap - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.DECO_GITHUB_TOKEN }} - script: | - let artifacts = JSON.parse('${{ needs.goreleaser.outputs.artifacts }}') - artifacts = artifacts.filter(a => a.type == "Archive") - artifacts = new Map( - artifacts.map(a => [ - a.goos + "_" + a.goarch, - a.extra.Checksum.replace("sha256:", "") - ]) - ) + # - name: Update homebrew-tap + # uses: actions/github-script@v6 + # with: + # github-token: ${{ secrets.DECO_GITHUB_TOKEN }} + # script: | + # let artifacts = JSON.parse('${{ needs.goreleaser.outputs.artifacts }}') + # artifacts = artifacts.filter(a => a.type == "Archive") + # artifacts = new Map( + # artifacts.map(a => [ + # a.goos + "_" + a.goarch, + # a.extra.Checksum.replace("sha256:", "") + # ]) + # ) - await github.rest.actions.createWorkflowDispatch({ - owner: 'databricks', - repo: 'homebrew-tap', - workflow_id: 'release-pr.yml', - ref: 'main', - inputs: { - version: "${{ env.VERSION }}", - darwin_amd64_sha: artifacts.get('darwin_amd64'), - darwin_arm64_sha: artifacts.get('darwin_arm64'), - linux_amd64_sha: artifacts.get('linux_amd64'), - linux_arm64_sha: artifacts.get('linux_arm64') - } - }); + # await github.rest.actions.createWorkflowDispatch({ + # owner: 'databricks', + # repo: 'homebrew-tap', + # workflow_id: 'release-pr.yml', + # ref: 'main', + # inputs: { + # version: "${{ env.VERSION }}", + # darwin_amd64_sha: artifacts.get('darwin_amd64'), + # darwin_arm64_sha: artifacts.get('darwin_arm64'), + # linux_amd64_sha: artifacts.get('linux_amd64'), + # linux_arm64_sha: artifacts.get('linux_arm64') + # } + # }); - create-vscode-extension-update-pr: - needs: goreleaser - runs-on: ubuntu-latest - steps: - - name: Set VERSION variable from tag - run: | - VERSION=${{ github.ref_name }} - echo "VERSION=${VERSION:1}" >> $GITHUB_ENV + # create-vscode-extension-update-pr: + # needs: goreleaser + # runs-on: ubuntu-latest + # steps: + # - name: Set VERSION variable from tag + # run: | + # VERSION=${{ github.ref_name }} + # echo "VERSION=${VERSION:1}" >> $GITHUB_ENV - - name: Update CLI version in the VSCode extension - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.DECO_GITHUB_TOKEN }} - script: | - await github.rest.actions.createWorkflowDispatch({ - owner: 'databricks', - repo: 'databricks-vscode', - workflow_id: 'update-cli-version.yml', - ref: 'main', - inputs: { - version: "${{ env.VERSION }}", - } - }); + # - name: Update CLI version in the VSCode extension + # uses: actions/github-script@v6 + # with: + # github-token: ${{ secrets.DECO_GITHUB_TOKEN }} + # script: | + # await github.rest.actions.createWorkflowDispatch({ + # owner: 'databricks', + # repo: 'databricks-vscode', + # workflow_id: 'update-cli-version.yml', + # ref: 'main', + # inputs: { + # version: "${{ env.VERSION }}", + # } + # }); - publish-to-winget-pkgs: - needs: goreleaser - runs-on: windows-latest - environment: release - steps: - - uses: vedantmgoyal2009/winget-releaser@93fd8b606a1672ec3e5c6c3bb19426be68d1a8b0 # https://github.com/vedantmgoyal2009/winget-releaser/releases/tag/v2 - with: - identifier: Databricks.DatabricksCLI - installers-regex: 'windows_.*\.zip$' # Only windows releases - token: ${{ secrets.ENG_DEV_ECOSYSTEM_BOT_TOKEN }} - fork-user: eng-dev-ecosystem-bot + # publish-to-winget-pkgs: + # needs: goreleaser + # runs-on: windows-latest + # environment: release + # steps: + # - uses: vedantmgoyal2009/winget-releaser@93fd8b606a1672ec3e5c6c3bb19426be68d1a8b0 # https://github.com/vedantmgoyal2009/winget-releaser/releases/tag/v2 + # with: + # identifier: Databricks.DatabricksCLI + # installers-regex: 'windows_.*\.zip$' # Only windows releases + # token: ${{ secrets.ENG_DEV_ECOSYSTEM_BOT_TOKEN }} + # fork-user: eng-dev-ecosystem-bot diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 0cf87a9ce1..3355212bd7 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -45,6 +45,34 @@ archives: # file name then additional logic to clean up older builds would be needed. name_template: 'databricks_cli_{{ if not .IsSnapshot }}{{ .Version }}_{{ end }}{{ .Os }}_{{ .Arch }}' +#TODO: Add some documentation / a readme to the docker directory on how to maintain this. + +dockers: + - id: arm64 + goarch: arm64 + image_templates: + # Docker tags can't have "+" in them, so we replace it with "-" + - 'ghcr.io/databricks/cli:{{replace .Version "+" "-"}}-arm64' + build_flag_templates: + - "--build-arg=ARCH=arm64" + - "--platform=linux/arm64" + extra_files: + - "./docker/config.tfrc" + - "./docker/setup.sh" + + - id: amd64 + goarch: amd64 + image_templates: + # Docker tags can't have "+" in them, so we replace it with "-" + - 'ghcr.io/databricks/cli:{{replace .Version "+" "-"}}-amd64' + build_flag_templates: + - "--build-arg=ARCH=amd64" + - "--platform=linux/amd64" + extra_files: + - "./docker/config.tfrc" + - "./docker/setup.sh" + + checksum: name_template: 'databricks_cli_{{ .Version }}_SHA256SUMS' algorithm: sha256 diff --git a/Dockerfile b/Dockerfile index 2772b29a16..e3f11cd4f5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,30 +1,28 @@ -FROM golang:alpine as builder +FROM alpine:3.19 as builder RUN apk add jq WORKDIR /build -# # Copy repo to wd -# COPY . . +# TODO: Copt the entire repo to the build directory. This is temp for testing. +COPY ./docker/setup.sh /build/docker/setup.sh +COPY ./databricks /app/databricks +COPY ./docker/config.tfrc /app/config/config.tfrc -# # Build CLI binary -# RUN go mod download && go mod verify -# RUN CGO_ENABLED=0 go build -o /build/databricks +# TODO: Parameterize this in goreleaser. Make this a build arg and pass it +# as a positional argument to the setup.sh script. +ARG ARCH +RUN /build/docker/setup.sh -COPY ./docker/setup.sh ./docker/setup.sh -COPY ./databricks ./databricks -ENV BUILD_ARCH "arm64" -RUN ./docker/setup.sh - -# Construct final image +# Start from a fresh base image, to remove any build artifacts and scripts. FROM alpine:3.19 +ENV DATABRICKS_TF_EXEC_PATH "/app/bin/terraform" +ENV DATABRICKS_TF_CLI_CONFIG_FILE "/app/config/config.tfrc" +ENV PATH="/app:${PATH}" +COPY --from=builder /app /app -# # COPY --from=builder /build/databricks /app/databricks -# # COPY --from=builder /build/bundle/internal/tf/codegen/tmp/bin/terraform /app/terraform/terraform -# # COPY --from=builder /build/bundle/internal/tf/codegen/tmp/ - -# # CONTINUE: stop using the Go script. It does not work. Instead rely on a new shell -# # script that I write. +ENTRYPOINT ["/app/databricks"] +CMD ["-h"] diff --git a/bundle/deploy/terraform/init.go b/bundle/deploy/terraform/init.go index 9f42353104..bb02431450 100644 --- a/bundle/deploy/terraform/init.go +++ b/bundle/deploy/terraform/init.go @@ -138,23 +138,36 @@ func inheritEnvVars(ctx context.Context, environ map[string]string) error { func getEnvVarWithMatchingVersion(ctx context.Context, envVarName string, versionVarName string, currentVersion string) (string, error) { envValue := env.Get(ctx, envVarName) versionValue := env.Get(ctx, versionVarName) - if envValue == "" || versionValue == "" { - log.Debugf(ctx, "%s and %s aren't defined", envVarName, versionVarName) - return "", nil - } - if versionValue != currentVersion { - log.Debugf(ctx, "%s as %s does not match the current version %s, ignoring %s", versionVarName, versionValue, currentVersion, envVarName) + + // return early if the environment variable is not set + if envValue == "" { + log.Debugf(ctx, "%s is not defined", envVarName) return "", nil } + + // If the path does not exist, we return early. _, err := os.Stat(envValue) if err != nil { if os.IsNotExist(err) { - log.Debugf(ctx, "%s at %s does not exist, ignoring %s", envVarName, envValue, versionVarName) + log.Debugf(ctx, "%s at %s does not exist", envVarName, envValue) return "", nil } else { return "", err } } + + // If the version environment variable is not set, we directly return the value of the environment variable. + if versionValue == "" { + return envValue, nil + } + + // If the version environment variable is set, we check if it matches the current version. + // If it does not match, we ignore the environment variable. + // if it matches, we check if the path exists. + if versionValue != currentVersion { + log.Debugf(ctx, "%s as %s does not match the current version %s, ignoring %s", versionVarName, versionValue, currentVersion, envVarName) + return "", nil + } return envValue, nil } diff --git a/bundle/deploy/terraform/init_test.go b/bundle/deploy/terraform/init_test.go index ece897193a..ffc2158516 100644 --- a/bundle/deploy/terraform/init_test.go +++ b/bundle/deploy/terraform/init_test.go @@ -12,6 +12,7 @@ import ( "github.com/databricks/cli/bundle" "github.com/databricks/cli/bundle/config" "github.com/databricks/cli/bundle/internal/tf/schema" + "github.com/databricks/cli/internal/testutil" "github.com/databricks/cli/libs/env" "github.com/hashicorp/hc-install/product" "github.com/stretchr/testify/assert" @@ -392,3 +393,60 @@ func createTempFile(t *testing.T, dest string, name string, executable bool) str } return binPath } + +func TestGetEnvVarWithMatchingVersion(t *testing.T) { + envVarName := "FOO" + versionVarName := "FOO_VERSION" + + tmp := t.TempDir() + testutil.Touch(t, tmp, "bar") + + var tc = []struct { + envValue string + versionValue string + currentVersion string + expected string + }{ + { + envValue: filepath.Join(tmp, "bar"), + versionValue: "1.2.3", + currentVersion: "1.2.3", + expected: filepath.Join(tmp, "bar"), + }, + { + envValue: filepath.Join(tmp, "does-not-exist"), + versionValue: "1.2.3", + currentVersion: "1.2.3", + expected: "", + }, + { + envValue: filepath.Join(tmp, "bar"), + versionValue: "1.2.3", + currentVersion: "1.2.4", + expected: "", + }, + { + envValue: "", + versionValue: "1.2.3", + currentVersion: "1.2.3", + expected: "", + }, + { + envValue: filepath.Join(tmp, "bar"), + versionValue: "", + currentVersion: "1.2.3", + expected: filepath.Join(tmp, "bar"), + }, + } + + for _, c := range tc { + t.Run("", func(t *testing.T) { + t.Setenv(envVarName, c.envValue) + t.Setenv(versionVarName, c.versionValue) + + actual, err := getEnvVarWithMatchingVersion(context.Background(), envVarName, versionVarName, c.currentVersion) + require.NoError(t, err) + assert.Equal(t, c.expected, actual) + }) + } +} diff --git a/docker/config.tfrc b/docker/config.tfrc new file mode 100644 index 0000000000..123f6d6398 --- /dev/null +++ b/docker/config.tfrc @@ -0,0 +1,6 @@ +provider_installation { + filesystem_mirror { + path = "/app/providers" + include = ["registry.terraform.io/databricks/databricks"] + } +} diff --git a/docker/setup.sh b/docker/setup.sh index 3a0818c85d..03fe2c680a 100755 --- a/docker/setup.sh +++ b/docker/setup.sh @@ -1,26 +1,32 @@ #!/bin/sh set -euo pipefail -# TODO: Add assertions that this script is build called from /build +DATABRICKS_TF_VERSION=$(/app/databricks bundle debug terraform --output json | jq -r .terraform.version) +DATABRICKS_TF_PROVIDER_VERSION=$(/app/databricks bundle debug terraform --output json | jq -r .terraform.providerVersion) +# Download the terraform binary +mkdir -p zip +wget https://releases.hashicorp.com/terraform/${DATABRICKS_TF_VERSION}/terraform_${DATABRICKS_TF_VERSION}_linux_${ARCH}.zip -O zip/terraform.zip +unzip zip/terraform.zip -d zip/terraform +mkdir -p /app/bin +mv zip/terraform/terraform /app/bin/terraform +# Download the provider plugin +TF_PROVIDER_NAME=terraform-provider-databricks_${DATABRICKS_TF_PROVIDER_VERSION}_linux_${ARCH}.zip +mkdir -p /app/providers/registry.terraform.io/databricks/databricks +wget https://github.com/databricks/terraform-provider-databricks/releases/download/v${DATABRICKS_TF_PROVIDER_VERSION}/${TF_PROVIDER_NAME} -O /app/providers/registry.terraform.io/databricks/databricks/${TF_PROVIDER_NAME} -TF_VERSION=$(/build/databricks bundle debug terraform --output json | jq .terraform.version -r) -PROVIDER_VERSION=$(/build/databricks bundle debug terraform --output json | jq .terraform.providerVersion -r) -# BUILD_ARCH="${1:-invalid}" -# TODO: Test this -# if [ "$BUILD_ARCH" = "invalid" ]; then -# exit 1 -# fi +# TODO: document both the interactive and the non interactive workflows for +# working with DABs with the docker container. Execing into the container +# allows for a better iteration loop -# TODO: add check that build arch is either amd64 or arm64 -mkdir -p zip +# For the interactive devloop: +# docker run -it --entrypoint /bin/sh cli ... -# Download the terraform binary -wget https://releases.hashicorp.com/terraform/${TF_VERSION}/terraform_${TF_VERSION}_linux_${BUILD_ARCH}.zip -O zip/terraform.zip -unzip zip/terraform.zip -d zip/terraform +# For the non-interactive devloop: +# docker run cli ... + +# TODO: End to end test for this image? -# Download the databricks terraform provider -wget https://github.com/databricks/terraform-provider-databricks/releases/download/v${PROVIDER_VERSION}/terraform-provider-databricks_${PROVIDER_VERSION}_linux_${BUILD_ARCH}.zip -O zip/provider.zip -unzip zip/provider.zip -d zip/provider +# TODO: Final sanity check that the docker image is indeed airgapped. From fb9638ea174cc55172acd75d4f662ba417028e4b Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Tue, 9 Apr 2024 18:42:54 +0200 Subject: [PATCH 03/15] test with tag --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8df02ef748..8579af4956 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,6 +4,7 @@ on: push: tags: - "v*" + - "v0.0.0-test.docker" workflow_dispatch: From 846e2b4ce291745fc0965c8b162014f2dfd0cf33 Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Tue, 9 Apr 2024 19:28:10 +0200 Subject: [PATCH 04/15] try exec form --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e3f11cd4f5..35054792c2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM alpine:3.19 as builder -RUN apk add jq +RUN ["apk", "add", "jq"] WORKDIR /build From be9de772ca4bccf565086faf98a9ebe4d883e97f Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Wed, 10 Apr 2024 16:41:23 +0200 Subject: [PATCH 05/15] use qemu and buildx --- .github/workflows/release.yml | 3 +++ .goreleaser.yaml | 2 ++ 2 files changed, 5 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8579af4956..47c75eddb5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -31,6 +31,9 @@ jobs: username: "${{ github.actor }}" password: "${{ secrets.GITHUB_TOKEN }}" + - name: Set up QEMU dependency + uses: docker/setup-qemu-action@v3 + - name: Run GoReleaser id: releaser uses: goreleaser/goreleaser-action@v4 diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 3355212bd7..e7c8f6eafd 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -50,6 +50,7 @@ archives: dockers: - id: arm64 goarch: arm64 + use: buildx image_templates: # Docker tags can't have "+" in them, so we replace it with "-" - 'ghcr.io/databricks/cli:{{replace .Version "+" "-"}}-arm64' @@ -62,6 +63,7 @@ dockers: - id: amd64 goarch: amd64 + use: buildx image_templates: # Docker tags can't have "+" in them, so we replace it with "-" - 'ghcr.io/databricks/cli:{{replace .Version "+" "-"}}-amd64' From 82a4b32b62f76687096bc56779daaaa7d1136f36 Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Wed, 10 Apr 2024 18:03:46 +0200 Subject: [PATCH 06/15] cleanup --- .github/workflows/release.yml | 179 +++++++++++++++++----------------- .goreleaser.yaml | 2 +- 2 files changed, 90 insertions(+), 91 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 47c75eddb5..07dd5af866 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,7 +4,6 @@ on: push: tags: - "v*" - - "v0.0.0-test.docker" workflow_dispatch: @@ -43,99 +42,99 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # create-setup-cli-release-pr: - # needs: goreleaser - # runs-on: ubuntu-latest - # steps: - # - name: Set VERSION variable from tag - # run: | - # VERSION=${{ github.ref_name }} - # echo "VERSION=${VERSION:1}" >> $GITHUB_ENV + create-setup-cli-release-pr: + needs: goreleaser + runs-on: ubuntu-latest + steps: + - name: Set VERSION variable from tag + run: | + VERSION=${{ github.ref_name }} + echo "VERSION=${VERSION:1}" >> $GITHUB_ENV - # - name: Update setup-cli - # uses: actions/github-script@v6 - # with: - # github-token: ${{ secrets.DECO_GITHUB_TOKEN }} - # script: | - # await github.rest.actions.createWorkflowDispatch({ - # owner: 'databricks', - # repo: 'setup-cli', - # workflow_id: 'release-pr.yml', - # ref: 'main', - # inputs: { - # version: "${{ env.VERSION }}", - # } - # }); + - name: Update setup-cli + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.DECO_GITHUB_TOKEN }} + script: | + await github.rest.actions.createWorkflowDispatch({ + owner: 'databricks', + repo: 'setup-cli', + workflow_id: 'release-pr.yml', + ref: 'main', + inputs: { + version: "${{ env.VERSION }}", + } + }); - # create-homebrew-tap-release-pr: - # needs: goreleaser - # runs-on: ubuntu-latest - # steps: - # - name: Set VERSION variable from tag - # run: | - # VERSION=${{ github.ref_name }} - # echo "VERSION=${VERSION:1}" >> $GITHUB_ENV + create-homebrew-tap-release-pr: + needs: goreleaser + runs-on: ubuntu-latest + steps: + - name: Set VERSION variable from tag + run: | + VERSION=${{ github.ref_name }} + echo "VERSION=${VERSION:1}" >> $GITHUB_ENV - # - name: Update homebrew-tap - # uses: actions/github-script@v6 - # with: - # github-token: ${{ secrets.DECO_GITHUB_TOKEN }} - # script: | - # let artifacts = JSON.parse('${{ needs.goreleaser.outputs.artifacts }}') - # artifacts = artifacts.filter(a => a.type == "Archive") - # artifacts = new Map( - # artifacts.map(a => [ - # a.goos + "_" + a.goarch, - # a.extra.Checksum.replace("sha256:", "") - # ]) - # ) + - name: Update homebrew-tap + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.DECO_GITHUB_TOKEN }} + script: | + let artifacts = JSON.parse('${{ needs.goreleaser.outputs.artifacts }}') + artifacts = artifacts.filter(a => a.type == "Archive") + artifacts = new Map( + artifacts.map(a => [ + a.goos + "_" + a.goarch, + a.extra.Checksum.replace("sha256:", "") + ]) + ) - # await github.rest.actions.createWorkflowDispatch({ - # owner: 'databricks', - # repo: 'homebrew-tap', - # workflow_id: 'release-pr.yml', - # ref: 'main', - # inputs: { - # version: "${{ env.VERSION }}", - # darwin_amd64_sha: artifacts.get('darwin_amd64'), - # darwin_arm64_sha: artifacts.get('darwin_arm64'), - # linux_amd64_sha: artifacts.get('linux_amd64'), - # linux_arm64_sha: artifacts.get('linux_arm64') - # } - # }); + await github.rest.actions.createWorkflowDispatch({ + owner: 'databricks', + repo: 'homebrew-tap', + workflow_id: 'release-pr.yml', + ref: 'main', + inputs: { + version: "${{ env.VERSION }}", + darwin_amd64_sha: artifacts.get('darwin_amd64'), + darwin_arm64_sha: artifacts.get('darwin_arm64'), + linux_amd64_sha: artifacts.get('linux_amd64'), + linux_arm64_sha: artifacts.get('linux_arm64') + } + }); - # create-vscode-extension-update-pr: - # needs: goreleaser - # runs-on: ubuntu-latest - # steps: - # - name: Set VERSION variable from tag - # run: | - # VERSION=${{ github.ref_name }} - # echo "VERSION=${VERSION:1}" >> $GITHUB_ENV + create-vscode-extension-update-pr: + needs: goreleaser + runs-on: ubuntu-latest + steps: + - name: Set VERSION variable from tag + run: | + VERSION=${{ github.ref_name }} + echo "VERSION=${VERSION:1}" >> $GITHUB_ENV - # - name: Update CLI version in the VSCode extension - # uses: actions/github-script@v6 - # with: - # github-token: ${{ secrets.DECO_GITHUB_TOKEN }} - # script: | - # await github.rest.actions.createWorkflowDispatch({ - # owner: 'databricks', - # repo: 'databricks-vscode', - # workflow_id: 'update-cli-version.yml', - # ref: 'main', - # inputs: { - # version: "${{ env.VERSION }}", - # } - # }); + - name: Update CLI version in the VSCode extension + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.DECO_GITHUB_TOKEN }} + script: | + await github.rest.actions.createWorkflowDispatch({ + owner: 'databricks', + repo: 'databricks-vscode', + workflow_id: 'update-cli-version.yml', + ref: 'main', + inputs: { + version: "${{ env.VERSION }}", + } + }); - # publish-to-winget-pkgs: - # needs: goreleaser - # runs-on: windows-latest - # environment: release - # steps: - # - uses: vedantmgoyal2009/winget-releaser@93fd8b606a1672ec3e5c6c3bb19426be68d1a8b0 # https://github.com/vedantmgoyal2009/winget-releaser/releases/tag/v2 - # with: - # identifier: Databricks.DatabricksCLI - # installers-regex: 'windows_.*\.zip$' # Only windows releases - # token: ${{ secrets.ENG_DEV_ECOSYSTEM_BOT_TOKEN }} - # fork-user: eng-dev-ecosystem-bot + publish-to-winget-pkgs: + needs: goreleaser + runs-on: windows-latest + environment: release + steps: + - uses: vedantmgoyal2009/winget-releaser@93fd8b606a1672ec3e5c6c3bb19426be68d1a8b0 # https://github.com/vedantmgoyal2009/winget-releaser/releases/tag/v2 + with: + identifier: Databricks.DatabricksCLI + installers-regex: 'windows_.*\.zip$' # Only windows releases + token: ${{ secrets.ENG_DEV_ECOSYSTEM_BOT_TOKEN }} + fork-user: eng-dev-ecosystem-bot diff --git a/.goreleaser.yaml b/.goreleaser.yaml index e7c8f6eafd..9661261536 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -45,7 +45,7 @@ archives: # file name then additional logic to clean up older builds would be needed. name_template: 'databricks_cli_{{ if not .IsSnapshot }}{{ .Version }}_{{ end }}{{ .Os }}_{{ .Arch }}' -#TODO: Add some documentation / a readme to the docker directory on how to maintain this. +# TODO: Add some documentation / a readme to the docker directory on how to maintain this. dockers: - id: arm64 From 3b62c8479a3b350c5826d872c152d3106e960e59 Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Wed, 10 Apr 2024 18:05:46 +0200 Subject: [PATCH 07/15] more cleanup --- Dockerfile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 35054792c2..d4e7614c89 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,17 +4,13 @@ RUN ["apk", "add", "jq"] WORKDIR /build -# TODO: Copt the entire repo to the build directory. This is temp for testing. COPY ./docker/setup.sh /build/docker/setup.sh COPY ./databricks /app/databricks COPY ./docker/config.tfrc /app/config/config.tfrc -# TODO: Parameterize this in goreleaser. Make this a build arg and pass it -# as a positional argument to the setup.sh script. ARG ARCH RUN /build/docker/setup.sh - # Start from a fresh base image, to remove any build artifacts and scripts. FROM alpine:3.19 From 008283a153633b484d5fc6f8f6f6823fd52e84f6 Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Wed, 10 Apr 2024 18:08:55 +0200 Subject: [PATCH 08/15] some comments --- .github/workflows/release.yml | 2 ++ .goreleaser.yaml | 1 + 2 files changed, 3 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 07dd5af866..6600cc86dc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,6 +30,8 @@ jobs: username: "${{ github.actor }}" password: "${{ secrets.GITHUB_TOKEN }}" + # QEMU is required to build cross platform docker images using buildx. + # It's allows virtualization of the CPU architecture in software. - name: Set up QEMU dependency uses: docker/setup-qemu-action@v3 diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 9661261536..658f3f4d3d 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -50,6 +50,7 @@ archives: dockers: - id: arm64 goarch: arm64 + # We need to use buildx to build arm64 image on a amd64 machine. use: buildx image_templates: # Docker tags can't have "+" in them, so we replace it with "-" From 649f58c807ecc7c96bcab2455336e947767bdca6 Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Wed, 10 Apr 2024 18:09:57 +0200 Subject: [PATCH 09/15] - --- .github/workflows/release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6600cc86dc..b50bc7ef82 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,6 +24,8 @@ jobs: with: go-version: 1.21.x + # Log into the GitHub Container Registry. The goreleaser action will create + # the docker images and push them to the GitHub Container Registry. - uses: "docker/login-action@v3" with: registry: "ghcr.io" From 51da5c639e1f57ff668b91b6302c815540ce575b Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Wed, 10 Apr 2024 18:41:42 +0200 Subject: [PATCH 10/15] more comment cleanup --- .goreleaser.yaml | 2 -- docker/setup.sh | 15 --------------- 2 files changed, 17 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 658f3f4d3d..b1f95f00a6 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -45,8 +45,6 @@ archives: # file name then additional logic to clean up older builds would be needed. name_template: 'databricks_cli_{{ if not .IsSnapshot }}{{ .Version }}_{{ end }}{{ .Os }}_{{ .Arch }}' -# TODO: Add some documentation / a readme to the docker directory on how to maintain this. - dockers: - id: arm64 goarch: arm64 diff --git a/docker/setup.sh b/docker/setup.sh index 03fe2c680a..3f6c09dc72 100755 --- a/docker/setup.sh +++ b/docker/setup.sh @@ -15,18 +15,3 @@ mv zip/terraform/terraform /app/bin/terraform TF_PROVIDER_NAME=terraform-provider-databricks_${DATABRICKS_TF_PROVIDER_VERSION}_linux_${ARCH}.zip mkdir -p /app/providers/registry.terraform.io/databricks/databricks wget https://github.com/databricks/terraform-provider-databricks/releases/download/v${DATABRICKS_TF_PROVIDER_VERSION}/${TF_PROVIDER_NAME} -O /app/providers/registry.terraform.io/databricks/databricks/${TF_PROVIDER_NAME} - - -# TODO: document both the interactive and the non interactive workflows for -# working with DABs with the docker container. Execing into the container -# allows for a better iteration loop - -# For the interactive devloop: -# docker run -it --entrypoint /bin/sh cli ... - -# For the non-interactive devloop: -# docker run cli ... - -# TODO: End to end test for this image? - -# TODO: Final sanity check that the docker image is indeed airgapped. From 0cea0865a9f68ae34d370b0184c85ff4b6741279 Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Wed, 10 Apr 2024 18:47:38 +0200 Subject: [PATCH 11/15] add a latest image --- .goreleaser.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index b1f95f00a6..e440687473 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -53,6 +53,7 @@ dockers: image_templates: # Docker tags can't have "+" in them, so we replace it with "-" - 'ghcr.io/databricks/cli:{{replace .Version "+" "-"}}-arm64' + - 'ghcr.io/databricks/cli:latest-arm64' build_flag_templates: - "--build-arg=ARCH=arm64" - "--platform=linux/arm64" @@ -66,6 +67,7 @@ dockers: image_templates: # Docker tags can't have "+" in them, so we replace it with "-" - 'ghcr.io/databricks/cli:{{replace .Version "+" "-"}}-amd64' + - 'ghcr.io/databricks/cli:latest-amd64' build_flag_templates: - "--build-arg=ARCH=amd64" - "--platform=linux/amd64" From 4528767d9b54bcea5fbad94ffe426cdacf12e8e6 Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Thu, 11 Apr 2024 13:41:36 +0200 Subject: [PATCH 12/15] changes to test the final workflow --- .github/workflows/release.yml | 179 +++++++++++++++++----------------- 1 file changed, 90 insertions(+), 89 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b50bc7ef82..6486d28ec3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,6 +4,7 @@ on: push: tags: - "v*" + - "v0.0.0-testdocker" workflow_dispatch: @@ -46,99 +47,99 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - create-setup-cli-release-pr: - needs: goreleaser - runs-on: ubuntu-latest - steps: - - name: Set VERSION variable from tag - run: | - VERSION=${{ github.ref_name }} - echo "VERSION=${VERSION:1}" >> $GITHUB_ENV + # create-setup-cli-release-pr: + # needs: goreleaser + # runs-on: ubuntu-latest + # steps: + # - name: Set VERSION variable from tag + # run: | + # VERSION=${{ github.ref_name }} + # echo "VERSION=${VERSION:1}" >> $GITHUB_ENV - - name: Update setup-cli - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.DECO_GITHUB_TOKEN }} - script: | - await github.rest.actions.createWorkflowDispatch({ - owner: 'databricks', - repo: 'setup-cli', - workflow_id: 'release-pr.yml', - ref: 'main', - inputs: { - version: "${{ env.VERSION }}", - } - }); + # - name: Update setup-cli + # uses: actions/github-script@v6 + # with: + # github-token: ${{ secrets.DECO_GITHUB_TOKEN }} + # script: | + # await github.rest.actions.createWorkflowDispatch({ + # owner: 'databricks', + # repo: 'setup-cli', + # workflow_id: 'release-pr.yml', + # ref: 'main', + # inputs: { + # version: "${{ env.VERSION }}", + # } + # }); - create-homebrew-tap-release-pr: - needs: goreleaser - runs-on: ubuntu-latest - steps: - - name: Set VERSION variable from tag - run: | - VERSION=${{ github.ref_name }} - echo "VERSION=${VERSION:1}" >> $GITHUB_ENV + # create-homebrew-tap-release-pr: + # needs: goreleaser + # runs-on: ubuntu-latest + # steps: + # - name: Set VERSION variable from tag + # run: | + # VERSION=${{ github.ref_name }} + # echo "VERSION=${VERSION:1}" >> $GITHUB_ENV - - name: Update homebrew-tap - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.DECO_GITHUB_TOKEN }} - script: | - let artifacts = JSON.parse('${{ needs.goreleaser.outputs.artifacts }}') - artifacts = artifacts.filter(a => a.type == "Archive") - artifacts = new Map( - artifacts.map(a => [ - a.goos + "_" + a.goarch, - a.extra.Checksum.replace("sha256:", "") - ]) - ) + # - name: Update homebrew-tap + # uses: actions/github-script@v6 + # with: + # github-token: ${{ secrets.DECO_GITHUB_TOKEN }} + # script: | + # let artifacts = JSON.parse('${{ needs.goreleaser.outputs.artifacts }}') + # artifacts = artifacts.filter(a => a.type == "Archive") + # artifacts = new Map( + # artifacts.map(a => [ + # a.goos + "_" + a.goarch, + # a.extra.Checksum.replace("sha256:", "") + # ]) + # ) - await github.rest.actions.createWorkflowDispatch({ - owner: 'databricks', - repo: 'homebrew-tap', - workflow_id: 'release-pr.yml', - ref: 'main', - inputs: { - version: "${{ env.VERSION }}", - darwin_amd64_sha: artifacts.get('darwin_amd64'), - darwin_arm64_sha: artifacts.get('darwin_arm64'), - linux_amd64_sha: artifacts.get('linux_amd64'), - linux_arm64_sha: artifacts.get('linux_arm64') - } - }); + # await github.rest.actions.createWorkflowDispatch({ + # owner: 'databricks', + # repo: 'homebrew-tap', + # workflow_id: 'release-pr.yml', + # ref: 'main', + # inputs: { + # version: "${{ env.VERSION }}", + # darwin_amd64_sha: artifacts.get('darwin_amd64'), + # darwin_arm64_sha: artifacts.get('darwin_arm64'), + # linux_amd64_sha: artifacts.get('linux_amd64'), + # linux_arm64_sha: artifacts.get('linux_arm64') + # } + # }); - create-vscode-extension-update-pr: - needs: goreleaser - runs-on: ubuntu-latest - steps: - - name: Set VERSION variable from tag - run: | - VERSION=${{ github.ref_name }} - echo "VERSION=${VERSION:1}" >> $GITHUB_ENV + # create-vscode-extension-update-pr: + # needs: goreleaser + # runs-on: ubuntu-latest + # steps: + # - name: Set VERSION variable from tag + # run: | + # VERSION=${{ github.ref_name }} + # echo "VERSION=${VERSION:1}" >> $GITHUB_ENV - - name: Update CLI version in the VSCode extension - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.DECO_GITHUB_TOKEN }} - script: | - await github.rest.actions.createWorkflowDispatch({ - owner: 'databricks', - repo: 'databricks-vscode', - workflow_id: 'update-cli-version.yml', - ref: 'main', - inputs: { - version: "${{ env.VERSION }}", - } - }); + # - name: Update CLI version in the VSCode extension + # uses: actions/github-script@v6 + # with: + # github-token: ${{ secrets.DECO_GITHUB_TOKEN }} + # script: | + # await github.rest.actions.createWorkflowDispatch({ + # owner: 'databricks', + # repo: 'databricks-vscode', + # workflow_id: 'update-cli-version.yml', + # ref: 'main', + # inputs: { + # version: "${{ env.VERSION }}", + # } + # }); - publish-to-winget-pkgs: - needs: goreleaser - runs-on: windows-latest - environment: release - steps: - - uses: vedantmgoyal2009/winget-releaser@93fd8b606a1672ec3e5c6c3bb19426be68d1a8b0 # https://github.com/vedantmgoyal2009/winget-releaser/releases/tag/v2 - with: - identifier: Databricks.DatabricksCLI - installers-regex: 'windows_.*\.zip$' # Only windows releases - token: ${{ secrets.ENG_DEV_ECOSYSTEM_BOT_TOKEN }} - fork-user: eng-dev-ecosystem-bot + # publish-to-winget-pkgs: + # needs: goreleaser + # runs-on: windows-latest + # environment: release + # steps: + # - uses: vedantmgoyal2009/winget-releaser@93fd8b606a1672ec3e5c6c3bb19426be68d1a8b0 # https://github.com/vedantmgoyal2009/winget-releaser/releases/tag/v2 + # with: + # identifier: Databricks.DatabricksCLI + # installers-regex: 'windows_.*\.zip$' # Only windows releases + # token: ${{ secrets.ENG_DEV_ECOSYSTEM_BOT_TOKEN }} + # fork-user: eng-dev-ecosystem-bot From 98736f1db98b04b26eb1fe5cbd79a0f529e88d86 Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Thu, 11 Apr 2024 14:15:43 +0200 Subject: [PATCH 13/15] Revert "changes to test the final workflow" This reverts commit 4528767d9b54bcea5fbad94ffe426cdacf12e8e6. --- .github/workflows/release.yml | 179 +++++++++++++++++----------------- 1 file changed, 89 insertions(+), 90 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6486d28ec3..b50bc7ef82 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,7 +4,6 @@ on: push: tags: - "v*" - - "v0.0.0-testdocker" workflow_dispatch: @@ -47,99 +46,99 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # create-setup-cli-release-pr: - # needs: goreleaser - # runs-on: ubuntu-latest - # steps: - # - name: Set VERSION variable from tag - # run: | - # VERSION=${{ github.ref_name }} - # echo "VERSION=${VERSION:1}" >> $GITHUB_ENV + create-setup-cli-release-pr: + needs: goreleaser + runs-on: ubuntu-latest + steps: + - name: Set VERSION variable from tag + run: | + VERSION=${{ github.ref_name }} + echo "VERSION=${VERSION:1}" >> $GITHUB_ENV - # - name: Update setup-cli - # uses: actions/github-script@v6 - # with: - # github-token: ${{ secrets.DECO_GITHUB_TOKEN }} - # script: | - # await github.rest.actions.createWorkflowDispatch({ - # owner: 'databricks', - # repo: 'setup-cli', - # workflow_id: 'release-pr.yml', - # ref: 'main', - # inputs: { - # version: "${{ env.VERSION }}", - # } - # }); + - name: Update setup-cli + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.DECO_GITHUB_TOKEN }} + script: | + await github.rest.actions.createWorkflowDispatch({ + owner: 'databricks', + repo: 'setup-cli', + workflow_id: 'release-pr.yml', + ref: 'main', + inputs: { + version: "${{ env.VERSION }}", + } + }); - # create-homebrew-tap-release-pr: - # needs: goreleaser - # runs-on: ubuntu-latest - # steps: - # - name: Set VERSION variable from tag - # run: | - # VERSION=${{ github.ref_name }} - # echo "VERSION=${VERSION:1}" >> $GITHUB_ENV + create-homebrew-tap-release-pr: + needs: goreleaser + runs-on: ubuntu-latest + steps: + - name: Set VERSION variable from tag + run: | + VERSION=${{ github.ref_name }} + echo "VERSION=${VERSION:1}" >> $GITHUB_ENV - # - name: Update homebrew-tap - # uses: actions/github-script@v6 - # with: - # github-token: ${{ secrets.DECO_GITHUB_TOKEN }} - # script: | - # let artifacts = JSON.parse('${{ needs.goreleaser.outputs.artifacts }}') - # artifacts = artifacts.filter(a => a.type == "Archive") - # artifacts = new Map( - # artifacts.map(a => [ - # a.goos + "_" + a.goarch, - # a.extra.Checksum.replace("sha256:", "") - # ]) - # ) + - name: Update homebrew-tap + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.DECO_GITHUB_TOKEN }} + script: | + let artifacts = JSON.parse('${{ needs.goreleaser.outputs.artifacts }}') + artifacts = artifacts.filter(a => a.type == "Archive") + artifacts = new Map( + artifacts.map(a => [ + a.goos + "_" + a.goarch, + a.extra.Checksum.replace("sha256:", "") + ]) + ) - # await github.rest.actions.createWorkflowDispatch({ - # owner: 'databricks', - # repo: 'homebrew-tap', - # workflow_id: 'release-pr.yml', - # ref: 'main', - # inputs: { - # version: "${{ env.VERSION }}", - # darwin_amd64_sha: artifacts.get('darwin_amd64'), - # darwin_arm64_sha: artifacts.get('darwin_arm64'), - # linux_amd64_sha: artifacts.get('linux_amd64'), - # linux_arm64_sha: artifacts.get('linux_arm64') - # } - # }); + await github.rest.actions.createWorkflowDispatch({ + owner: 'databricks', + repo: 'homebrew-tap', + workflow_id: 'release-pr.yml', + ref: 'main', + inputs: { + version: "${{ env.VERSION }}", + darwin_amd64_sha: artifacts.get('darwin_amd64'), + darwin_arm64_sha: artifacts.get('darwin_arm64'), + linux_amd64_sha: artifacts.get('linux_amd64'), + linux_arm64_sha: artifacts.get('linux_arm64') + } + }); - # create-vscode-extension-update-pr: - # needs: goreleaser - # runs-on: ubuntu-latest - # steps: - # - name: Set VERSION variable from tag - # run: | - # VERSION=${{ github.ref_name }} - # echo "VERSION=${VERSION:1}" >> $GITHUB_ENV + create-vscode-extension-update-pr: + needs: goreleaser + runs-on: ubuntu-latest + steps: + - name: Set VERSION variable from tag + run: | + VERSION=${{ github.ref_name }} + echo "VERSION=${VERSION:1}" >> $GITHUB_ENV - # - name: Update CLI version in the VSCode extension - # uses: actions/github-script@v6 - # with: - # github-token: ${{ secrets.DECO_GITHUB_TOKEN }} - # script: | - # await github.rest.actions.createWorkflowDispatch({ - # owner: 'databricks', - # repo: 'databricks-vscode', - # workflow_id: 'update-cli-version.yml', - # ref: 'main', - # inputs: { - # version: "${{ env.VERSION }}", - # } - # }); + - name: Update CLI version in the VSCode extension + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.DECO_GITHUB_TOKEN }} + script: | + await github.rest.actions.createWorkflowDispatch({ + owner: 'databricks', + repo: 'databricks-vscode', + workflow_id: 'update-cli-version.yml', + ref: 'main', + inputs: { + version: "${{ env.VERSION }}", + } + }); - # publish-to-winget-pkgs: - # needs: goreleaser - # runs-on: windows-latest - # environment: release - # steps: - # - uses: vedantmgoyal2009/winget-releaser@93fd8b606a1672ec3e5c6c3bb19426be68d1a8b0 # https://github.com/vedantmgoyal2009/winget-releaser/releases/tag/v2 - # with: - # identifier: Databricks.DatabricksCLI - # installers-regex: 'windows_.*\.zip$' # Only windows releases - # token: ${{ secrets.ENG_DEV_ECOSYSTEM_BOT_TOKEN }} - # fork-user: eng-dev-ecosystem-bot + publish-to-winget-pkgs: + needs: goreleaser + runs-on: windows-latest + environment: release + steps: + - uses: vedantmgoyal2009/winget-releaser@93fd8b606a1672ec3e5c6c3bb19426be68d1a8b0 # https://github.com/vedantmgoyal2009/winget-releaser/releases/tag/v2 + with: + identifier: Databricks.DatabricksCLI + installers-regex: 'windows_.*\.zip$' # Only windows releases + token: ${{ secrets.ENG_DEV_ECOSYSTEM_BOT_TOKEN }} + fork-user: eng-dev-ecosystem-bot From 0fd7ba9f664e4799a1d211a4882a45ab6200f065 Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Thu, 11 Apr 2024 15:54:22 +0200 Subject: [PATCH 14/15] typo --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b50bc7ef82..e2ecbfce38 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,7 +33,7 @@ jobs: password: "${{ secrets.GITHUB_TOKEN }}" # QEMU is required to build cross platform docker images using buildx. - # It's allows virtualization of the CPU architecture in software. + # It allows virtualization of the CPU architecture in software. - name: Set up QEMU dependency uses: docker/setup-qemu-action@v3 From b7dbb585577a283d04a092631368266d28d8fbd0 Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Thu, 11 Apr 2024 15:58:29 +0200 Subject: [PATCH 15/15] more comment cleanup --- .github/workflows/release.yml | 2 +- bundle/deploy/terraform/init.go | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e2ecbfce38..f9b4ec15f0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,7 +33,7 @@ jobs: password: "${{ secrets.GITHUB_TOKEN }}" # QEMU is required to build cross platform docker images using buildx. - # It allows virtualization of the CPU architecture in software. + # It allows virtualization of the CPU architecture at the application level. - name: Set up QEMU dependency uses: docker/setup-qemu-action@v3 diff --git a/bundle/deploy/terraform/init.go b/bundle/deploy/terraform/init.go index bb02431450..69ae70ba63 100644 --- a/bundle/deploy/terraform/init.go +++ b/bundle/deploy/terraform/init.go @@ -161,9 +161,8 @@ func getEnvVarWithMatchingVersion(ctx context.Context, envVarName string, versio return envValue, nil } - // If the version environment variable is set, we check if it matches the current version. - // If it does not match, we ignore the environment variable. - // if it matches, we check if the path exists. + // When the version environment variable is set, we check if it matches the current version. + // If it does not match, we return an empty string. if versionValue != currentVersion { log.Debugf(ctx, "%s as %s does not match the current version %s, ignoring %s", versionVarName, versionValue, currentVersion, envVarName) return "", nil