diff --git a/internal/pipe/scoop/scoop.go b/internal/pipe/scoop/scoop.go index 1e7c77b06..2d7ba83d3 100644 --- a/internal/pipe/scoop/scoop.go +++ b/internal/pipe/scoop/scoop.go @@ -142,12 +142,14 @@ func doRun(ctx *context.Context, cl client.Client) error { // Manifest represents a scoop.sh App Manifest. // more info: https://github.com/lukesampson/scoop/wiki/App-Manifests type Manifest struct { - Version string `json:"version"` // The version of the app that this manifest installs. - Architecture map[string]Resource `json:"architecture"` // `architecture`: If the app has 32- and 64-bit versions, architecture can be used to wrap the differences. - Homepage string `json:"homepage,omitempty"` // `homepage`: The home page for the program. - License string `json:"license,omitempty"` // `license`: The software license for the program. For well-known licenses, this will be a string like "MIT" or "GPL2". For custom licenses, this should be the URL of the license. - Description string `json:"description,omitempty"` // Description of the app - Persist []string `json:"persist,omitempty"` // Persist data between updates + Version string `json:"version"` // The version of the app that this manifest installs. + Architecture map[string]Resource `json:"architecture"` // `architecture`: If the app has 32- and 64-bit versions, architecture can be used to wrap the differences. + Homepage string `json:"homepage,omitempty"` // `homepage`: The home page for the program. + License string `json:"license,omitempty"` // `license`: The software license for the program. For well-known licenses, this will be a string like "MIT" or "GPL2". For custom licenses, this should be the URL of the license. + Description string `json:"description,omitempty"` // Description of the app + Persist []string `json:"persist,omitempty"` // Persist data between updates + PreInstall []string `json:"pre_install,omitempty"` // An array of strings, of the commands to be executed before an application is installed. + PostInstall []string `json:"post_install,omitempty"` // An array of strings, of the commands to be executed after an application is installed. } // Resource represents a combination of a url and a binary name for an architecture. @@ -175,6 +177,8 @@ func dataFor(ctx *context.Context, cl client.Client, artifacts []*artifact.Artif License: ctx.Config.Scoop.License, Description: ctx.Config.Scoop.Description, Persist: ctx.Config.Scoop.Persist, + PreInstall: ctx.Config.Scoop.PreInstall, + PostInstall: ctx.Config.Scoop.PostInstall, } if ctx.Config.Scoop.URLTemplate == "" { diff --git a/internal/pipe/scoop/scoop_test.go b/internal/pipe/scoop/scoop_test.go index c96969015..0434f4f55 100644 --- a/internal/pipe/scoop/scoop_test.go +++ b/internal/pipe/scoop/scoop_test.go @@ -790,6 +790,45 @@ func Test_buildManifest(t *testing.T) { }, }, }, + { + "testdata/test_buildmanifest_pre_post_install.json.golden", + &context.Context{ + Context: ctx.Background(), + TokenType: context.TokenTypeGitHub, + Git: context.GitInfo{ + CurrentTag: "v1.0.1", + }, + Version: "1.0.1", + Artifacts: artifact.New(), + Config: config.Project{ + GitHubURLs: config.GitHubURLs{ + Download: "https://github.com", + }, + Dist: ".", + ProjectName: "run-pipe", + Archives: []config.Archive{ + {Format: "tar.gz"}, + }, + Release: config.Release{ + GitHub: config.Repo{ + Owner: "test", + Name: "test", + }, + }, + Scoop: config.Scoop{ + Bucket: config.RepoRef{ + Owner: "test", + Name: "test", + }, + Description: "A run pipe test formula", + Homepage: "https://github.com/goreleaser", + Persist: []string{"data", "config", "test.ini"}, + PreInstall: []string{"Write-Host 'Running preinstall command'"}, + PostInstall: []string{"Write-Host 'Running postinstall command'"}, + }, + }, + }, + }, { "testdata/test_buildmanifest_url_template.json.golden", &context.Context{ diff --git a/internal/pipe/scoop/testdata/test_buildmanifest_pre_post_install.json.golden b/internal/pipe/scoop/testdata/test_buildmanifest_pre_post_install.json.golden new file mode 100644 index 000000000..da67fd8d6 --- /dev/null +++ b/internal/pipe/scoop/testdata/test_buildmanifest_pre_post_install.json.golden @@ -0,0 +1,34 @@ +{ + "version": "1.0.1", + "architecture": { + "32bit": { + "url": "https://github.com/test/test/releases/download/v1.0.1/foo_1.0.1_windows_386.tar.gz", + "bin": [ + "foo.exe", + "bar.exe" + ], + "hash": "5e2bf57d3f40c4b6df69daf1936cb766f832374b4fc0259a7cbff06e2f70f269" + }, + "64bit": { + "url": "https://github.com/test/test/releases/download/v1.0.1/foo_1.0.1_windows_amd64.tar.gz", + "bin": [ + "foo.exe", + "bar.exe" + ], + "hash": "5e2bf57d3f40c4b6df69daf1936cb766f832374b4fc0259a7cbff06e2f70f269" + } + }, + "homepage": "https://github.com/goreleaser", + "description": "A run pipe test formula", + "persist": [ + "data", + "config", + "test.ini" + ], + "pre_install": [ + "Write-Host 'Running preinstall command'" + ], + "post_install": [ + "Write-Host 'Running postinstall command'" + ] +} \ No newline at end of file diff --git a/pkg/config/config.go b/pkg/config/config.go index 851721ccf..9d331057e 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -128,6 +128,8 @@ type Scoop struct { URLTemplate string `yaml:"url_template,omitempty"` Persist []string `yaml:"persist,omitempty"` SkipUpload string `yaml:"skip_upload,omitempty"` + PreInstall []string `yaml:"pre_install,omitempty"` + PostInstall []string `yaml:"post_install,omitempty"` } // CommitAuthor is the author of a Git commit. diff --git a/www/docs/customization/scoop.md b/www/docs/customization/scoop.md index 6fb7c1eb1..a590ede61 100644 --- a/www/docs/customization/scoop.md +++ b/www/docs/customization/scoop.md @@ -49,6 +49,14 @@ scoop: persist: - "data" - "config.toml" + + # An array of commands to be executed before an application is installed. + # Default is empty. + pre_install: ["Write-Host 'Running preinstall command'"] + + # An array of commands to be executed after an application is installed. + # Default is empty. + post_install: ["Write-Host 'Running postinstall command'"] ``` By defining the `scoop` section, GoReleaser will take care of publishing the