@@ -182,32 +182,32 @@ func (p *Publisher) publishGitHubRelease(
182182}
183183
184184// HomebrewCaskSettings holds the custom settings for homebrew_cask publisher.
185+ // Field names match their Homebrew cask stanza counterparts.
185186type HomebrewCaskSettings struct {
187+ Name string `mapstructure:"name"`
188+ Desc string `mapstructure:"desc"`
189+ Homepage string `mapstructure:"homepage"`
190+ Pkg string `mapstructure:"pkg"` // Override pkg filename
191+ Binary string `mapstructure:"binary"` // Full path to binary, e.g. /usr/local/bin/hugoreleaser
186192 BundleIdentifier string `mapstructure:"bundle_identifier"`
187193 TapRepository string `mapstructure:"tap_repository"`
188- Name string `mapstructure:"name"`
189194 CaskPath string `mapstructure:"cask_path"`
190195 TemplateFilename string `mapstructure:"template_filename"`
191- Description string `mapstructure:"description"`
192- Homepage string `mapstructure:"homepage"`
193- BinaryName string `mapstructure:"binary_name"`
194- BinaryLocation string `mapstructure:"binary_location"`
195196}
196197
197198// HomebrewCaskContext holds data for the Homebrew cask template.
199+ // Field names match their Homebrew cask stanza counterparts.
198200type HomebrewCaskContext struct {
199- Name string
200- DisplayName string
201+ Token string // Cask identifier, e.g. "hugoreleaser"
201202 Version string
202203 SHA256 string
203204 URL string
204- Description string
205+ Name string // Display name for "name" stanza
206+ Desc string
205207 Homepage string
206- PkgFilename string
208+ Pkg string
209+ Binary string
207210 BundleIdentifier string
208-
209- // TODO(bep) check how goreleaser does this.
210- BinaryPath string // Full path to binary, e.g. /usr/local/bin/hugoreleaser
211211}
212212
213213func (p * Publisher ) updateHomebrewCask (
@@ -239,12 +239,6 @@ func (p *Publisher) updateHomebrewCask(
239239 if settings .CaskPath == "" {
240240 settings .CaskPath = fmt .Sprintf ("Casks/%s.rb" , settings .Name )
241241 }
242- if settings .BinaryName == "" {
243- settings .BinaryName = p .core .Config .BuildSettings .Binary
244- }
245- if settings .BinaryLocation == "" {
246- settings .BinaryLocation = "/usr/local/bin"
247- }
248242
249243 // Find the first .pkg archive matching the archive paths pattern.
250244 pkgInfo , err := p .findPkgArchive (release , pub .ArchivePathsCompiled )
@@ -254,6 +248,12 @@ func (p *Publisher) updateHomebrewCask(
254248
255249 logCtx .WithField ("pkg" , pkgInfo .Name ).Log (logg .String ("Found pkg archive" ))
256250
251+ // Use pkg filename from settings if provided, otherwise from archive.
252+ pkgFilename := settings .Pkg
253+ if pkgFilename == "" {
254+ pkgFilename = pkgInfo .Name
255+ }
256+
257257 // Build download URL.
258258 downloadURL := fmt .Sprintf (
259259 "https://github.com/%s/%s/releases/download/%s/%s" ,
@@ -263,24 +263,18 @@ func (p *Publisher) updateHomebrewCask(
263263 pkgInfo .Name ,
264264 )
265265
266- // Build binary path if binary_name is configured.
267- var binaryPath string
268- if settings .BinaryName != "" {
269- binaryPath = filepath .Join (settings .BinaryLocation , settings .BinaryName )
270- }
271-
272266 // Build cask context.
273267 caskCtx := HomebrewCaskContext {
274- Name : settings .Name ,
275- DisplayName : p .core .Config .Project ,
268+ Token : settings .Name ,
269+ Name : p .core .Config .Project ,
276270 Version : version ,
277271 SHA256 : pkgInfo .SHA256 ,
278272 URL : downloadURL ,
279- Description : settings .Description ,
273+ Desc : settings .Desc ,
280274 Homepage : settings .Homepage ,
281- PkgFilename : pkgInfo .Name ,
275+ Pkg : pkgFilename ,
276+ Binary : settings .Binary ,
282277 BundleIdentifier : settings .BundleIdentifier ,
283- BinaryPath : binaryPath ,
284278 }
285279
286280 // Render cask template.
0 commit comments