github.com/ahmet2mir/goreleaser@v0.180.3-0.20210927151101-8e5ee5a9b8c5/pkg/config/config.go (about) 1 // Package config contains the model and loader of the goreleaser configuration 2 // file. 3 package config 4 5 import ( 6 "io" 7 "os" 8 "strings" 9 "time" 10 11 "github.com/apex/log" 12 "github.com/goreleaser/nfpm/v2/files" 13 yaml "gopkg.in/yaml.v2" 14 ) 15 16 // GitHubURLs holds the URLs to be used when using github enterprise. 17 type GitHubURLs struct { 18 API string `yaml:"api,omitempty"` 19 Upload string `yaml:"upload,omitempty"` 20 Download string `yaml:"download,omitempty"` 21 SkipTLSVerify bool `yaml:"skip_tls_verify,omitempty"` 22 } 23 24 // GitLabURLs holds the URLs to be used when using gitlab ce/enterprise. 25 type GitLabURLs struct { 26 API string `yaml:"api,omitempty"` 27 Download string `yaml:"download,omitempty"` 28 SkipTLSVerify bool `yaml:"skip_tls_verify,omitempty"` 29 } 30 31 // GiteaURLs holds the URLs to be used when using gitea. 32 type GiteaURLs struct { 33 API string `yaml:"api,omitempty"` 34 Download string `yaml:"download,omitempty"` 35 SkipTLSVerify bool `yaml:"skip_tls_verify,omitempty"` 36 } 37 38 // Repo represents any kind of repo (github, gitlab, etc). 39 // to upload releases into. 40 type Repo struct { 41 Owner string `yaml:",omitempty"` 42 Name string `yaml:",omitempty"` 43 } 44 45 // RepoRef represents any kind of repo which may differ 46 // from the one we are building from and may therefore 47 // also require separate authentication 48 // e.g. Homebrew Tap, Scoop bucket. 49 type RepoRef struct { 50 Owner string `yaml:",omitempty"` 51 Name string `yaml:",omitempty"` 52 Token string `yaml:",omitempty"` 53 } 54 55 // HomebrewDependency represents Homebrew dependency. 56 type HomebrewDependency struct { 57 Name string `yaml:",omitempty"` 58 Type string `yaml:",omitempty"` 59 } 60 61 // type alias to prevent stack overflowing in the custom unmarshaler. 62 type homebrewDependency HomebrewDependency 63 64 // UnmarshalYAML is a custom unmarshaler that accept brew deps in both the old and new format. 65 func (a *HomebrewDependency) UnmarshalYAML(unmarshal func(interface{}) error) error { 66 var str string 67 if err := unmarshal(&str); err == nil { 68 a.Name = str 69 return nil 70 } 71 72 var dep homebrewDependency 73 if err := unmarshal(&dep); err != nil { 74 return err 75 } 76 77 a.Name = dep.Name 78 a.Type = dep.Type 79 80 return nil 81 } 82 83 // String of the repo, e.g. owner/name. 84 func (r Repo) String() string { 85 if r.Owner == "" && r.Name == "" { 86 return "" 87 } 88 return r.Owner + "/" + r.Name 89 } 90 91 // Homebrew contains the brew section. 92 type Homebrew struct { 93 Name string `yaml:",omitempty"` 94 Tap RepoRef `yaml:",omitempty"` 95 CommitAuthor CommitAuthor `yaml:"commit_author,omitempty"` 96 CommitMessageTemplate string `yaml:"commit_msg_template,omitempty"` 97 Folder string `yaml:",omitempty"` 98 Caveats string `yaml:",omitempty"` 99 Plist string `yaml:",omitempty"` 100 Install string `yaml:",omitempty"` 101 PostInstall string `yaml:"post_install,omitempty"` 102 Dependencies []HomebrewDependency `yaml:",omitempty"` 103 Test string `yaml:",omitempty"` 104 Conflicts []string `yaml:",omitempty"` 105 Description string `yaml:",omitempty"` 106 Homepage string `yaml:",omitempty"` 107 License string `yaml:",omitempty"` 108 SkipUpload string `yaml:"skip_upload,omitempty"` 109 DownloadStrategy string `yaml:"download_strategy,omitempty"` 110 URLTemplate string `yaml:"url_template,omitempty"` 111 CustomRequire string `yaml:"custom_require,omitempty"` 112 CustomBlock string `yaml:"custom_block,omitempty"` 113 IDs []string `yaml:"ids,omitempty"` 114 Goarm string `yaml:"goarm,omitempty"` 115 } 116 117 // Scoop contains the scoop.sh section. 118 type Scoop struct { 119 Name string `yaml:",omitempty"` 120 Bucket RepoRef `yaml:",omitempty"` 121 Folder string `yaml:",omitempty"` 122 CommitAuthor CommitAuthor `yaml:"commit_author,omitempty"` 123 CommitMessageTemplate string `yaml:"commit_msg_template,omitempty"` 124 Homepage string `yaml:",omitempty"` 125 Description string `yaml:",omitempty"` 126 License string `yaml:",omitempty"` 127 URLTemplate string `yaml:"url_template,omitempty"` 128 Persist []string `yaml:"persist,omitempty"` 129 SkipUpload string `yaml:"skip_upload,omitempty"` 130 PreInstall []string `yaml:"pre_install,omitempty"` 131 PostInstall []string `yaml:"post_install,omitempty"` 132 } 133 134 // CommitAuthor is the author of a Git commit. 135 type CommitAuthor struct { 136 Name string `yaml:",omitempty"` 137 Email string `yaml:",omitempty"` 138 } 139 140 // Hooks define actions to run before and/or after something. 141 type Hooks struct { 142 Pre string `yaml:",omitempty"` 143 Post string `yaml:",omitempty"` 144 } 145 146 // IgnoredBuild represents a build ignored by the user. 147 type IgnoredBuild struct { 148 Goos, Goarch, Goarm, Gomips string 149 } 150 151 // StringArray is a wrapper for an array of strings. 152 type StringArray []string 153 154 // UnmarshalYAML is a custom unmarshaler that wraps strings in arrays. 155 func (a *StringArray) UnmarshalYAML(unmarshal func(interface{}) error) error { 156 var strings []string 157 if err := unmarshal(&strings); err != nil { 158 var str string 159 if err := unmarshal(&str); err != nil { 160 return err 161 } 162 *a = []string{str} 163 } else { 164 *a = strings 165 } 166 return nil 167 } 168 169 // FlagArray is a wrapper for an array of strings. 170 type FlagArray []string 171 172 // UnmarshalYAML is a custom unmarshaler that wraps strings in arrays. 173 func (a *FlagArray) UnmarshalYAML(unmarshal func(interface{}) error) error { 174 var flags []string 175 if err := unmarshal(&flags); err != nil { 176 var flagstr string 177 if err := unmarshal(&flagstr); err != nil { 178 return err 179 } 180 *a = strings.Fields(flagstr) 181 } else { 182 *a = flags 183 } 184 return nil 185 } 186 187 // Build contains the build configuration section. 188 type Build struct { 189 ID string `yaml:",omitempty"` 190 Goos []string `yaml:",omitempty"` 191 Goarch []string `yaml:",omitempty"` 192 Goarm []string `yaml:",omitempty"` 193 Gomips []string `yaml:",omitempty"` 194 Targets []string `yaml:",omitempty"` 195 Ignore []IgnoredBuild `yaml:",omitempty"` 196 Dir string `yaml:",omitempty"` 197 Main string `yaml:",omitempty"` 198 Ldflags StringArray `yaml:",omitempty"` 199 Tags FlagArray `yaml:",omitempty"` 200 Flags FlagArray `yaml:",omitempty"` 201 Binary string `yaml:",omitempty"` 202 Hooks HookConfig `yaml:",omitempty"` 203 Env []string `yaml:",omitempty"` 204 Builder string `yaml:",omitempty"` 205 Asmflags StringArray `yaml:",omitempty"` 206 Gcflags StringArray `yaml:",omitempty"` 207 ModTimestamp string `yaml:"mod_timestamp,omitempty"` 208 Skip bool `yaml:",omitempty"` 209 GoBinary string `yaml:",omitempty"` 210 NoUniqueDistDir bool `yaml:"no_unique_dist_dir,omitempty"` 211 UnproxiedMain string `yaml:"-"` // used by gomod.proxy 212 UnproxiedDir string `yaml:"-"` // used by gomod.proxy 213 } 214 215 type HookConfig struct { 216 Pre BuildHooks `yaml:",omitempty"` 217 Post BuildHooks `yaml:",omitempty"` 218 } 219 220 type BuildHooks []BuildHook 221 222 // UnmarshalYAML is a custom unmarshaler that allows simplified declaration of single command. 223 func (bhc *BuildHooks) UnmarshalYAML(unmarshal func(interface{}) error) error { 224 var singleCmd string 225 err := unmarshal(&singleCmd) 226 if err == nil { 227 *bhc = []BuildHook{{Cmd: singleCmd}} 228 return nil 229 } 230 231 type t BuildHooks 232 var hooks t 233 if err := unmarshal(&hooks); err != nil { 234 return err 235 } 236 *bhc = (BuildHooks)(hooks) 237 return nil 238 } 239 240 type BuildHook struct { 241 Dir string `yaml:",omitempty"` 242 Cmd string `yaml:",omitempty"` 243 Env []string `yaml:",omitempty"` 244 } 245 246 // UnmarshalYAML is a custom unmarshaler that allows simplified declarations of commands as strings. 247 func (bh *BuildHook) UnmarshalYAML(unmarshal func(interface{}) error) error { 248 var cmd string 249 if err := unmarshal(&cmd); err != nil { 250 type t BuildHook 251 var hook t 252 if err := unmarshal(&hook); err != nil { 253 return err 254 } 255 *bh = (BuildHook)(hook) 256 return nil 257 } 258 259 bh.Cmd = cmd 260 return nil 261 } 262 263 // FormatOverride is used to specify a custom format for a specific GOOS. 264 type FormatOverride struct { 265 Goos string `yaml:",omitempty"` 266 Format string `yaml:",omitempty"` 267 } 268 269 // File is a file inside an archive. 270 type File struct { 271 Source string `yaml:"src,omitempty"` 272 Destination string `yaml:"dst,omitempty"` 273 StripParent bool `yaml:"strip_parent,omitempty"` 274 Info FileInfo `yaml:"info,omitempty"` 275 } 276 277 // FileInfo is the file info of a file. 278 type FileInfo struct { 279 Owner string `yaml:"owner,omitempty"` 280 Group string `yaml:"group"` 281 Mode os.FileMode `yaml:"mode,omitempty"` 282 MTime time.Time `yaml:"mtime,omitempty"` 283 } 284 285 // type alias to prevent stack overflow 286 type fileAlias File 287 288 // UnmarshalYAML is a custom unmarshaler that wraps strings in arrays. 289 func (f *File) UnmarshalYAML(unmarshal func(interface{}) error) error { 290 var str string 291 if err := unmarshal(&str); err == nil { 292 *f = File{Source: str} 293 return nil 294 } 295 296 var file fileAlias 297 if err := unmarshal(&file); err != nil { 298 return err 299 } 300 *f = File(file) 301 return nil 302 } 303 304 // Archive config used for the archive. 305 type Archive struct { 306 ID string `yaml:",omitempty"` 307 Builds []string `yaml:",omitempty"` 308 NameTemplate string `yaml:"name_template,omitempty"` 309 Replacements map[string]string `yaml:",omitempty"` 310 Format string `yaml:",omitempty"` 311 FormatOverrides []FormatOverride `yaml:"format_overrides,omitempty"` 312 WrapInDirectory string `yaml:"wrap_in_directory,omitempty"` 313 Files []File `yaml:",omitempty"` 314 AllowDifferentBinaryCount bool `yaml:"allow_different_binary_count"` 315 } 316 317 // Release config used for the GitHub/GitLab release. 318 type Release struct { 319 GitHub Repo `yaml:",omitempty"` 320 GitLab Repo `yaml:",omitempty"` 321 Gitea Repo `yaml:",omitempty"` 322 Draft bool `yaml:",omitempty"` 323 Disable bool `yaml:",omitempty"` 324 Prerelease string `yaml:",omitempty"` 325 NameTemplate string `yaml:"name_template,omitempty"` 326 IDs []string `yaml:"ids,omitempty"` 327 ExtraFiles []ExtraFile `yaml:"extra_files,omitempty"` 328 DiscussionCategoryName string `yaml:"discussion_category_name,omitempty"` 329 Header string `yaml:"header,omitempty"` 330 Footer string `yaml:"footer,omitempty"` 331 } 332 333 // Milestone config used for VCS milestone. 334 type Milestone struct { 335 Repo Repo `yaml:",omitempty"` 336 Close bool `yaml:",omitempty"` 337 FailOnError bool `yaml:"fail_on_error,omitempty"` 338 NameTemplate string `yaml:"name_template,omitempty"` 339 } 340 341 // ExtraFile on a release. 342 type ExtraFile struct { 343 Glob string `yaml:"glob,omitempty"` 344 } 345 346 // NFPM config. 347 type NFPM struct { 348 NFPMOverridables `yaml:",inline"` 349 Overrides map[string]NFPMOverridables `yaml:"overrides,omitempty"` 350 351 ID string `yaml:",omitempty"` 352 Builds []string `yaml:",omitempty"` 353 Formats []string `yaml:",omitempty"` 354 Section string `yaml:",omitempty"` 355 Priority string `yaml:",omitempty"` 356 Vendor string `yaml:",omitempty"` 357 Homepage string `yaml:",omitempty"` 358 Maintainer string `yaml:",omitempty"` 359 Description string `yaml:",omitempty"` 360 License string `yaml:",omitempty"` 361 Bindir string `yaml:",omitempty"` 362 Meta bool `yaml:",omitempty"` // make package without binaries - only deps 363 } 364 365 // NFPMScripts is used to specify maintainer scripts. 366 type NFPMScripts struct { 367 PreInstall string `yaml:"preinstall,omitempty"` 368 PostInstall string `yaml:"postinstall,omitempty"` 369 PreRemove string `yaml:"preremove,omitempty"` 370 PostRemove string `yaml:"postremove,omitempty"` 371 } 372 373 type NFPMRPMSignature struct { 374 // PGP secret key, can be ASCII-armored 375 KeyFile string `yaml:"key_file,omitempty"` 376 KeyPassphrase string `yaml:"-"` // populated from environment variable 377 } 378 379 // NFPMRPMScripts represents scripts only available on RPM packages. 380 type NFPMRPMScripts struct { 381 PreTrans string `yaml:"pretrans,omitempty"` 382 PostTrans string `yaml:"posttrans,omitempty"` 383 } 384 385 // NFPMRPM is custom configs that are only available on RPM packages. 386 type NFPMRPM struct { 387 Summary string `yaml:"summary,omitempty"` 388 Group string `yaml:"group,omitempty"` 389 Compression string `yaml:"compression,omitempty"` 390 Signature NFPMRPMSignature `yaml:"signature,omitempty"` 391 Scripts NFPMRPMScripts `yaml:"scripts,omitempty"` 392 } 393 394 // NFPMDebScripts is scripts only available on deb packages. 395 type NFPMDebScripts struct { 396 Rules string `yaml:"rules,omitempty"` 397 Templates string `yaml:"templates,omitempty"` 398 } 399 400 // NFPMDebTriggers contains triggers only available for deb packages. 401 // https://wiki.debian.org/DpkgTriggers 402 // https://man7.org/linux/man-pages/man5/deb-triggers.5.html 403 type NFPMDebTriggers struct { 404 Interest []string `yaml:"interest,omitempty"` 405 InterestAwait []string `yaml:"interest_await,omitempty"` 406 InterestNoAwait []string `yaml:"interest_noawait,omitempty"` 407 Activate []string `yaml:"activate,omitempty"` 408 ActivateAwait []string `yaml:"activate_await,omitempty"` 409 ActivateNoAwait []string `yaml:"activate_noawait,omitempty"` 410 } 411 412 // NFPMDebSignature contains config for signing deb packages created by nfpm. 413 type NFPMDebSignature struct { 414 // PGP secret key, can be ASCII-armored 415 KeyFile string `yaml:"key_file,omitempty"` 416 KeyPassphrase string `yaml:"-"` // populated from environment variable 417 // origin, maint or archive (defaults to origin) 418 Type string `yaml:"type,omitempty"` 419 } 420 421 // NFPMDeb is custom configs that are only available on deb packages. 422 type NFPMDeb struct { 423 Scripts NFPMDebScripts `yaml:"scripts,omitempty"` 424 Triggers NFPMDebTriggers `yaml:"triggers,omitempty"` 425 Breaks []string `yaml:"breaks,omitempty"` 426 Signature NFPMDebSignature `yaml:"signature,omitempty"` 427 } 428 429 type NFPMAPKScripts struct { 430 PreUpgrade string `yaml:"preupgrade,omitempty"` 431 PostUpgrade string `yaml:"postupgrade,omitempty"` 432 } 433 434 // NFPMAPKSignature contains config for signing apk packages created by nfpm. 435 type NFPMAPKSignature struct { 436 // RSA private key in PEM format 437 KeyFile string `yaml:"key_file,omitempty"` 438 KeyPassphrase string `yaml:"-"` // populated from environment variable 439 // defaults to <maintainer email>.rsa.pub 440 KeyName string `yaml:"key_name,omitempty"` 441 } 442 443 // NFPMAPK is custom config only available on apk packages. 444 type NFPMAPK struct { 445 Scripts NFPMAPKScripts `yaml:"scripts,omitempty"` 446 Signature NFPMAPKSignature `yaml:"signature,omitempty"` 447 } 448 449 // NFPMOverridables is used to specify per package format settings. 450 type NFPMOverridables struct { 451 FileNameTemplate string `yaml:"file_name_template,omitempty"` 452 PackageName string `yaml:"package_name,omitempty"` 453 Epoch string `yaml:"epoch,omitempty"` 454 Release string `yaml:"release,omitempty"` 455 Prerelease string `yaml:"prerelease,omitempty"` 456 VersionMetadata string `yaml:"version_metadata,omitempty"` 457 Replacements map[string]string `yaml:",omitempty"` 458 Dependencies []string `yaml:",omitempty"` 459 Recommends []string `yaml:",omitempty"` 460 Suggests []string `yaml:",omitempty"` 461 Conflicts []string `yaml:",omitempty"` 462 Replaces []string `yaml:",omitempty"` 463 EmptyFolders []string `yaml:"empty_folders,omitempty"` 464 Contents files.Contents `yaml:"contents,omitempty"` 465 Scripts NFPMScripts `yaml:"scripts,omitempty"` 466 RPM NFPMRPM `yaml:"rpm,omitempty"` 467 Deb NFPMDeb `yaml:"deb,omitempty"` 468 APK NFPMAPK `yaml:"apk,omitempty"` 469 } 470 471 // Sign config. 472 type Sign struct { 473 ID string `yaml:"id,omitempty"` 474 Cmd string `yaml:"cmd,omitempty"` 475 Args []string `yaml:"args,omitempty"` 476 Signature string `yaml:"signature,omitempty"` 477 Artifacts string `yaml:"artifacts,omitempty"` 478 IDs []string `yaml:"ids,omitempty"` 479 Stdin *string `yaml:"stdin,omitempty"` 480 StdinFile string `yaml:"stdin_file,omitempty"` 481 } 482 483 // SnapcraftAppMetadata for the binaries that will be in the snap package. 484 type SnapcraftAppMetadata struct { 485 Plugs []string 486 Daemon string 487 Args string 488 Completer string `yaml:",omitempty"` 489 Command string `yaml:"command"` 490 RestartCondition string `yaml:"restart_condition,omitempty"` 491 } 492 493 type SnapcraftLayoutMetadata struct { 494 Symlink string `yaml:",omitempty"` 495 Bind string `yaml:",omitempty"` 496 BindFile string `yaml:"bind_file,omitempty"` 497 Type string `yaml:",omitempty"` 498 } 499 500 // Snapcraft config. 501 type Snapcraft struct { 502 NameTemplate string `yaml:"name_template,omitempty"` 503 Replacements map[string]string `yaml:",omitempty"` 504 Publish bool `yaml:",omitempty"` 505 506 ID string `yaml:",omitempty"` 507 Builds []string `yaml:",omitempty"` 508 Name string `yaml:",omitempty"` 509 Summary string `yaml:",omitempty"` 510 Description string `yaml:",omitempty"` 511 Base string `yaml:",omitempty"` 512 License string `yaml:",omitempty"` 513 Grade string `yaml:",omitempty"` 514 ChannelTemplates []string `yaml:"channel_templates,omitempty"` 515 Confinement string `yaml:",omitempty"` 516 Layout map[string]SnapcraftLayoutMetadata `yaml:",omitempty"` 517 Apps map[string]SnapcraftAppMetadata `yaml:",omitempty"` 518 Plugs map[string]interface{} `yaml:",omitempty"` 519 520 Files []SnapcraftExtraFiles `yaml:"extra_files,omitempty"` 521 } 522 523 // SnapcraftExtraFiles config. 524 type SnapcraftExtraFiles struct { 525 Source string `yaml:"source"` 526 Destination string `yaml:"destination,omitempty"` 527 Mode uint32 `yaml:"mode,omitempty"` 528 } 529 530 // Snapshot config. 531 type Snapshot struct { 532 NameTemplate string `yaml:"name_template,omitempty"` 533 } 534 535 // Checksum config. 536 type Checksum struct { 537 NameTemplate string `yaml:"name_template,omitempty"` 538 Algorithm string `yaml:"algorithm,omitempty"` 539 IDs []string `yaml:"ids,omitempty"` 540 Disable bool `yaml:"disable,omitempty"` 541 ExtraFiles []ExtraFile `yaml:"extra_files,omitempty"` 542 } 543 544 // Docker image config. 545 type Docker struct { 546 ID string `yaml:"id,omitempty"` 547 IDs []string `yaml:"ids,omitempty"` 548 Goos string `yaml:",omitempty"` 549 Goarch string `yaml:",omitempty"` 550 Goarm string `yaml:",omitempty"` 551 Dockerfile string `yaml:",omitempty"` 552 ImageTemplates []string `yaml:"image_templates,omitempty"` 553 SkipPush string `yaml:"skip_push,omitempty"` 554 Files []string `yaml:"extra_files,omitempty"` 555 BuildFlagTemplates []string `yaml:"build_flag_templates,omitempty"` 556 PushFlags []string `yaml:"push_flags,omitempty"` 557 Buildx bool `yaml:"use_buildx,omitempty"` // deprecated: use Use instead 558 Use string `yaml:"use,omitempty"` 559 } 560 561 // DockerManifest config. 562 type DockerManifest struct { 563 ID string `yaml:"id,omitempty"` 564 NameTemplate string `yaml:"name_template,omitempty"` 565 SkipPush string `yaml:"skip_push,omitempty"` 566 ImageTemplates []string `yaml:"image_templates,omitempty"` 567 CreateFlags []string `yaml:"create_flags,omitempty"` 568 PushFlags []string `yaml:"push_flags,omitempty"` 569 Use string `yaml:"use,omitempty"` 570 } 571 572 // Filters config. 573 type Filters struct { 574 Exclude []string `yaml:",omitempty"` 575 } 576 577 // Changelog Config. 578 type Changelog struct { 579 Filters Filters `yaml:",omitempty"` 580 Sort string `yaml:",omitempty"` 581 Skip bool `yaml:",omitempty"` // TODO(caarlos0): rename to Disable to match other pipes 582 } 583 584 // EnvFiles holds paths to files that contains environment variables 585 // values like the github token for example. 586 type EnvFiles struct { 587 GitHubToken string `yaml:"github_token,omitempty"` 588 GitLabToken string `yaml:"gitlab_token,omitempty"` 589 GiteaToken string `yaml:"gitea_token,omitempty"` 590 } 591 592 // Before config. 593 type Before struct { 594 Hooks []string `yaml:",omitempty"` 595 } 596 597 // Blob contains config for GO CDK blob. 598 type Blob struct { 599 Bucket string `yaml:",omitempty"` 600 Provider string `yaml:",omitempty"` 601 Region string `yaml:",omitempty"` 602 DisableSSL bool `yaml:"disableSSL,omitempty"` 603 Folder string `yaml:",omitempty"` 604 KMSKey string `yaml:",omitempty"` 605 IDs []string `yaml:"ids,omitempty"` 606 Endpoint string `yaml:",omitempty"` // used for minio for example 607 ExtraFiles []ExtraFile `yaml:"extra_files,omitempty"` 608 } 609 610 // Upload configuration. 611 type Upload struct { 612 Name string `yaml:",omitempty"` 613 IDs []string `yaml:"ids,omitempty"` 614 Target string `yaml:",omitempty"` 615 Username string `yaml:",omitempty"` 616 Mode string `yaml:",omitempty"` 617 Method string `yaml:",omitempty"` 618 ChecksumHeader string `yaml:"checksum_header,omitempty"` 619 TrustedCerts string `yaml:"trusted_certificates,omitempty"` 620 Checksum bool `yaml:",omitempty"` 621 Signature bool `yaml:",omitempty"` 622 CustomArtifactName bool `yaml:"custom_artifact_name,omitempty"` 623 CustomHeaders map[string]string `yaml:"custom_headers,omitempty"` 624 } 625 626 // Publisher configuration. 627 type Publisher struct { 628 Name string `yaml:",omitempty"` 629 IDs []string `yaml:"ids,omitempty"` 630 Checksum bool `yaml:",omitempty"` 631 Signature bool `yaml:",omitempty"` 632 Dir string `yaml:",omitempty"` 633 Cmd string `yaml:",omitempty"` 634 Env []string `yaml:",omitempty"` 635 } 636 637 // Source configuration. 638 type Source struct { 639 NameTemplate string `yaml:"name_template,omitempty"` 640 Format string `yaml:",omitempty"` 641 Enabled bool `yaml:",omitempty"` 642 } 643 644 // Project includes all project configuration. 645 type Project struct { 646 ProjectName string `yaml:"project_name,omitempty"` 647 Env []string `yaml:",omitempty"` 648 Release Release `yaml:",omitempty"` 649 Milestones []Milestone `yaml:",omitempty"` 650 Brews []Homebrew `yaml:",omitempty"` 651 Scoop Scoop `yaml:",omitempty"` 652 Builds []Build `yaml:",omitempty"` 653 Archives []Archive `yaml:",omitempty"` 654 NFPMs []NFPM `yaml:"nfpms,omitempty"` 655 Snapcrafts []Snapcraft `yaml:",omitempty"` 656 Snapshot Snapshot `yaml:",omitempty"` 657 Checksum Checksum `yaml:",omitempty"` 658 Dockers []Docker `yaml:",omitempty"` 659 DockerManifests []DockerManifest `yaml:"docker_manifests,omitempty"` 660 Artifactories []Upload `yaml:",omitempty"` 661 Uploads []Upload `yaml:",omitempty"` 662 Blobs []Blob `yaml:"blobs,omitempty"` 663 Publishers []Publisher `yaml:"publishers,omitempty"` 664 Changelog Changelog `yaml:",omitempty"` 665 Dist string `yaml:",omitempty"` 666 Signs []Sign `yaml:",omitempty"` 667 DockerSigns []Sign `yaml:"docker_signs,omitempty"` 668 EnvFiles EnvFiles `yaml:"env_files,omitempty"` 669 Before Before `yaml:",omitempty"` 670 Source Source `yaml:",omitempty"` 671 GoMod GoMod `yaml:"gomod,omitempty"` 672 Announce Announce `yaml:"announce,omitempty"` 673 674 // this is a hack ¯\_(ツ)_/¯ 675 SingleBuild Build `yaml:"build,omitempty"` 676 677 // should be set if using github enterprise 678 GitHubURLs GitHubURLs `yaml:"github_urls,omitempty"` 679 680 // should be set if using a private gitlab 681 GitLabURLs GitLabURLs `yaml:"gitlab_urls,omitempty"` 682 683 // should be set if using Gitea 684 GiteaURLs GiteaURLs `yaml:"gitea_urls,omitempty"` 685 } 686 687 type GoMod struct { 688 Proxy bool `yaml:",omitempty"` 689 Env []string `yaml:",omitempty"` 690 GoBinary string `yaml:",omitempty"` 691 } 692 693 type Announce struct { 694 Twitter Twitter `yaml:"twitter,omitempty"` 695 Reddit Reddit `yaml:"reddit,omitempty"` 696 Slack Slack `yaml:"slack,omitempty"` 697 Discord Discord `yaml:"discord,omitempty"` 698 Teams Teams `yaml:"teams,omitempty"` 699 SMTP SMTP `yaml:"smtp,omitempty"` 700 } 701 702 type Twitter struct { 703 Enabled bool `yaml:"enabled,omitempty"` 704 MessageTemplate string `yaml:"message_template,omitempty"` 705 } 706 707 type Reddit struct { 708 Enabled bool `yaml:"enabled,omitempty"` 709 ApplicationID string `yaml:"application_id,omitempty"` 710 Username string `yaml:"username,omitempty"` 711 TitleTemplate string `yaml:"title_template,omitempty"` 712 URLTemplate string `yaml:"url_template,omitempty"` 713 Sub string `yaml:"sub,omitempty"` 714 } 715 716 type Slack struct { 717 Enabled bool `yaml:"enabled,omitempty"` 718 MessageTemplate string `yaml:"message_template,omitempty"` 719 Channel string `yaml:"channel,omitempty"` 720 Username string `yaml:"username,omitempty"` 721 IconEmoji string `yaml:"icon_emoji,omitempty"` 722 IconURL string `yaml:"icon_url,omitempty"` 723 } 724 725 type Discord struct { 726 Enabled bool `yaml:"enabled,omitempty"` 727 MessageTemplate string `yaml:"message_template,omitempty"` 728 Author string `yaml:"author,omitempty"` 729 Color string `yaml:"color,omitempty"` 730 IconURL string `yaml:"icon_url,omitempty"` 731 } 732 733 type Teams struct { 734 Enabled bool `yaml:"enabled,omitempty"` 735 TitleTemplate string `yaml:"title_template,omitempty"` 736 MessageTemplate string `yaml:"message_template,omitempty"` 737 Color string `yaml:"color,omitempty"` 738 IconURL string `yaml:"icon_url,omitempty"` 739 } 740 741 type SMTP struct { 742 Enabled bool `yaml:"enabled,omitempty"` 743 Host string `yaml:"host,omitempty"` 744 Port int `yaml:"port,omitempty"` 745 Username string `yaml:"username,omitempty"` 746 From string `yaml:"from,omitempty"` 747 To []string `yaml:"to,omitempty"` 748 SubjectTemplate string `yaml:"subject_template,omitempty"` 749 BodyTemplate string `yaml:"body_template,omitempty"` 750 InsecureSkipVerify bool `yaml:"insecure_skip_verify,omitempty"` 751 } 752 753 // Load config file. 754 func Load(file string) (config Project, err error) { 755 f, err := os.Open(file) // #nosec 756 if err != nil { 757 return 758 } 759 defer f.Close() 760 log.WithField("file", file).Info("loading config file") 761 return LoadReader(f) 762 } 763 764 // LoadReader config via io.Reader. 765 func LoadReader(fd io.Reader) (config Project, err error) { 766 data, err := io.ReadAll(fd) 767 if err != nil { 768 return config, err 769 } 770 err = yaml.UnmarshalStrict(data, &config) 771 log.WithField("config", config).Debug("loaded config file") 772 return config, err 773 }