Skip to content

Commit

Permalink
Support install binary to specific directory (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
LinuxSuRen committed Aug 24, 2022
1 parent 7a32e72 commit 9684e5c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 5 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ 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/
- --force
5 changes: 5 additions & 0 deletions cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

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

Expand Down Expand Up @@ -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"
}
Expand Down

0 comments on commit 9684e5c

Please sign in to comment.