From 5b1d3d560d86634babc2d4dafa5449e7256c3b7e Mon Sep 17 00:00:00 2001 From: Scott Cranton Date: Fri, 19 Apr 2019 11:08:17 -0400 Subject: [PATCH] Added update of package manager formulas during releases (#180) * Added update of package manager formulas during releases --- Gopkg.lock | 176 +++++++++++++++++- Gopkg.toml | 2 +- .../v0.5.9/package-management-update.yaml | 3 + ci/upload_github_release_assets.go | 63 ++++++- 4 files changed, 233 insertions(+), 11 deletions(-) create mode 100644 changelog/v0.5.9/package-management-update.yaml diff --git a/Gopkg.lock b/Gopkg.lock index 9fc98fd..7bdbd41 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -22,6 +22,14 @@ revision = "fc3b03a2d2d1f43fad3007038bd16f044f870722" version = "v9.10.0" +[[projects]] + digest = "1:22105f92bcc87302c07d8806a79c41cc29356b1e74b9a8607678fd3ba4af2bf0" + name = "github.com/avast/retry-go" + packages = ["."] + pruneopts = "" + revision = "08d411bf8302219fe47ca04dbdf9de892010c5e5" + version = "v2.2.0" + [[projects]] branch = "master" digest = "1:3c9f2cb0cbd46ecc6f6992a26bc6fdefa7bd0be1b9cd558666c1b7e9f605c825" @@ -80,6 +88,21 @@ revision = "06ea1031745cb8b3dab3f6a236daf2b0aa468b7e" version = "v3.2.0" +[[projects]] + digest = "1:f21c1a68814ffc02db479adbd973c710e0ece6150ddc0726655c0a2048299152" + name = "github.com/emirpasic/gods" + packages = [ + "containers", + "lists", + "lists/arraylist", + "trees", + "trees/binaryheap", + "utils", + ] + pruneopts = "" + revision = "1615341f118ae12f353cc8a983f35b584342c9b3" + version = "v1.12.0" + [[projects]] digest = "1:b2ac39cf926d768133bdd17e53333235a3e1d6154ed806777f0ba5f43819fa2e" name = "github.com/fgrosse/zaptest" @@ -383,6 +406,14 @@ revision = "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75" version = "v1.0" +[[projects]] + branch = "master" + digest = "1:95abc4eba158a39873bd4fabdee576d0ae13826b550f8b710881d80ae4093a0f" + name = "github.com/jbenet/go-context" + packages = ["io"] + pruneopts = "" + revision = "d14ea06fba99483203c19d92cfcd13ebe73135f4" + [[projects]] digest = "1:9eab2325abbed0ebcee9d44bb3660a69d5d10e42d5ac4a0e77f7a6ea22bfce88" name = "github.com/json-iterator/go" @@ -399,6 +430,14 @@ revision = "027a6d1765d673d337e687394dbe780dd64e2a1e" version = "v2.3.0" +[[projects]] + digest = "1:41e0bed5df4f9fd04c418bf9b6b7179b3671e416ad6175332601ca1c8dc74606" + name = "github.com/kevinburke/ssh_config" + packages = ["."] + pruneopts = "" + revision = "81db2a75821ed34e682567d48be488a1c3121088" + version = "0.5" + [[projects]] digest = "1:29d28429a93b076908a36420a7ecb2bf429d24c15a4b5e2c220ea00fc84b71af" name = "github.com/kr/pty" @@ -527,6 +566,14 @@ revision = "003f63b7f4cff3fc95357005358af2de0f5fe152" version = "v1.3.0" +[[projects]] + digest = "1:049b5bee78dfdc9628ee0e557219c41f683e5b06c5a5f20eaba0105ccc586689" + name = "github.com/pelletier/go-buffruneio" + packages = ["."] + pruneopts = "" + revision = "c37440a7cf42ac63b919c752ca73a85067e05992" + version = "v0.2.0" + [[projects]] digest = "1:894aef961c056b6d85d12bac890bf60c44e99b46292888bfa66caf529f804457" name = "github.com/pelletier/go-toml" @@ -586,6 +633,14 @@ revision = "572520ed46dbddaed19ea3d9541bdd0494163693" version = "v0.1" +[[projects]] + digest = "1:3962f553b77bf6c03fc07cd687a22dd3b00fe11aa14d31194f5505f5bb65cdc8" + name = "github.com/sergi/go-diff" + packages = ["diffmatchpatch"] + pruneopts = "" + revision = "1744e2970ca51c86172c8190fadad617561ed6e7" + version = "v1.0.0" + [[projects]] digest = "1:8cf46b6c18a91068d446e26b67512cf16f1540b45d90b28b9533706a127f0ca6" name = "github.com/sirupsen/logrus" @@ -603,7 +658,7 @@ version = "0.0.4" [[projects]] - digest = "1:c36f790d81d9722cfe9dfc954a6375ef7956b28fadf4a1c2e11ed79f4e856216" + digest = "1:f3c05862357a0aac4a5e416c933dd665eae23b3edb9d63839489acf8d0b62377" name = "github.com/solo-io/go-utils" packages = [ "changelogutils", @@ -615,12 +670,13 @@ "githubutils", "kubeutils", "logger", + "pkgmgmtutils", "protoutils", "versionutils", ] pruneopts = "" - revision = "e084fb30fbb39f78ce3dde57d5113fbf370d19ae" - version = "v0.2.14" + revision = "a27432d89f419897df796a17456410e49a9727c3" + version = "v0.7.11" [[projects]] digest = "1:1c0b84e64555e5e23b21af53d0aafbe2038da94545d54d0f8d06beb1b18948bc" @@ -727,6 +783,19 @@ revision = "6d33b5a963d922d182c91e8a1c88d81fd150cfd4" version = "v1.3.1" +[[projects]] + digest = "1:740b31391e4c3e4d2b5a20e1cbf2c2f7765275ead23945acc7669c36c0b8095a" + name = "github.com/src-d/gcfg" + packages = [ + ".", + "scanner", + "token", + "types", + ] + pruneopts = "" + revision = "1ac3a1ac202429a54835fe8408a92880156b489d" + version = "v1.4.0" + [[projects]] branch = "master" digest = "1:55110794a7ff6a8890578b5188988a6b6056db7e81a1dc2e631e2e10d9e3f4c8" @@ -743,6 +812,14 @@ pruneopts = "" revision = "be1fbeda19366dea804f00efff2dd73a1642fdcc" +[[projects]] + digest = "1:172f94a6b3644a8f9e6b5e5b7fc9fe1e42d424f52a0300b2e7ab1e57db73f85d" + name = "github.com/xanzy/ssh-agent" + packages = ["."] + pruneopts = "" + revision = "6a3e2ff9e7c564f36873c2e36413f634534f1c44" + version = "v0.2.1" + [[projects]] digest = "1:ad67dfd3799a2c58f6c65871dd141d8b53f61f600aec48ce8d7fa16a4d5476f8" name = "go.opencensus.io" @@ -805,7 +882,24 @@ branch = "master" digest = "1:b22f8b0c8fe3c1da65d3b55bdb57ed154945ac186b93fe75a1df0e9e3a3348a6" name = "golang.org/x/crypto" - packages = ["ssh/terminal"] + packages = [ + "cast5", + "curve25519", + "ed25519", + "ed25519/internal/edwards25519", + "internal/chacha20", + "openpgp", + "openpgp/armor", + "openpgp/elgamal", + "openpgp/errors", + "openpgp/packet", + "openpgp/s2k", + "poly1305", + "ssh", + "ssh/agent", + "ssh/knownhosts", + "ssh/terminal", + ] pruneopts = "" revision = "b49d69b5da943f7ef3c9cf91c8777c1f78a0cc3c" @@ -994,6 +1088,70 @@ revision = "d2d2541c53f18d2a059457998ce2876cc8e67cbf" version = "v0.9.1" +[[projects]] + digest = "1:cc4fc94e3088593a2cde96c032e05d1e3c7d494147d7a7d707445ccc478bf4a0" + name = "gopkg.in/src-d/go-billy.v4" + packages = [ + ".", + "helper/chroot", + "helper/polyfill", + "osfs", + "util", + ] + pruneopts = "" + revision = "982626487c60a5252e7d0b695ca23fb0fa2fd670" + version = "v4.3.0" + +[[projects]] + digest = "1:ba8b1140c5acd16441a389462395a66f7fb96738103562a8d781cb0029828317" + name = "gopkg.in/src-d/go-git.v4" + packages = [ + ".", + "config", + "internal/revision", + "internal/url", + "plumbing", + "plumbing/cache", + "plumbing/filemode", + "plumbing/format/config", + "plumbing/format/diff", + "plumbing/format/gitignore", + "plumbing/format/idxfile", + "plumbing/format/index", + "plumbing/format/objfile", + "plumbing/format/packfile", + "plumbing/format/pktline", + "plumbing/object", + "plumbing/protocol/packp", + "plumbing/protocol/packp/capability", + "plumbing/protocol/packp/sideband", + "plumbing/revlist", + "plumbing/storer", + "plumbing/transport", + "plumbing/transport/client", + "plumbing/transport/file", + "plumbing/transport/git", + "plumbing/transport/http", + "plumbing/transport/internal/common", + "plumbing/transport/server", + "plumbing/transport/ssh", + "storage", + "storage/filesystem", + "storage/filesystem/dotgit", + "storage/memory", + "utils/binary", + "utils/diff", + "utils/ioutil", + "utils/merkletrie", + "utils/merkletrie/filesystem", + "utils/merkletrie/index", + "utils/merkletrie/internal/frame", + "utils/merkletrie/noder", + ] + pruneopts = "" + revision = "aa6f288c256ff8baf8a7745546a9752323dc0d89" + version = "v4.11.0" + [[projects]] branch = "v1" digest = "1:a96d16bd088460f2e0685d46c39bcf1208ba46e0a977be2df49864ec7da447dd" @@ -1002,6 +1160,14 @@ pruneopts = "" revision = "dd632973f1e7218eb1089048e0798ec9ae7dceb8" +[[projects]] + digest = "1:ceec7e96590fb8168f36df4795fefe17051d4b0c2acc7ec4e260d8138c4dafac" + name = "gopkg.in/warnings.v0" + packages = ["."] + pruneopts = "" + revision = "ec4a0fea49c7b46c2aeb0b51aac55779c607e52b" + version = "v0.1.2" + [[projects]] digest = "1:f0620375dd1f6251d9973b5f2596228cc8042e887cd7f827e4220bc1ce8c30e2" name = "gopkg.in/yaml.v2" @@ -1287,6 +1453,8 @@ "github.com/solo-io/go-utils/errors", "github.com/solo-io/go-utils/githubutils", "github.com/solo-io/go-utils/kubeutils", + "github.com/solo-io/go-utils/logger", + "github.com/solo-io/go-utils/pkgmgmtutils", "github.com/solo-io/go-utils/versionutils", "github.com/solo-io/solo-kit/pkg/api/v1/clients", "github.com/solo-io/solo-kit/pkg/api/v1/clients/factory", diff --git a/Gopkg.toml b/Gopkg.toml index de2eb88..ecbca11 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -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" diff --git a/changelog/v0.5.9/package-management-update.yaml b/changelog/v0.5.9/package-management-update.yaml new file mode 100644 index 0000000..a1197b8 --- /dev/null +++ b/changelog/v0.5.9/package-management-update.yaml @@ -0,0 +1,3 @@ +changelog: + - type: NON_USER_FACING + description: Added auto update of packagement management formulas as part of release process diff --git a/ci/upload_github_release_assets.go b/ci/upload_github_release_assets.go index c3e414b..4096d5b 100755 --- a/ci/upload_github_release_assets.go +++ b/ci/upload_github_release_assets.go @@ -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: "bot@solo.io", + 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()) + } + } + } }