{"id":19859587,"url":"https://github.com/youngjuning/go-release","last_synced_at":"2025-05-02T02:31:37.023Z","repository":{"id":54119895,"uuid":"335629928","full_name":"youngjuning/go-release","owner":"youngjuning","description":"A version control tool based on github release.","archived":false,"fork":false,"pushed_at":"2021-03-09T03:46:35.000Z","size":90,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-06T21:32:11.816Z","etag":null,"topics":["cli","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/youngjuning.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-03T13:16:23.000Z","updated_at":"2023-11-20T13:42:12.000Z","dependencies_parsed_at":"2022-08-13T07:00:40.800Z","dependency_job_id":null,"html_url":"https://github.com/youngjuning/go-release","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/youngjuning%2Fgo-release","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/youngjuning%2Fgo-release/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/youngjuning%2Fgo-release/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/youngjuning%2Fgo-release/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/youngjuning","download_url":"https://codeload.github.com/youngjuning/go-release/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251972523,"owners_count":21673618,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","golang"],"created_at":"2024-11-12T14:29:18.312Z","updated_at":"2025-05-02T02:31:32.007Z","avatar_url":"https://github.com/youngjuning.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-release\n\nA version control tools based on github release.\n\n## Why Use?\n\nWe assume the following conditions:\n\n1. You have a binary executable and publish it to GitHub release like [Deno](https://github.com/denoland/deno/releases) do.\n2. You want to realize `upgrade` command like `deno upgrade`\n\n\u003e Try me help you to do that.\n\n## Install\n\n```sh\n$ go get github.com/youngjuning/go-release\n```\n\n## Example\n\n```go\npackage main\n\nimport \"github.com/youngjuning/go-release\"\n\nfunc main() {\n  update, err := release.CheckUpdate(\"denoland\", \"deno\", \"0.0.1\")\n  if err != nil {\n    panic(err)\n  }\n  if update.IsUpdate {\n    fmt.Printf(\"Latest version is %v.\\n\",update.LatestVersion) // out: Latest version is 1.7.1.\n    // Run upgrade command\n  }\n}\n```\n\n## Use in Cobra\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/codeskyblue/go-sh\"\n\t\"github.com/spf13/cobra\"\n\t\"github.com/youngjuning/go-release\"\n)\n\nconst Version = \"0.0.1\"\n\nfunc checkUpgrade(current string, force bool) {\n\tif force {\n\t\tfmt.Println(\"Looking up latest version\")\n\t}\n\tupdate, err := release.CheckUpdate(\"youngjuning\", \"tpc\", current)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tif update.IsUpdate {\n\t\tif force {\n\t\t\tfmt.Printf(\"Found latest version %v \\n\", update.LatestVersion)\n\t\t} else {\n\t\t\tfmt.Printf(\"Found tpc latest version %v \\n\", update.LatestVersion)\n\t\t}\n\t\t// bin while install to \"~/.tuya/bin/tpc\".Please use in your case.\n\t\t// tpc is the string from tpc-*.zip.Please use in your case.\n\t\t// Run upgrade command\n\t\tif !force {\n\t\t\tfmt.Println(\"\\nPress any key to exit.\")\n\t\t}\n\t} else {\n\t\tif force {\n\t\t\tfmt.Printf(\"Local tpc version %v is the most recent release \\n\", current)\n\t\t}\n\t}\n}\n\nvar rootCmd = \u0026cobra.Command{\n\tUse:     \"tpc\",\n\tVersion: Version,\n\tRun: func(cmd *cobra.Command, args []string) {\n\t\tsh.Command(\"tpc\", \"-h\").Run()\n\t},\n\tPersistentPostRun: func(cmd *cobra.Command, args []string) {\n\t\tsh.Command(\"bash\", \"-c\", \"tpc upgrade --force=false\").Start()\n\t},\n}\n\nvar cmdUpgrade = \u0026cobra.Command{\n\tUse: \"upgrade\",\n\tRun: func(cmd *cobra.Command, args []string) {\n\t\tforce, _ := cmd.Flags().GetBool(\"force\")\n\t\tcheckUpgrade(Version, force)\n\t},\n\tPersistentPostRun: func(cmd *cobra.Command, args []string) {},\n}\n\nfunc main() {\n\tcmdUpgrade.Flags().Bool(\"force\", true, \"Force to upgrade\")\n\trootCmd.AddCommand(cmdUpgrade)\n\trootCmd.Execute()\n}\n```\n\n## TODO\n\n- [x] Add Test (I can't write it. SOS)\n```bash\n➜  go-release (main) ✗ go test -v .\n=== RUN   TestRelease\n    release_test.go:18: Latest version is 1.8.0.\n    release_test.go:25: Latest Release URL is https://github.com/denoland/deno/releases/latest.\n--- PASS: TestRelease (0.68s)\nPASS\nok  \tgithub.com/youngjuning/go-release\t0.795s\n```\n- [ ] Add Release CI\n\n## Thanks\n\nThis project is inspired on https://github.com/denoland/deno. Thanks for the author.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoungjuning%2Fgo-release","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyoungjuning%2Fgo-release","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoungjuning%2Fgo-release/lists"}