From 6c06bb46ff2d3a514f2da2b54b44abec516ecfb1 Mon Sep 17 00:00:00 2001 From: Andrew Hamilton Date: Thu, 21 Jun 2018 21:12:13 -0700 Subject: [PATCH] Updates releaser to work better with HomeBrew - Fixes version used with replacer to strip off the "v" at the beginning - Fixes compiled options that weren't being set correctly again - Pushes out v0.1.1 which the updates --- releaser/INSTALL_RECEIPT.json.tmpl | 7 +------ releaser/main.go | 22 ++++++++++++++-------- releaser/relnotes.md | 6 ++++-- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/releaser/INSTALL_RECEIPT.json.tmpl b/releaser/INSTALL_RECEIPT.json.tmpl index 34d6b6e..ea33818 100644 --- a/releaser/INSTALL_RECEIPT.json.tmpl +++ b/releaser/INSTALL_RECEIPT.json.tmpl @@ -15,12 +15,7 @@ "stdlib": null, "compiler": "clang", "aliases": [], - "runtime_dependencies": [ - { - "full_name": "kubernetes-cli", - "version": "1.9.2" - } - ], + "runtime_dependencies": [], "source": { "path": "@@HOMEBREW_PREFIX@@/Homebrew/Library/Taps/dollarshaveclub/homebrew-public/Formula/psst.rb", "tap": "dollarshaveclub/public", diff --git a/releaser/main.go b/releaser/main.go index 80376d5..2a8dfd9 100644 --- a/releaser/main.go +++ b/releaser/main.go @@ -25,6 +25,7 @@ import ( "os" "os/exec" "path/filepath" + "regexp" "strings" "text/template" @@ -64,7 +65,7 @@ func init() { pflag.StringVar(&fpath, "formula", "Formula/psst.rb", "path to formula within tap repo") pflag.StringVar(&ftpath, "formula-template", "Formula/psst.rb.tmpl", "path to formula template within tap repo") pflag.StringVar(&targetoslist, "macos-versions", "el_capitan,high_sierra,sierra", "Supported MacOS versions (comma-delimited)") - pflag.UintVar(&hbrev, "homebrew-rev", 1, "Homebrew revision (bump to force reinstall/rebuild)") + pflag.UintVar(&hbrev, "homebrew-rev", 0, "Homebrew revision (bump to force reinstall/rebuild)") pflag.UintVar(&brbd, "bottle-rebuild", 1, "Bottle rebuild (bump to force bottle reinstall)") pflag.BoolVar(&draft, "draft", false, "Draft release (unpublished)") pflag.BoolVar(&prerelease, "prerelease", false, "Prerelease") @@ -172,8 +173,10 @@ type formulaTemplateData struct { func (ftd *formulaTemplateData) populate(bdefs []bottleDefinition) { ftd.Tag = rname ftd.CommitSHA = commitsha - ftd.HomebrewRevision = hbrev - ftd.BaseDownloadURL = fmt.Sprintf("https://github.com/%v/%v/releases/download/%v/", repoOwner, repoName, rname) + if hbrev > 0 { + ftd.HomebrewRevision = hbrev + } + ftd.BaseDownloadURL = fmt.Sprintf("https://github.com/%v/%v/releases/download/%v", repoOwner, repoName, rname) ftd.BottleRebuild = brbd ftd.Bottled = true ftd.BottleDefs = bdefs @@ -231,7 +234,7 @@ const ( linuxBinName = "psst-linux-amd64" ) -var buildopts = []string{"-ldflags", "-X github.com/dollarshaveclub/psst/internal/version.CommitSHA=%v -X github.com/dollarshaveclub/psst/internal/version.Version=%v -X $(REPO)/cmd.CompiledDirectory=github -X $(REPO)/cmd.CompiledStorage=vault -X $(REPO)/cmd.Org=dollarshaveclub"} +var buildopts = []string{"-ldflags", "-X github.com/dollarshaveclub/psst/cmd.CommitSHA=%v -X github.com/dollarshaveclub/psst/cmd.Version=%v -X github.com/dollarshaveclub/psst/cmd.CompiledDirectory=github -X github.com/dollarshaveclub/psst/cmd.CompiledStorage=vault -X github.com/dollarshaveclub/psst/cmd.Org=dollarshaveclub"} func buildBins() error { if err := os.MkdirAll("bins", os.ModeDir|0755); err != nil { @@ -295,7 +298,7 @@ func cpifneeded(src, dest string) error { return nil } -var bottleNameTmpl = template.Must(template.New("bn").Parse("psst-{{ .Release }}_{{ .HomebrewRevision }}.{{ .OS }}.bottle.{{ .BottleRebuild }}.tar.gz")) +var bottleNameTmpl = template.Must(template.New("bn").Parse("psst-{{ .Release }}{{ if .HomebrewRevision }}_{{ .HomebrewRevision }}{{ end }}.{{ .OS }}.bottle.{{ .BottleRebuild }}.tar.gz")) // createBottle synthetically creates a bottle tarball returning the bottle definitions, local bottle filenames and error if any func createBottle() ([]bottleDefinition, []string, error) { @@ -327,15 +330,18 @@ func createBottle() ([]bottleDefinition, []string, error) { return nil, nil, errors.Wrap(err, "error reading install receipt template") } tmpl, err := template.New("instrcpt").Parse(string(ir)) + semVer := regexp.MustCompile("([0-9.]+)").FindString(rname) d := struct { Release string OS string HomebrewRevision uint BottleRebuild uint }{ - Release: rname, - HomebrewRevision: hbrev, - BottleRebuild: brbd, + Release: semVer, + BottleRebuild: brbd, + } + if hbrev > 0 { + d.HomebrewRevision = hbrev } buf := bytes.NewBuffer([]byte{}) if err := tmpl.Execute(buf, &d); err != nil { diff --git a/releaser/relnotes.md b/releaser/relnotes.md index 17d43e9..dbe0761 100644 --- a/releaser/relnotes.md +++ b/releaser/relnotes.md @@ -1,3 +1,5 @@ -# Initial Release +# Fixes build for homebrew -- Adds command for sharing secrets using GitHub as a user directory and Vault as a secure storage backend. \ No newline at end of file +- Fixes build to include compiled in options. +- Fixes releaser so that it properly packages binaries for HomeBrew. +- Fixes HomeBrew tap templates so that bottles begin to work. \ No newline at end of file