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-12 03:52:32 +01:00
package chocolatey
import (
"errors"
"os"
"path/filepath"
"testing"
"github.com/goreleaser/goreleaser/internal/artifact"
"github.com/goreleaser/goreleaser/internal/client"
"github.com/goreleaser/goreleaser/internal/golden"
2023-03-02 00:01:11 -03:00
"github.com/goreleaser/goreleaser/internal/testctx"
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-12 03:52:32 +01:00
"github.com/goreleaser/goreleaser/internal/testlib"
"github.com/goreleaser/goreleaser/pkg/config"
"github.com/goreleaser/goreleaser/pkg/context"
"github.com/stretchr/testify/require"
)
2023-06-20 09:33:59 -03:00
func TestContinueOnError ( t * testing . T ) {
require . True ( t , Pipe { } . ContinueOnError ( ) )
}
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-12 03:52:32 +01:00
func TestDescription ( t * testing . T ) {
require . NotEmpty ( t , Pipe { } . String ( ) )
}
func TestSkip ( t * testing . T ) {
2023-03-02 00:01:11 -03:00
ctx := testctx . New ( )
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-12 03:52:32 +01:00
require . True ( t , Pipe { } . Skip ( ctx ) )
}
func TestDefault ( t * testing . T ) {
testlib . Mktmp ( t )
2023-03-02 00:01:11 -03:00
ctx := testctx . NewWithCfg ( config . Project {
ProjectName : "myproject" ,
Chocolateys : [ ] config . Chocolatey {
{ } ,
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-12 03:52:32 +01:00
} ,
2023-03-02 00:01:11 -03:00
} , testctx . GitHubTokenType )
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-12 03:52:32 +01:00
require . NoError ( t , Pipe { } . Default ( ctx ) )
require . Equal ( t , ctx . Config . ProjectName , ctx . Config . Chocolateys [ 0 ] . Name )
require . Equal ( t , ctx . Config . ProjectName , ctx . Config . Chocolateys [ 0 ] . Title )
require . Equal ( t , "v1" , ctx . Config . Chocolateys [ 0 ] . Goamd64 )
}
func Test_doRun ( t * testing . T ) {
folder := t . TempDir ( )
file := filepath . Join ( folder , "archive" )
require . NoError ( t , os . WriteFile ( file , [ ] byte ( "lorem ipsum" ) , 0 o644 ) )
tests := [ ] struct {
name string
choco config . Chocolatey
2023-09-16 14:08:11 -03:00
exec func ( cmd string , args ... string ) ( [ ] byte , error )
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-12 03:52:32 +01:00
published int
err string
} {
{
name : "no artifacts" ,
choco : config . Chocolatey {
Name : "app" ,
IDs : [ ] string { "no-app" } ,
Goamd64 : "v1" ,
} ,
err : "chocolatey requires a windows build and archive" ,
} ,
{
name : "choco command not found" ,
choco : config . Chocolatey {
Name : "app" ,
Goamd64 : "v1" ,
} ,
2023-09-16 14:08:11 -03:00
exec : func ( _ string , _ ... string ) ( [ ] byte , error ) {
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-12 03:52:32 +01:00
return nil , errors . New ( ` exec: "choco.exe": executable file not found in $PATH ` )
} ,
err : ` failed to generate chocolatey package: exec: "choco.exe": executable file not found in $PATH: ` ,
} ,
{
name : "skip publish" ,
choco : config . Chocolatey {
Name : "app" ,
Goamd64 : "v1" ,
SkipPublish : true ,
} ,
2023-09-16 14:08:11 -03:00
exec : func ( cmd string , args ... string ) ( [ ] byte , error ) {
checkPackCmd ( t , cmd , args ... )
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-12 03:52:32 +01:00
return [ ] byte ( "success" ) , nil
} ,
} ,
{
name : "success" ,
choco : config . Chocolatey {
Name : "app" ,
Goamd64 : "v1" ,
} ,
2023-09-16 14:08:11 -03:00
exec : func ( cmd string , args ... string ) ( [ ] byte , error ) {
checkPackCmd ( t , cmd , args ... )
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-12 03:52:32 +01:00
return [ ] byte ( "success" ) , nil
} ,
published : 1 ,
} ,
}
for _ , tt := range tests {
t . Run ( tt . name , func ( t * testing . T ) {
cmd = fakeCmd { execFn : tt . exec }
t . Cleanup ( func ( ) {
cmd = stdCmd { }
} )
2023-03-02 00:01:11 -03:00
ctx := testctx . NewWithCfg (
config . Project {
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-12 03:52:32 +01:00
Dist : folder ,
ProjectName : "run-all" ,
} ,
2023-03-02 00:01:11 -03:00
testctx . WithCurrentTag ( "v1.0.1" ) ,
testctx . WithVersion ( "1.0.1" ) ,
)
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-12 03:52:32 +01:00
ctx . Artifacts . Add ( & artifact . Artifact {
Name : "app_1.0.1_windows_amd64.zip" ,
Path : file ,
Goos : "windows" ,
Goarch : "amd64" ,
Goamd64 : "v1" ,
Type : artifact . UploadableArchive ,
Extra : map [ string ] interface { } {
artifact . ExtraID : "app" ,
artifact . ExtraFormat : "zip" ,
} ,
} )
client := client . NewMock ( )
got := doRun ( ctx , client , tt . choco )
var err string
if got != nil {
err = got . Error ( )
}
if tt . err != err {
t . Errorf ( "Unexpected error: %s (expected %s)" , err , tt . err )
}
list := ctx . Artifacts . Filter ( artifact . ByType ( artifact . PublishableChocolatey ) ) . List ( )
require . Len ( t , list , tt . published )
} )
}
}
func Test_buildNuspec ( t * testing . T ) {
2023-03-02 00:01:11 -03:00
ctx := testctx . New ( testctx . WithVersion ( "1.12.3" ) )
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-12 03:52:32 +01:00
choco := config . Chocolatey {
Name : "goreleaser" ,
IDs : [ ] string { } ,
Title : "GoReleaser" ,
Authors : "caarlos0" ,
ProjectURL : "https://goreleaser.com/" ,
Tags : "go docker homebrew golang package" ,
Summary : "Deliver Go binaries as fast and easily as possible" ,
Description : "GoReleaser builds Go binaries for several platforms, creates a GitHub release and then pushes a Homebrew formula to a tap repository. All that wrapped in your favorite CI." ,
Dependencies : [ ] config . ChocolateyDependency {
{ ID : "nfpm" } ,
} ,
}
out , err := buildNuspec ( ctx , choco )
require . NoError ( t , err )
golden . RequireEqualExt ( t , out , ".nuspec" )
}
func Test_buildTemplate ( t * testing . T ) {
folder := t . TempDir ( )
file := filepath . Join ( folder , "archive" )
require . NoError ( t , os . WriteFile ( file , [ ] byte ( "lorem ipsum" ) , 0 o644 ) )
2023-03-02 00:01:11 -03:00
ctx := testctx . New ( testctx . WithVersion ( "1.0.0" ) , testctx . WithCurrentTag ( "v1.0.0" ) )
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-12 03:52:32 +01:00
artifacts := [ ] * artifact . Artifact {
{
Name : "app_1.0.0_windows_386.zip" ,
Goos : "windows" ,
Goarch : "386" ,
Goamd64 : "v1" ,
Path : file ,
} ,
{
Name : "app_1.0.0_windows_amd64.zip" ,
Goos : "windows" ,
Goarch : "amd64" ,
Goamd64 : "v1" ,
Path : file ,
} ,
}
choco := config . Chocolatey {
Name : "app" ,
}
client := client . NewMock ( )
data , err := dataFor ( ctx , client , choco , artifacts )
if err != nil {
t . Error ( err )
}
out , err := buildTemplate ( choco . Name , scriptTemplate , data )
require . NoError ( t , err )
golden . RequireEqualExt ( t , out , ".script.ps1" )
}
func TestPublish ( t * testing . T ) {
folder := t . TempDir ( )
file := filepath . Join ( folder , "archive" )
require . NoError ( t , os . WriteFile ( file , [ ] byte ( "lorem ipsum" ) , 0 o644 ) )
2023-09-16 14:08:11 -03:00
fakenu := filepath . Join ( t . TempDir ( ) , "foo.nupkg" )
require . NoError ( t , os . WriteFile ( fakenu , [ ] byte ( "fake nupkg" ) , 0 o644 ) )
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-12 03:52:32 +01:00
tests := [ ] struct {
name string
artifacts [ ] artifact . Artifact
2023-09-16 14:08:11 -03:00
exec func ( cmd string , args ... string ) ( [ ] byte , error )
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-12 03:52:32 +01:00
skip bool
err string
} {
{
name : "no artifacts" ,
} ,
{
name : "no api key" ,
artifacts : [ ] artifact . Artifact {
{
Type : artifact . PublishableChocolatey ,
Name : "app.1.0.1.nupkg" ,
Extra : map [ string ] interface { } {
artifact . ExtraFormat : nupkgFormat ,
chocoConfigExtra : config . Chocolatey { } ,
} ,
} ,
} ,
} ,
{
name : "push error" ,
artifacts : [ ] artifact . Artifact {
{
Type : artifact . PublishableChocolatey ,
Name : "app.1.0.1.nupkg" ,
Extra : map [ string ] interface { } {
artifact . ExtraFormat : nupkgFormat ,
chocoConfigExtra : config . Chocolatey {
APIKey : "abcd" ,
} ,
} ,
} ,
} ,
2023-09-16 14:08:11 -03:00
exec : func ( cmd string , args ... string ) ( [ ] byte , error ) {
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-12 03:52:32 +01:00
return nil , errors . New ( ` unable to push ` )
} ,
err : "failed to push chocolatey package: unable to push: " ,
} ,
{
name : "success" ,
artifacts : [ ] artifact . Artifact {
{
Type : artifact . PublishableChocolatey ,
Name : "app.1.0.1.nupkg" ,
2023-09-16 14:08:11 -03:00
Path : fakenu ,
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-12 03:52:32 +01:00
Extra : map [ string ] interface { } {
artifact . ExtraFormat : nupkgFormat ,
chocoConfigExtra : config . Chocolatey {
2023-09-16 14:08:11 -03:00
APIKey : "abcd" ,
SourceRepo : "abc" ,
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-12 03:52:32 +01:00
} ,
} ,
} ,
} ,
2023-09-16 14:08:11 -03:00
exec : func ( cmd string , args ... string ) ( [ ] byte , error ) {
checkPushCmd ( t , cmd , args ... )
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-12 03:52:32 +01:00
return [ ] byte ( "success" ) , nil
} ,
} ,
}
for _ , tt := range tests {
t . Run ( tt . name , func ( t * testing . T ) {
cmd = fakeCmd { execFn : tt . exec }
t . Cleanup ( func ( ) {
cmd = stdCmd { }
} )
2023-09-04 16:20:58 -03:00
ctx := testctx . New ( )
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-12 03:52:32 +01:00
for _ , artifact := range tt . artifacts {
ctx . Artifacts . Add ( & artifact )
}
got := Pipe { } . Publish ( ctx )
var err string
if got != nil {
err = got . Error ( )
}
if tt . err != err {
t . Errorf ( "Unexpected error: %s (expected %s)" , err , tt . err )
}
} )
}
}
2023-03-03 09:50:15 -03:00
func TestDependencies ( t * testing . T ) {
require . Equal ( t , [ ] string { "choco" } , Pipe { } . Dependencies ( nil ) )
}
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-12 03:52:32 +01:00
type fakeCmd struct {
2023-09-16 14:08:11 -03:00
execFn func ( cmd string , args ... string ) ( [ ] byte , error )
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-12 03:52:32 +01:00
}
var _ cmder = fakeCmd { }
2023-09-16 14:08:11 -03:00
func ( f fakeCmd ) Exec ( _ * context . Context , cmd string , args ... string ) ( [ ] byte , error ) {
return f . execFn ( cmd , args ... )
}
func checkPushCmd ( tb testing . TB , cmd string , args ... string ) {
tb . Helper ( )
tb . Log ( "would have run:" , cmd , args )
require . Len ( tb , args , 6 )
require . Equal ( tb , cmd , "choco" )
require . FileExists ( tb , args [ 5 ] )
}
func checkPackCmd ( tb testing . TB , cmd string , args ... string ) {
tb . Helper ( )
tb . Log ( "would have run:" , cmd , args )
require . Len ( tb , args , 4 )
require . Equal ( tb , cmd , "choco" )
require . FileExists ( tb , args [ 1 ] )
require . DirExists ( tb , args [ 3 ] )
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-12 03:52:32 +01:00
}