From 0a867195f412ed078a04aca092f6aafa5ba78d17 Mon Sep 17 00:00:00 2001 From: Sheldon Hull Date: Tue, 3 Jan 2023 17:58:33 -0600 Subject: [PATCH 1/6] docs: add aqua installation method --- site/content/index.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/site/content/index.md b/site/content/index.md index 6f3f7a61..83ad78cd 100644 --- a/site/content/index.md +++ b/site/content/index.md @@ -73,6 +73,21 @@ asdf install mage latest asdf global mage latest ``` +### Using Aqua + +aqua is a declarative CLI Version Manager written in Go. +You can install CLI tools and manage their versions with YAML declaratively. + +To add to a project tool config: + +```shell +aqua init +aqua generate -i mage +aqua install +``` + +To add to a global `aqua.yaml`, add to the [global configuration](https://aquaproj.github.io/docs/tutorial-basics/global-config) and finally run `aqua install --all` for Mage to be installed. + ## Example Magefile ```go @@ -97,7 +112,7 @@ Run the above `Build` target by simply running `mage build` in the same director ## Magefiles directory -If you create your Magefile or files within a directory named `magefiles` And there is no Magefile in your current directory, +If you create your Magefile or files within a directory named `magefiles` And there is no Magefile in your current directory, `mage` will default to the directory as the source for your targets while keeping the current directory as working one. The result is the equivalent of running `mage -d magefiles -w .` @@ -133,7 +148,7 @@ Commands: -version show version info for the mage binary Options: - -d + -d directory to read magefiles from (default ".") -debug turn on debug messages -f force recreation of compiled magefile From 488bd7234e89b879219cbf3d1ab3863c471aefde Mon Sep 17 00:00:00 2001 From: Sheldon Hull Date: Fri, 17 Feb 2023 14:25:04 -0600 Subject: [PATCH 2/6] refactor(compile): add trimpath to compile to remove local paths - Include trimpath to ensure local filepaths from CI or developer don't get included in the produced artifact. - This was added in Go 1.13, so not sure if there is something special to handle adding this flag only if go version > 1.13. --- .gitignore | 3 +++ mage/main.go | 2 ++ 2 files changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index 8d101a18..c55dbb5a 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,6 @@ Session.vim # Hugo build lock .hugo_build.lock + +# output files should be ignored +mage_out diff --git a/mage/main.go b/mage/main.go index 0a50da6d..b8b80e26 100644 --- a/mage/main.go +++ b/mage/main.go @@ -591,6 +591,8 @@ func Compile(goos, goarch, ldflags, magePath, goCmd, compileTo string, gofiles [ gofiles[i] = filepath.Base(gofiles[i]) } buildArgs := []string{"build", "-o", compileTo} + // buildArgs = append(buildArgs, "-trimpath") + if ldflags != "" { buildArgs = append(buildArgs, "-ldflags", ldflags) } From b4b8c57c589d140b3780365d5dd8df2faa6f0335 Mon Sep 17 00:00:00 2001 From: Sheldon Hull Date: Fri, 17 Feb 2023 14:29:42 -0600 Subject: [PATCH 3/6] uncomment new build arg --- mage/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mage/main.go b/mage/main.go index b8b80e26..b4e4f580 100644 --- a/mage/main.go +++ b/mage/main.go @@ -227,7 +227,7 @@ Commands: -version show version info for the mage binary Options: - -d + -d directory to read magefiles from (default "." or "magefiles" if exists) -debug turn on debug messages -f force recreation of compiled magefile @@ -591,7 +591,7 @@ func Compile(goos, goarch, ldflags, magePath, goCmd, compileTo string, gofiles [ gofiles[i] = filepath.Base(gofiles[i]) } buildArgs := []string{"build", "-o", compileTo} - // buildArgs = append(buildArgs, "-trimpath") + buildArgs = append(buildArgs, "-trimpath") if ldflags != "" { buildArgs = append(buildArgs, "-ldflags", ldflags) From 83c0c0417865ea8a63a0672e4ea3e013b5cbc09a Mon Sep 17 00:00:00 2001 From: sheldonhull Date: Tue, 21 Feb 2023 12:52:32 -0600 Subject: [PATCH 4/6] Undo doc changes from the other pull request --- site/content/index.md | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/site/content/index.md b/site/content/index.md index 83ad78cd..cdd334ed 100644 --- a/site/content/index.md +++ b/site/content/index.md @@ -73,21 +73,6 @@ asdf install mage latest asdf global mage latest ``` -### Using Aqua - -aqua is a declarative CLI Version Manager written in Go. -You can install CLI tools and manage their versions with YAML declaratively. - -To add to a project tool config: - -```shell -aqua init -aqua generate -i mage -aqua install -``` - -To add to a global `aqua.yaml`, add to the [global configuration](https://aquaproj.github.io/docs/tutorial-basics/global-config) and finally run `aqua install --all` for Mage to be installed. - ## Example Magefile ```go @@ -148,7 +133,7 @@ Commands: -version show version info for the mage binary Options: - -d + -d directory to read magefiles from (default ".") -debug turn on debug messages -f force recreation of compiled magefile From 1d38f853a009709660618a160eeb4c5146ea1ccd Mon Sep 17 00:00:00 2001 From: sheldonhull Date: Tue, 21 Feb 2023 12:53:23 -0600 Subject: [PATCH 5/6] Update index.md --- site/content/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/content/index.md b/site/content/index.md index cdd334ed..6f3f7a61 100644 --- a/site/content/index.md +++ b/site/content/index.md @@ -97,7 +97,7 @@ Run the above `Build` target by simply running `mage build` in the same director ## Magefiles directory -If you create your Magefile or files within a directory named `magefiles` And there is no Magefile in your current directory, +If you create your Magefile or files within a directory named `magefiles` And there is no Magefile in your current directory, `mage` will default to the directory as the source for your targets while keeping the current directory as working one. The result is the equivalent of running `mage -d magefiles -w .` From 1e323343443fbe6947009008b30f1bb376a706db Mon Sep 17 00:00:00 2001 From: sheldonhull Date: Fri, 24 Feb 2023 03:36:08 -0600 Subject: [PATCH 6/6] Update mage/main.go Co-authored-by: Horacio Duran --- mage/main.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mage/main.go b/mage/main.go index b4e4f580..939f6272 100644 --- a/mage/main.go +++ b/mage/main.go @@ -590,9 +590,7 @@ func Compile(goos, goarch, ldflags, magePath, goCmd, compileTo string, gofiles [ for i := range gofiles { gofiles[i] = filepath.Base(gofiles[i]) } - buildArgs := []string{"build", "-o", compileTo} - buildArgs = append(buildArgs, "-trimpath") - + buildArgs := []string{"build", "-o", compileTo, "-trimpath"} if ldflags != "" { buildArgs = append(buildArgs, "-ldflags", ldflags) }