diff --git a/.envrc b/.envrc index 60b08db..84fc8e5 100644 --- a/.envrc +++ b/.envrc @@ -1,5 +1,7 @@ -strict_env -source_env_if_exists .envrc.local-asdf -use_asdf -PATH_add .local/bin -source_env_if_exists .envrc.local +# Automatically sets up your devbox environment whenever you cd into this +# directory via our direnv integration: + +eval "$(devbox generate direnv --print-envrc)" + +# check out https://www.jetpack.io/devbox/docs/ide_configuration/direnv/ +# for more details diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 3c3e21a..c4fc32d 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -24,11 +24,17 @@ jobs: - name: Check out code uses: actions/checkout@v3 - - name: Install asdf - uses: asdf-vm/actions/setup@v2 + # Setup github authentication to ensure Github's rate limits are not hit. + - name: Configure nix GitHub access-tokens + run: | + mkdir -p ~/.config/nix + echo "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" >>~/.config/nix/nix.conf + + - name: Install devbox + uses: jetpack-io/devbox-install-action@v0.4.0 - name: Run unit tests - run: make test + run: devbox run -- make test - name: Annotate tests if: always() @@ -49,13 +55,20 @@ jobs: with: files: "test/e2e/**/*.go" - - name: Install asdf - if: steps.check_e2e_files.outputs.files_exists == 'true' - uses: asdf-vm/actions/setup@v2 + # Setup github authentication to ensure Github's rate limits are not hit. + - if: steps.check_e2e_files.outputs.files_exists == 'true' + name: Configure nix GitHub access-tokens + run: | + mkdir -p ~/.config/nix + echo "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" >>~/.config/nix/nix.conf - - name: Run e2e tests - if: steps.check_e2e_files.outputs.files_exists == 'true' - run: make e2e-test + - if: steps.check_e2e_files.outputs.files_exists == 'true' + name: Install devbox + uses: jetpack-io/devbox-install-action@v0.4.0 + + - if: steps.check_e2e_files.outputs.files_exists == 'true' + name: Run e2e tests + run: devbox run -- make e2e-test lint: runs-on: ubuntu-22.04 @@ -63,17 +76,27 @@ jobs: - name: Check out code uses: actions/checkout@v3 - - name: Gather tool versions - uses: jimmidyson/asdf-parse-tool-versions@v2 - id: versions + # Setup github authentication to ensure Github's rate limits are not hit. + - name: Configure nix GitHub access-tokens + run: | + mkdir -p ~/.config/nix + echo "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" >>~/.config/nix/nix.conf + + - name: Install devbox + uses: jetpack-io/devbox-install-action@v0.4.0 + + - name: Collect tool versions + run: | + echo GO_VERSION="$(devbox run -- go version | cut -d' ' -f 3 | grep -o '[0-9.]\+')" >>"${GITHUB_ENV}" + echo GOLANGCI_LINT_VERSION="$(devbox run -- golangci-lint version --format short)" >>"${GITHUB_ENV}" - name: golangci-lint uses: reviewdog/action-golangci-lint@v2 with: fail_on_error: true reporter: github-pr-review - go_version: ${{ fromJson(steps.versions.outputs.tools).golang }} - golangci_lint_version: v${{ fromJson(steps.versions.outputs.tools).golangci-lint }} + go_version: ${{ env.GO_VERSION }} + golangci_lint_version: v${{ env.GOLANGCI_LINT_VERSION }} generated: runs-on: ubuntu-22.04 @@ -81,21 +104,20 @@ jobs: - name: Check out code uses: actions/checkout@v3 - - name: Install asdf - uses: asdf-vm/actions/setup@v2 + # Setup github authentication to ensure Github's rate limits are not hit. + - name: Configure nix GitHub access-tokens + run: | + mkdir -p ~/.config/nix + echo "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" >>~/.config/nix/nix.conf + + - name: Install devbox + uses: jetpack-io/devbox-install-action@v0.4.0 - name: Check generated files - run: make go-generate + run: devbox run -- make go-generate - name: Verify no changed files - uses: tj-actions/verify-changed-files@v16 - id: verify-changed-files - - - name: Fail if files have changed - if: steps.verify-changed-files.outputs.files_changed == 'true' - run: | - echo "Changed files: ${{ steps.verify-changed-files.outputs.changed_files }}" - exit 1 + run: git diff --exit-code pre-commit: runs-on: ubuntu-22.04 @@ -103,28 +125,22 @@ jobs: - name: Check out code uses: actions/checkout@v3 - - name: Gather tool versions - uses: jimmidyson/asdf-parse-tool-versions@v2 - id: versions + # Setup github authentication to ensure Github's rate limits are not hit. + - name: Configure nix GitHub access-tokens + run: | + mkdir -p ~/.config/nix + echo "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" >>~/.config/nix/nix.conf - - uses: actions/setup-go@v4 - with: - go-version: ${{ fromJson(steps.versions.outputs.tools).golang }} - check-latest: false - cache: true + - name: Install devbox + uses: jetpack-io/devbox-install-action@v0.4.0 - - uses: mfinelli/setup-shfmt@v2 + - name: Set up pre-commit cache + uses: actions/cache@v3 with: - shfmt-version: ${{ fromJson(steps.versions.outputs.tools).shfmt }} - - - name: Install asdf - uses: asdf-vm/actions/setup@v2 + path: ~/.cache/pre-commit + key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }} - - name: Install helm-docs - run: make install-tool.helm-docs - - - uses: pre-commit/action@v3.0.0 - with: - extra_args: --all-files --show-diff-on-failure + - name: Run pre-commit + run: devbox run -- make pre-commit env: - SKIP: no-commit-to-branch,golangci-lint,go-generate + SKIP: no-commit-to-branch,golangci-lint diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index f0eb9a6..d85ccae 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -25,16 +25,22 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 + # Setup github authentication to ensure Github's rate limits are not hit. + - name: Configure nix GitHub access-tokens + run: | + mkdir -p ~/.config/nix + echo "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" >>~/.config/nix/nix.conf + + - name: Install devbox + uses: jetpack-io/devbox-install-action@v0.4.0 + - name: Initialize CodeQL uses: github/codeql-action/init@v2 with: languages: ${{ matrix.language }} - - name: Install tools via asdf - uses: asdf-vm/actions/install@v2 - - name: Build - run: make build-snapshot + run: devbox run -- make build-snapshot - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/recover-secret.yaml b/.github/workflows/recover-secret.yaml deleted file mode 100644 index 53a19b8..0000000 --- a/.github/workflows/recover-secret.yaml +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright 2022 D2iQ, Inc. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -on: workflow_dispatch -jobs: - openssl: - name: Recover Secret With OpenSSL - runs-on: ubuntu-22.04 - steps: - - env: - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - OPENSSL_PASSWORD: ${{ secrets.OPENSSL_PASSWORD }} - OPENSSL_ITER: ${{ secrets.OPENSSL_ITER }} - run: | - echo "$(echo "${DOCKER_PASSWORD}" | openssl enc -e -aes-256-cbc -a -pbkdf2 -iter ${OPENSSL_ITER} -k "${OPENSSL_PASSWORD}")" - echo "Copy the above value, and then execute locally:" - echo "echo PASTE_HERE | openssl base64 -d | openssl enc -d -pbkdf2 -iter \$OPENSSL_ITER -aes-256-cbc -k \$OPENSSL_PASSWORD" diff --git a/.github/workflows/release-main.yaml b/.github/workflows/release-main.yaml index 2043176..98cdae8 100644 --- a/.github/workflows/release-main.yaml +++ b/.github/workflows/release-main.yaml @@ -30,29 +30,36 @@ jobs: with: fetch-depth: 0 + # Setup github authentication to ensure Github's rate limits are not hit. - if: ${{ steps.release-please.outputs.release_created }} - name: Install tools via asdf - uses: asdf-vm/actions/install@v2 + name: Configure nix GitHub access-tokens + run: | + mkdir -p ~/.config/nix + echo "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" >>~/.config/nix/nix.conf + + - if: ${{ steps.release-please.outputs.release_created }} + name: Install devbox + uses: jetpack-io/devbox-install-action@v0.4.0 - if: ${{ steps.release-please.outputs.release_created }} name: Login to GitHub Container Registry uses: docker/login-action@v2 with: registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - if: ${{ steps.release-please.outputs.release_created }} name: Release - run: make release + run: devbox run -- make release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - if: ${{ steps.release-please.outputs.release_created }} + - if: ${{ steps.release-please.outputs.release_created }} name: Publish Helm chart uses: stefanprodan/helm-gh-pages@v1.7.0 with: - token: ${{ secrets.GITHUB_TOKEN }} - app_version: ${{ steps.release-please.outputs.tag_name }} - chart_version: ${{ steps.release-please.outputs.tag_name }} + token: ${{ secrets.GITHUB_TOKEN }} + app_version: ${{ steps.release-please.outputs.tag_name }} + chart_version: ${{ steps.release-please.outputs.tag_name }} target_dir: repo diff --git a/.go-tools b/.go-tools index 283b4ad..e9360f0 100644 --- a/.go-tools +++ b/.go-tools @@ -1,4 +1 @@ github.com/oligot/go-mod-upgrade@v0.9.1 -gotest.tools/gotestsum@v1.10.0 -github.com/segmentio/golines@v0.11.0 -github.com/google/go-containerregistry/cmd/crane@v0.15.2 diff --git a/.tool-versions b/.tool-versions deleted file mode 100644 index 5c41a86..0000000 --- a/.tool-versions +++ /dev/null @@ -1,16 +0,0 @@ -clusterctl 1.4.3 -gcloud 434.0.0 -ginkgo 2.10.0 -github-cli 2.30.0 -gojq 0.12.13 -golang 1.20.5 -golangci-lint 1.53.2 -goreleaser 1.18.2 -helm 3.12.0 -helm-docs 1.11.0 -kubebuilder 3.10.0 -kube-code-generator 0.27.2 -kube-controller-tools 0.12.0 -pre-commit 3.3.2 -shfmt 3.6.0 -upx 4.0.2 diff --git a/Makefile b/Makefile index 31b854e..337c463 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,3 @@ REPO_ROOT := $(CURDIR) include make/all.mk - -ASDF_VERSION=v0.10.2 - -CI_DOCKER_BUILD_ARGS=ASDF_VERSION=$(ASDF_VERSION) diff --git a/apis/config/v1alpha1/dynamiccredentialprovideconfig_types.go b/apis/config/v1alpha1/dynamiccredentialprovideconfig_types.go index 330ef45..8fcbba1 100644 --- a/apis/config/v1alpha1/dynamiccredentialprovideconfig_types.go +++ b/apis/config/v1alpha1/dynamiccredentialprovideconfig_types.go @@ -4,7 +4,7 @@ package v1alpha1 //go:generate controller-gen object paths=. -//go:generate bash -ec "cd ../../.. && defaulter-gen -h hack/boilerplate.go.txt -i ./apis/config/v1alpha1 -o ." +//go:generate bash -ec "cd ../../.. && defaulter-gen -h hack/boilerplate.go.txt -i ./apis/config/v1alpha1 -o ../../../" import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/devbox.json b/devbox.json new file mode 100644 index 0000000..76e3631 --- /dev/null +++ b/devbox.json @@ -0,0 +1,32 @@ +{ + "packages": [ + "clusterctl@latest", + "crane@latest", + "ginkgo@latest", + "go@latest", + "gojq@latest", + "golangci-lint@latest", + "golines@latest", + "google-cloud-sdk@latest", + "goreleaser@latest", + "gotestsum@latest", + "helm-docs@latest", + "kubebuilder@latest", + "kubernetes-code-generator@latest", + "kubernetes-controller-tools@latest", + "kubernetes-helm@latest", + "pre-commit@latest", + "shfmt@latest", + "upx@latest" + ], + "shell": { + "init_hook": [ + "echo 'Welcome to devbox!' > /dev/null" + ], + "scripts": { + "test": [ + "echo \"Error: no test specified\" && exit 1" + ] + } + } +} diff --git a/devbox.lock b/devbox.lock new file mode 100644 index 0000000..3d1df13 --- /dev/null +++ b/devbox.lock @@ -0,0 +1,113 @@ +{ + "lockfile_version": "1", + "packages": { + "clusterctl@latest": { + "last_modified": "2023-06-29T16:20:38Z", + "resolved": "github:NixOS/nixpkgs/3c614fbc76fc152f3e1bc4b2263da6d90adf80fb#clusterctl", + "source": "devbox-search", + "version": "1.4.3" + }, + "crane@latest": { + "last_modified": "2023-06-29T16:20:38Z", + "resolved": "github:NixOS/nixpkgs/3c614fbc76fc152f3e1bc4b2263da6d90adf80fb#crane", + "source": "devbox-search", + "version": "0.15.2" + }, + "ginkgo@latest": { + "last_modified": "2023-06-29T16:20:38Z", + "resolved": "github:NixOS/nixpkgs/3c614fbc76fc152f3e1bc4b2263da6d90adf80fb#ginkgo", + "source": "devbox-search", + "version": "2.11.0" + }, + "go@latest": { + "last_modified": "2023-06-29T16:20:38Z", + "resolved": "github:NixOS/nixpkgs/3c614fbc76fc152f3e1bc4b2263da6d90adf80fb#go", + "source": "devbox-search", + "version": "1.20.5" + }, + "gojq@latest": { + "last_modified": "2023-06-29T16:20:38Z", + "resolved": "github:NixOS/nixpkgs/3c614fbc76fc152f3e1bc4b2263da6d90adf80fb#gojq", + "source": "devbox-search", + "version": "0.12.13" + }, + "golangci-lint@latest": { + "last_modified": "2023-06-29T16:20:38Z", + "resolved": "github:NixOS/nixpkgs/3c614fbc76fc152f3e1bc4b2263da6d90adf80fb#golangci-lint", + "source": "devbox-search", + "version": "1.53.3" + }, + "golines@latest": { + "last_modified": "2023-05-07T06:59:10Z", + "resolved": "github:NixOS/nixpkgs/eb751d65225ec53de9cf3d88acbf08d275882389#golines", + "source": "devbox-search", + "version": "0.11.0" + }, + "google-cloud-sdk@latest": { + "last_modified": "2023-06-29T16:20:38Z", + "resolved": "github:NixOS/nixpkgs/3c614fbc76fc152f3e1bc4b2263da6d90adf80fb#google-cloud-sdk", + "source": "devbox-search", + "version": "433.0.1" + }, + "goreleaser@latest": { + "last_modified": "2023-06-29T16:20:38Z", + "resolved": "github:NixOS/nixpkgs/3c614fbc76fc152f3e1bc4b2263da6d90adf80fb#goreleaser", + "source": "devbox-search", + "version": "1.18.2" + }, + "gotestsum@latest": { + "last_modified": "2023-05-07T06:59:10Z", + "resolved": "github:NixOS/nixpkgs/eb751d65225ec53de9cf3d88acbf08d275882389#gotestsum", + "source": "devbox-search", + "version": "1.10.0" + }, + "helm-docs@latest": { + "last_modified": "2023-05-07T06:59:10Z", + "resolved": "github:NixOS/nixpkgs/eb751d65225ec53de9cf3d88acbf08d275882389#helm-docs", + "source": "devbox-search", + "version": "1.11.0" + }, + "kubebuilder@latest": { + "last_modified": "2023-06-29T16:20:38Z", + "resolved": "github:NixOS/nixpkgs/3c614fbc76fc152f3e1bc4b2263da6d90adf80fb#kubebuilder", + "source": "devbox-search", + "version": "3.11.0" + }, + "kubernetes-code-generator@latest": { + "last_modified": "2023-05-07T06:59:10Z", + "resolved": "github:NixOS/nixpkgs/eb751d65225ec53de9cf3d88acbf08d275882389#kubernetes-code-generator", + "source": "devbox-search", + "version": "0.25.4" + }, + "kubernetes-controller-tools@latest": { + "last_modified": "2023-05-07T06:59:10Z", + "resolved": "github:NixOS/nixpkgs/eb751d65225ec53de9cf3d88acbf08d275882389#kubernetes-controller-tools", + "source": "devbox-search", + "version": "0.12.0" + }, + "kubernetes-helm@latest": { + "last_modified": "2023-06-29T16:20:38Z", + "resolved": "github:NixOS/nixpkgs/3c614fbc76fc152f3e1bc4b2263da6d90adf80fb#kubernetes-helm", + "source": "devbox-search", + "version": "3.12.1" + }, + "pre-commit@latest": { + "last_modified": "2023-06-29T16:20:38Z", + "resolved": "github:NixOS/nixpkgs/3c614fbc76fc152f3e1bc4b2263da6d90adf80fb#pre-commit", + "source": "devbox-search", + "version": "3.3.3" + }, + "shfmt@latest": { + "last_modified": "2023-06-29T16:20:38Z", + "resolved": "github:NixOS/nixpkgs/3c614fbc76fc152f3e1bc4b2263da6d90adf80fb#shfmt", + "source": "devbox-search", + "version": "3.7.0" + }, + "upx@latest": { + "last_modified": "2023-05-07T06:59:10Z", + "resolved": "github:NixOS/nixpkgs/eb751d65225ec53de9cf3d88acbf08d275882389#upx", + "source": "devbox-search", + "version": "4.0.2" + } + } +} diff --git a/hack/demo/Dockerfile.demo-node b/hack/demo/Dockerfile.demo-node index 0e88f4b..bc05abf 100644 --- a/hack/demo/Dockerfile.demo-node +++ b/hack/demo/Dockerfile.demo-node @@ -3,7 +3,7 @@ # syntax=docker/dockerfile:1 -FROM --platform=linux/${TARGETARCH} mesosphere/kind-node:v1.26.4 +FROM --platform=linux/${TARGETARCH} ghcr.io/mesosphere/kind-node:v1.26.6 ARG TARGETARCH COPY dist/dynamic-credential-provider_linux_${TARGETARCH}_v1/dynamic-credential-provider /etc/kubernetes/image-credential-provider/ diff --git a/make/docker.mk b/make/docker.mk index 2b2e65f..179a475 100644 --- a/make/docker.mk +++ b/make/docker.mk @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 .PHONY: update-distroless-base-image -update-distroless-base-image: install-tool.gcloud install-tool.gojq install-tool.go.crane; $(info $(M) updating distroless base image) +update-distroless-base-image: ; $(info $(M) updating distroless base image) LATEST_DISTROLESS_NONROOT_DIGEST="$$(gcloud container images list-tags gcr.io/distroless/static --format=json | gojq -r '.[] | select(.tags | index("nonroot")) | .digest')"; \ DISTROLESS_AMD64_DIGEST="$$(crane manifest gcr.io/distroless/static@$${LATEST_DISTROLESS_NONROOT_DIGEST} | gojq -r '.manifests[] | select(.platform.os == "linux" and .platform.architecture == "amd64").digest')"; \ DISTROLESS_ARM64_DIGEST="$$(crane manifest gcr.io/distroless/static@$${LATEST_DISTROLESS_NONROOT_DIGEST} | gojq -r '.manifests[] | select(.platform.os == "linux" and .platform.architecture == "arm64").digest')"; \ diff --git a/make/go.mk b/make/go.mk index ae57978..7609245 100644 --- a/make/go.mk +++ b/make/go.mk @@ -47,7 +47,7 @@ endif .PHONY: test.% test.%: ## Runs go tests for a specific module -test.%: install-tool.go.gotestsum; $(info $(M) running tests$(if $(GOTEST_RUN), matching "$(GOTEST_RUN)") for $* module) +test.%: ; $(info $(M) running tests$(if $(GOTEST_RUN), matching "$(GOTEST_RUN)") for $* module) $(if $(filter-out root,$*),cd $* && )$(call go_test) .PHONY: integration-test @@ -79,7 +79,6 @@ E2E_FLAKE_ATTEMPTS ?= 1 .PHONY: e2e-test e2e-test: ## Runs e2e tests -e2e-test: install-tool.golang install-tool.ginkgo ifneq ($(SKIP_BUILD),true) $(MAKE) GOOS=linux release-snapshot endif @@ -124,7 +123,7 @@ endif .PHONY: lint.% lint.%: ## Runs golangci-lint for a specific module -lint.%: install-tool.golangci-lint install-tool.go.golines; $(info $(M) linting $* module) +lint.%: ; $(info $(M) linting $* module) $(if $(filter-out root,$*),cd $* && )find -name '*.go' ! -name 'zz_generated*.go' -exec golines -w {} \; $(if $(filter-out root,$*),cd $* && )golangci-lint run --fix --config=$(GOLANGCI_CONFIG_FILE) $(if $(filter-out root,$*),cd $* && )go fix ./... @@ -140,7 +139,7 @@ endif .PHONY: mod-tidy.% mod-tidy.%: ## Runs go mod tidy for a specific module -mod-tidy.%: install-tool.golang; $(info $(M) running go mod tidy for $* module) +mod-tidy.%: ; $(info $(M) running go mod tidy for $* module) $(if $(filter-out root,$*),cd $* && )go mod tidy -v -compat=1.17 $(if $(filter-out root,$*),cd $* && )go mod verify @@ -155,16 +154,16 @@ endif .PHONY: go-clean.% go-clean.%: ## Cleans go build, test and modules caches for a specific module -go-clean.%: install-tool.golang; $(info $(M) running go clean for $* module) +go-clean.%: ; $(info $(M) running go clean for $* module) $(if $(filter-out root,$*),cd $* && )go clean -r -i -cache -testcache -modcache .PHONY: go-generate go-generate: ## Runs go generate -go-generate: install-tool.golang install-tool.kube-controller-tools install-tool.kube-code-generator; $(info $(M) running go generate) +go-generate: ; $(info $(M) running go generate) go generate -x ./... go fix ./... .PHONY: go-mod-upgrade go-mod-upgrade: ## Interactive check for direct module dependency upgrades -go-mod-upgrade: install-tool.golang install-tool.go.go-mod-upgrade ; $(info $(M) checking for direct module dependency upgrades) +go-mod-upgrade: install-tool.go.go-mod-upgrade ; $(info $(M) checking for direct module dependency upgrades) go-mod-upgrade diff --git a/make/goreleaser.mk b/make/goreleaser.mk index 1e2c0c2..6d08c9a 100644 --- a/make/goreleaser.mk +++ b/make/goreleaser.mk @@ -12,7 +12,7 @@ export CLOUD_PROVIDER_GCP_VERSION := master .PHONY: build-snapshot build-snapshot: ## Builds a snapshot with goreleaser -build-snapshot: install-tool.goreleaser ; $(info $(M) building snapshot $*) +build-snapshot: ; $(info $(M) building snapshot $*) goreleaser --debug=$(GORELEASER_DEBUG) \ build \ --snapshot \ @@ -23,7 +23,7 @@ build-snapshot: install-tool.goreleaser ; $(info $(M) building snapshot $*) .PHONY: release release: ## Builds a release with goreleaser -release: install-tool.goreleaser ; $(info $(M) building release $*) +release: ; $(info $(M) building release $*) goreleaser --debug=$(GORELEASER_DEBUG) \ release \ --clean \ @@ -32,7 +32,7 @@ release: install-tool.goreleaser ; $(info $(M) building release $*) .PHONY: release-snapshot release-snapshot: ## Builds a snapshot release with goreleaser -release-snapshot: install-tool.goreleaser ; $(info $(M) building snapshot release $*) +release-snapshot: ; $(info $(M) building snapshot release $*) goreleaser --debug=$(GORELEASER_DEBUG) \ release \ --snapshot \ diff --git a/make/pre-commit.mk b/make/pre-commit.mk index 969e9b2..d968b37 100644 --- a/make/pre-commit.mk +++ b/make/pre-commit.mk @@ -9,7 +9,7 @@ endif .PHONY: pre-commit pre-commit: ## Runs pre-commit on all files -pre-commit: install-tool.pre-commit install-tool.helm-docs ; $(info $(M) running pre-commit) +pre-commit: ; $(info $(M) running pre-commit) ifeq ($(wildcard $(PRE_COMMIT_CONFIG_FILE)),) $(error Cannot find pre-commit config file $(PRE_COMMIT_CONFIG_FILE). Specify the config file via PRE_COMMIT_CONFIG_FILE variable) endif diff --git a/make/tools.mk b/make/tools.mk index 6a9adc8..a65061c 100644 --- a/make/tools.mk +++ b/make/tools.mk @@ -18,67 +18,13 @@ endef .PHONY: install-tool.go.%: ## Installs go tools -install-tool.go.%: install-tool.golang; $(info $(M) installing go tool $*) +install-tool.go.%: ; $(info $(M) installing go tool $*) $(call install_go_tool,$*) endif -ifndef SKIP_ASDF_CHECK -ifeq ($(shell command -v asdf),) - $(error "This repo requires asdf - see https://asdf-vm.com/guide/getting-started.html for instructions to install") -endif -endif - -define install_tool - $(if $(1), \ - (asdf plugin list 2>/dev/null | grep -E '^$(1)$$' &>/dev/null) || asdf plugin add $(1), \ - grep -Eo '^[^#]\S+' $(REPO_ROOT)/.tool-versions | \ - xargs -I{} bash -ec '(asdf plugin list 2>/dev/null | grep -E "^{}$$" &>/dev/null) || \ - asdf plugin add {}' \ - ) - asdf install $1 -endef - -.PHONY: install-tools -install-tools: ## Install all tools -install-tools: ; $(info $(M) installing all tools) - $(call install_tool,) -ifneq ($(wildcard $(GO_TOOLS_FILE)),) - cat $(GO_TOOLS_FILE) | xargs -L1 go install -v -endif - -.PHONY: install-tool.% -install-tool.%: ## Install specific tool -install-tool.%: ; $(info $(M) installing $*) - $(call install_tool,$*) - -.PHONY: upgrade-tools -# ASDF plugins use different env vars for GitHub authentication when querying releases. Try to -# handle this nicely by specifying some of the known env vars to prevent rate limiting. -ifdef GITHUB_USER_TOKEN -upgrade-tools: export GITHUB_API_TOKEN=$(GITHUB_USER_TOKEN) -else -ifdef GITHUB_TOKEN -upgrade-tools: export GITHUB_API_TOKEN=$(GITHUB_TOKEN) -endif -endif -upgrade-tools: export OAUTH_TOKEN=$(GITHUB_API_TOKEN) -upgrade-tools: ## Upgrades all tools to latest available versions -upgrade-tools: upgrade-go-tools; $(info $(M) upgrading all tools to latest available versions) - grep -Eo '^[^#]\S+' $(REPO_ROOT)/.tool-versions | \ - xargs -I{} bash -ec '(asdf plugin list 2>/dev/null | grep -E "^{}$$" &>/dev/null) || \ - asdf plugin add {}' - grep -v '# FREEZE' $(REPO_ROOT)/.tool-versions | \ - grep -Eo '^[^#]\S+' | \ - xargs -I{} bash -ec '\ - export VERSION="$$( \ - asdf list all {} | \ - grep -vE "(^Available versions:|-src|-dev|-latest|-stm|[-\\.]rc|-alpha|-beta|[-\\.]pre|-next|(a|b|c)[0-9]+|snapshot|master)" | \ - tail -1 \ - )" && asdf install {} $${VERSION} && asdf local {} $${VERSION}' - .PHONY: upgrade-go-tools upgrade-go-tools: ## Upgrades all go tools to latest available versions -upgrade-go-tools: install-tool.golang; $(info $(M) upgrading all go tools to latest available versions) +upgrade-go-tools: ; $(info $(M) upgrading all go tools to latest available versions) grep -v '# FREEZE' .go-tools | \ grep -Eo '^[^#][^@]+' | \ xargs -I {} bash -ec ' \ diff --git a/make/upx.mk b/make/upx.mk index 4467086..741496c 100644 --- a/make/upx.mk +++ b/make/upx.mk @@ -9,7 +9,6 @@ ifneq ($(SKIP_UPX),true) ifeq ($(GOOS)/$(GOARCH),windows/arm64) upx: ; $(info $(M) skipping packing $(UPX_REAL_TARGET) - $(GOOS)/$(GOARCH) is not yet supported by upx) else -upx: install-tool.upx upx: ## Pack executable using upx upx: ; $(info $(M) packing $(UPX_REAL_TARGET)) (upx -l $(UPX_REAL_TARGET) &>/dev/null && echo $(UPX_REAL_TARGET) is already packed) || upx --best $(UPX_REAL_TARGET)