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

Support install binary to specific directory #285

Merged
merged 1 commit into from
Aug 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
@@ -4,16 +4,16 @@ inputs:
version:
description: 'The version of hd'
required: false
default: 'v0.0.68'
default: 'v0.0.69'
tool:
description: 'The desired tool name'
required: true
runs:
using: 'docker'
image: 'docker://ghcr.io/linuxsuren/hd:v0.0.68'
image: 'docker://ghcr.io/linuxsuren/hd:v0.0.69'
args:
- hd
- get
- install
- ${{ inputs.tool }}
- --fetch=true
- --output=/github/home/${{ inputs.tool }}
- --target=/github/home/
5 changes: 5 additions & 0 deletions cmd/install.go
Original file line number Diff line number Diff line change
@@ -49,6 +49,7 @@ Cannot find your desired package? Please run command: hd fetch --reset, then try
"Indicate if install it via go install github.com/xxx/xxx")
flags.StringVarP(&opt.fromBranch, "from-branch", "", "master",
"Only works if the flag --from-source is true")
flags.StringVarP(&opt.target, "target", "", "/usr/local/bin", "The target installation directory")
flags.BoolVarP(&opt.goget, "goget", "", viper.GetBool("fetch"),
"Use command goget to download the binary, only works if the flag --from-source is true")

@@ -76,6 +77,7 @@ type installOption struct {
CleanPackage bool
fromSource bool
fromBranch string
target string
goget bool
force bool

@@ -159,6 +161,9 @@ func (o *installOption) install(cmd *cobra.Command, args []string) (err error) {
}
}

if o.target != "" {
o.Package.TargetDirectory = o.target
}
if o.Package.TargetDirectory == "" {
o.Package.TargetDirectory = "/usr/local/bin"
}