Skip to content

Commit 5b1d3d5

Browse files
scrantonsoloio-bulldozer[bot]
authored andcommitted
Added update of package manager formulas during releases (#180)
* Added update of package manager formulas during releases
1 parent 83de321 commit 5b1d3d5

File tree

4 files changed

+233
-11
lines changed

4 files changed

+233
-11
lines changed

Gopkg.lock

Lines changed: 172 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959

6060
[[constraint]]
6161
name = "github.com/solo-io/go-utils"
62-
version = "0.2.12"
62+
version = "0.7.11"
6363

6464
[[override]]
6565
name = "gopkg.in/fsnotify.v1"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
changelog:
2+
- type: NON_USER_FACING
3+
description: Added auto update of packagement management formulas as part of release process

ci/upload_github_release_assets.go

Lines changed: 57 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,80 @@
11
package main
22

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+
)
48

59
func main() {
10+
const buildDir = "_output"
11+
const repoOwner = "solo-io"
12+
const repoName = "squash"
13+
614
assets := make([]githubutils.ReleaseAssetSpec, 3)
715
assets[0] = githubutils.ReleaseAssetSpec{
816
Name: "squashctl-darwin",
9-
ParentPath: "_output",
17+
ParentPath: buildDir,
1018
UploadSHA: true,
1119
}
1220
assets[1] = githubutils.ReleaseAssetSpec{
1321
Name: "squashctl-linux",
14-
ParentPath: "_output",
22+
ParentPath: buildDir,
1523
UploadSHA: true,
1624
}
1725
assets[2] = githubutils.ReleaseAssetSpec{
1826
Name: "squashctl-windows.exe",
19-
ParentPath: "_output",
27+
ParentPath: buildDir,
2028
UploadSHA: true,
2129
}
30+
2231
spec := githubutils.UploadReleaseAssetSpec{
23-
Owner: "solo-io",
24-
Repo: "squash",
32+
Owner: repoOwner,
33+
Repo: repoName,
2534
Assets: assets,
2635
SkipAlreadyExists: true,
2736
}
2837
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+
}
2980
}

0 commit comments

Comments
 (0)