| 244 | } |
| 245 | |
| 246 | func getLatestVersion(modName string) (string, error) { |
| 247 | cmd := exec.Command("git", "tag", "-l", modName+"/v*", "--sort=-v:refname") |
| 248 | out, err := cmd.CombinedOutput() |
| 249 | if err != nil { |
| 250 | return "", err |
| 251 | } |
| 252 | lines := strings.Split(string(out), "\n") |
| 253 | if len(lines) == 0 { |
| 254 | return "", fmt.Errorf("no releases") |
| 255 | } |
| 256 | latest := strings.TrimSpace(lines[0]) |
| 257 | prefix := modName + "/" |
| 258 | |
| 259 | if latest == "" { |
| 260 | latest = prefix + "v0.0.0" |
| 261 | } |
| 262 | |
| 263 | if !strings.HasPrefix(latest, prefix) { |
| 264 | return "", fmt.Errorf("unexptected format of latest release: %s", latest) |
| 265 | } |
| 266 | return strings.TrimPrefix(latest, prefix), nil |
| 267 | } |
| 268 | |
| 269 | func gitTag(ctx context.Context, tag string) error { |
| 270 | cmd := exec.CommandContext(ctx, "git", "tag", tag, "-m", tag) |