|
1 | 1 | package main
|
2 | 2 |
|
3 |
| -import "github.com/solo-io/go-utils/githubutils" |
| 3 | +import ( |
| 4 | + "github.com/solo-io/go-utils/githubutils" |
| 5 | + "github.com/solo-io/go-utils/logger" |
| 6 | + "github.com/solo-io/go-utils/pkgmgmtutils" |
| 7 | +) |
4 | 8 |
|
5 | 9 | func main() {
|
| 10 | + const buildDir = "_output" |
| 11 | + const repoOwner = "solo-io" |
| 12 | + const repoName = "squash" |
| 13 | + |
6 | 14 | assets := make([]githubutils.ReleaseAssetSpec, 3)
|
7 | 15 | assets[0] = githubutils.ReleaseAssetSpec{
|
8 | 16 | Name: "squashctl-darwin",
|
9 |
| - ParentPath: "_output", |
| 17 | + ParentPath: buildDir, |
10 | 18 | UploadSHA: true,
|
11 | 19 | }
|
12 | 20 | assets[1] = githubutils.ReleaseAssetSpec{
|
13 | 21 | Name: "squashctl-linux",
|
14 |
| - ParentPath: "_output", |
| 22 | + ParentPath: buildDir, |
15 | 23 | UploadSHA: true,
|
16 | 24 | }
|
17 | 25 | assets[2] = githubutils.ReleaseAssetSpec{
|
18 | 26 | Name: "squashctl-windows.exe",
|
19 |
| - ParentPath: "_output", |
| 27 | + ParentPath: buildDir, |
20 | 28 | UploadSHA: true,
|
21 | 29 | }
|
| 30 | + |
22 | 31 | spec := githubutils.UploadReleaseAssetSpec{
|
23 |
| - Owner: "solo-io", |
24 |
| - Repo: "squash", |
| 32 | + Owner: repoOwner, |
| 33 | + Repo: repoName, |
25 | 34 | Assets: assets,
|
26 | 35 | SkipAlreadyExists: true,
|
27 | 36 | }
|
28 | 37 | githubutils.UploadReleaseAssetCli(&spec)
|
| 38 | + |
| 39 | + fOpts := []pkgmgmtutils.FormulaOptions{ |
| 40 | + { |
| 41 | + Name: "homebrew-tap/squashctl", |
| 42 | + FormulaName: "squashctl", |
| 43 | + Path: "Formula/squashctl.rb", |
| 44 | + RepoOwner: repoOwner, // Make change in this repo owner |
| 45 | + RepoName: "homebrew-tap", // expects this repo is forked from PRRepoOwner if PRRepoOwner != RepoOwner |
| 46 | + PRRepoOwner: repoOwner, // Make PR to this repo owner |
| 47 | + PRRepoName: "homebrew-tap", // and this repo |
| 48 | + PRBranch: "master", // and merge into this branch |
| 49 | + PRDescription: "", |
| 50 | + PRCommitName: "Solo-io Bot", |
| 51 | + PRCommitEmail: "[email protected]", |
| 52 | + VersionRegex: `version\s*"([0-9.]+)"`, |
| 53 | + DarwinShaRegex: `url\s*".*-darwin.*\W*sha256\s*"(.*)"`, |
| 54 | + LinuxShaRegex: `url\s*".*-linux.*\W*sha256\s*"(.*)"`, |
| 55 | + }, |
| 56 | + } |
| 57 | + |
| 58 | + // Update package manager install formulas |
| 59 | + status, err := pkgmgmtutils.UpdateFormulas(repoOwner, repoName, buildDir, |
| 60 | + `squashctl-(darwin|linux|windows).*\.sha256`, fOpts) |
| 61 | + if err != nil { |
| 62 | + logger.Fatalf("Error trying to update package manager formulas. Error was: %s", err.Error()) |
| 63 | + } |
| 64 | + for _, s := range status { |
| 65 | + if !s.Updated { |
| 66 | + if s.Err != nil { |
| 67 | + logger.Fatalf("Error while trying to update formula %s. Error was: %s", s.Name, s.Err.Error()) |
| 68 | + } else { |
| 69 | + logger.Fatalf("Error while trying to update formula %s. Error was nil", s.Name) // Shouldn't happen; really bad if it does |
| 70 | + } |
| 71 | + } |
| 72 | + if s.Err != nil { |
| 73 | + if s.Err == pkgmgmtutils.ErrAlreadyUpdated { |
| 74 | + logger.Warnf("Formula %s was updated externally, so no updates applied during this release", s.Name) |
| 75 | + } else { |
| 76 | + logger.Fatalf("Error updating Formula %s. Error was: %s", s.Name, s.Err.Error()) |
| 77 | + } |
| 78 | + } |
| 79 | + } |
29 | 80 | }
|
0 commit comments