1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-06 03:13:48 +02:00
goreleaser/internal/pipe/chocolatey/template.go
Fabio Ribeiro f2281e8ff2
feat: chocolatey support (#3509)
This PR adds support for generating the structure used to pack and push
Chocolatey Packages. And will solve the #3154

Is not ready for merge yet, but has the main structure, and ready for
comments.

Accordingly to Chocolatey, in order to build a package, it's necessary a
`.nuspec` and `chocolateyinstall.ps1` files at least, having these ones,
we could pack and distribute without adding the binary inside the final
package and that was implemented here.

To complete, will be necessary to define the package build and
distribute, however will be required to have Chocolatey installed
(Windows Only). One of alternatives that I thought was, publish the
files like Scoop and Brew in a separate repository, and there we could
use `chocolatey` through
[crazy-max/ghaction-chocolatey](https://github.com/crazy-max/ghaction-chocolatey).

Chocolatey has a lot of good examples of repositories:

https://github.com/chocolatey-community/chocolatey-packages/tree/master/automatic/curl

A final compilation of the missing parts:
- [x] How to pack and push (chocolatey)
- [x] Documentation

Sorry for the long description😄 

All feedback very welcome!

Co-authored-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
2022-11-11 23:52:32 -03:00

39 lines
971 B
Go

package chocolatey
type templateData struct {
Packages []releasePackage
}
type releasePackage struct {
DownloadURL string
Checksum string
Arch string
}
const scriptTemplate = `# This file was generated by GoReleaser. DO NOT EDIT.
$ErrorActionPreference = 'Stop';
$version = $env:chocolateyPackageVersion
$packageName = $env:chocolateyPackageName
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$packageArgs = @{
packageName = $packageName
unzipLocation = $toolsDir
fileType = 'exe'
{{- range $release := .Packages }}
{{- if eq $release.Arch "amd64" }}
url64bit = '{{ $release.DownloadURL }}'
checksum64 = '{{ $release.Checksum }}'
checksumType64 = 'sha256'
{{- else }}
url = '{{ $release.DownloadURL }}'
checksum = '{{ $release.Checksum }}'
checksumType = 'sha256'
{{- end }}
{{- end }}
}
Install-ChocolateyZipPackage @packageArgs
`