Skip to content

Commit

Permalink
Added update of package manager formulas during releases (#180)
Browse files Browse the repository at this point in the history
* Added update of package manager formulas during releases
  • Loading branch information
scranton authored and soloio-bulldozer[bot] committed Apr 19, 2019
1 parent 83de321 commit 5b1d3d5
Show file tree
Hide file tree
Showing 4 changed files with 233 additions and 11 deletions.
176 changes: 172 additions & 4 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

[[constraint]]
name = "github.com/solo-io/go-utils"
version = "0.2.12"
version = "0.7.11"

[[override]]
name = "gopkg.in/fsnotify.v1"
Expand Down
3 changes: 3 additions & 0 deletions changelog/v0.5.9/package-management-update.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
changelog:
- type: NON_USER_FACING
description: Added auto update of packagement management formulas as part of release process
63 changes: 57 additions & 6 deletions ci/upload_github_release_assets.go
Original file line number Diff line number Diff line change
@@ -1,29 +1,80 @@
package main

import "github.com/solo-io/go-utils/githubutils"
import (
"github.com/solo-io/go-utils/githubutils"
"github.com/solo-io/go-utils/logger"
"github.com/solo-io/go-utils/pkgmgmtutils"
)

func main() {
const buildDir = "_output"
const repoOwner = "solo-io"
const repoName = "squash"

assets := make([]githubutils.ReleaseAssetSpec, 3)
assets[0] = githubutils.ReleaseAssetSpec{
Name: "squashctl-darwin",
ParentPath: "_output",
ParentPath: buildDir,
UploadSHA: true,
}
assets[1] = githubutils.ReleaseAssetSpec{
Name: "squashctl-linux",
ParentPath: "_output",
ParentPath: buildDir,
UploadSHA: true,
}
assets[2] = githubutils.ReleaseAssetSpec{
Name: "squashctl-windows.exe",
ParentPath: "_output",
ParentPath: buildDir,
UploadSHA: true,
}

spec := githubutils.UploadReleaseAssetSpec{
Owner: "solo-io",
Repo: "squash",
Owner: repoOwner,
Repo: repoName,
Assets: assets,
SkipAlreadyExists: true,
}
githubutils.UploadReleaseAssetCli(&spec)

fOpts := []pkgmgmtutils.FormulaOptions{
{
Name: "homebrew-tap/squashctl",
FormulaName: "squashctl",
Path: "Formula/squashctl.rb",
RepoOwner: repoOwner, // Make change in this repo owner
RepoName: "homebrew-tap", // expects this repo is forked from PRRepoOwner if PRRepoOwner != RepoOwner
PRRepoOwner: repoOwner, // Make PR to this repo owner
PRRepoName: "homebrew-tap", // and this repo
PRBranch: "master", // and merge into this branch
PRDescription: "",
PRCommitName: "Solo-io Bot",
PRCommitEmail: "[email protected]",
VersionRegex: `version\s*"([0-9.]+)"`,
DarwinShaRegex: `url\s*".*-darwin.*\W*sha256\s*"(.*)"`,
LinuxShaRegex: `url\s*".*-linux.*\W*sha256\s*"(.*)"`,
},
}

// Update package manager install formulas
status, err := pkgmgmtutils.UpdateFormulas(repoOwner, repoName, buildDir,
`squashctl-(darwin|linux|windows).*\.sha256`, fOpts)
if err != nil {
logger.Fatalf("Error trying to update package manager formulas. Error was: %s", err.Error())
}
for _, s := range status {
if !s.Updated {
if s.Err != nil {
logger.Fatalf("Error while trying to update formula %s. Error was: %s", s.Name, s.Err.Error())
} else {
logger.Fatalf("Error while trying to update formula %s. Error was nil", s.Name) // Shouldn't happen; really bad if it does
}
}
if s.Err != nil {
if s.Err == pkgmgmtutils.ErrAlreadyUpdated {
logger.Warnf("Formula %s was updated externally, so no updates applied during this release", s.Name)
} else {
logger.Fatalf("Error updating Formula %s. Error was: %s", s.Name, s.Err.Error())
}
}
}
}

0 comments on commit 5b1d3d5

Please sign in to comment.