Skip to content

Commit

Permalink
feat: ability to specify fixed tag (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
zyrouge committed Jul 14, 2024
1 parent d0557e6 commit 0e44778
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions commands/install_github.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
var githubSourceReleaseStrings = []string{
string(core.GithubSourceReleaseLatest),
string(core.GithubSourceReleasePreRelease),
string(core.GithubSourceReleaseTagged),
string(core.GithubSourceReleaseAny),
}

Expand All @@ -38,6 +39,14 @@ var InstallGithubCommand = cli.Command{
),
Value: githubSourceReleaseStrings[0],
},
&cli.StringFlag{
Name: "tag",
Aliases: []string{"t"},
Usage: fmt.Sprintf(
"Release tag name (requires release to be %s)",
core.GithubSourceReleaseTagged,
),
},
&cli.BoolFlag{
Name: "link",
Aliases: []string{"l"},
Expand Down Expand Up @@ -68,11 +77,13 @@ var InstallGithubCommand = cli.Command{
url := args.Get(0)
appId := cmd.String("id")
releaseType := cmd.String("release")
tagName := cmd.String("tag")
link := cmd.Bool("link")
assumeYes := cmd.Bool("assume-yes")
utils.LogDebug(fmt.Sprintf("argument url: %s", url))
utils.LogDebug(fmt.Sprintf("argument id: %s", appId))
utils.LogDebug(fmt.Sprintf("argument release: %v", releaseType))
utils.LogDebug(fmt.Sprintf("argument tag: %v", tagName))
utils.LogDebug(fmt.Sprintf("argument link: %v", link))
utils.LogDebug(fmt.Sprintf("argument assume-yes: %v", assumeYes))

Expand Down Expand Up @@ -100,6 +111,7 @@ var InstallGithubCommand = cli.Command{
UserName: ghUsername,
RepoName: ghReponame,
Release: core.GithubSourceRelease(releaseType),
TagName: tagName,
}
release, err := source.FetchAptRelease()
if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions core/github_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ type GithubSourceRelease string
const (
GithubSourceReleaseLatest GithubSourceRelease = "latest"
GithubSourceReleasePreRelease GithubSourceRelease = "prerelease"
GithubSourceReleaseTagged GithubSourceRelease = "tag"
GithubSourceReleaseAny GithubSourceRelease = "any"
)

type GithubSource struct {
UserName string `json:"UserName"`
RepoName string `json:"RepoName"`
Release GithubSourceRelease `json:"Release"`
TagName string `json:"TagName"`
}

func ReadGithubSourceConfig(configPath string) (*GithubSource, error) {
Expand All @@ -39,6 +41,9 @@ func (source *GithubSource) FetchAptLatestRelease() (*GithubApiRelease, error) {
case GithubSourceReleasePreRelease:
return GithubApiFetchLatestPreRelease(source.UserName, source.RepoName)

case GithubSourceReleaseTagged:
return GithubApiFetchTaggedRelease(source.UserName, source.RepoName, source.TagName)

case GithubSourceReleaseAny:
return GithubApiFetchLatestAny(source.UserName, source.RepoName)

Expand Down

0 comments on commit 0e44778

Please sign in to comment.