the release's defaults run before the project's does, so, usually the
github/gitlab/gitea names are set.
however, in some cases, the release's defaults might be skipped, in
which case they'll be empty.
this breaks things like `goreleaser changelog`, especially on non-go
repositories.
this pr tries to extract the project name from the git remote url in the
project's defaulter.
it might be possible now to move it to run before the release defaulter,
even.
---------
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
We can use `(*regexp.Regexp).MatchString` instead of
`(*regexp.Regexp).Match([]byte(...))` to avoid unnecessary `[]byte`
conversions and reduce allocations. A one-line change for free
performance gain.
Benchmark:
```go
func BenchmarkMatch(b *testing.B) {
for i := 0; i < b.N; i++ {
if match := envOnlyRe.Match([]byte("{{ .Env.FOO }}")); !match {
b.Fail()
}
}
}
func BenchmarkMatchString(b *testing.B) {
for i := 0; i < b.N; i++ {
if match := envOnlyRe.MatchString("{{ .Env.FOO }}"); !match {
b.Fail()
}
}
}
```
Result:
```
goos: linux
goarch: amd64
pkg: github.com/goreleaser/goreleaser/internal/tmpl cpu: AMD Ryzen 7 PRO 4750U with Radeon Graphics
BenchmarkMatch-16 4320873 381.2 ns/op 16 B/op 1 allocs/op
BenchmarkMatchString-16 5973543 203.9 ns/op 0 B/op 0 allocs/op
PASS
ok github.com/goreleaser/goreleaser/internal/tmpl 3.366s
```
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
also regex is not possible there currenctly, didnt realized it at the
time
refs #4255
---------
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Add a new function `map` to template functions.
`map` creates a map from a list of pairs of key values, then you can
convert a key to a value using `.Get`. This simplifies writing
key-mapping templates. For example, the defaule `archives.name_template`
```yaml
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
```
becomes
```yaml
name_template: >-
{{ $arch := map "amd64" "x86_64" "386" "i386" -}}
{{ .ProjectName }}_
{{- title .OS }}_
{{- $arch.Get .Arch .Arch }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
```
---------
Co-authored-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
this will log everything that's being skipped in the beginning of the
release process.
also added some tests to `skips`
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
the paths of the artifacts always use forward slashes, and the logic to
handle the relative path stuff inside the sbom pipe did not account for
that.
running the paths through `filepath.Clean` beforehand fixes it.
also improved yamlschema a little bit :)
closes#4289
Laying the ground work to allow skipping more pipes without adding new
flags et al.
---------
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
tested this on a fake repo, and it seems to fix the problem...
seems like choco does not like when the path has `/` in it, so passing
it through `filepath.Clean` fixes it.
also improved tests a bit, and made a small docs fix.
closes https://github.com/goreleaser/goreleaser/issues/4292
<!--
Hi, thanks for contributing!
Please make sure you read our CONTRIBUTING guide.
Also, add tests and the respective documentation changes as well.
-->
<!-- If applied, this commit will... -->
The gomod pipe will skip if the Go version does not support modules.
<!-- Why is this change being made? -->
I tried to use goreleaser to build a project with Go v1.8.7 and it
failed on `loading go mod information` step. The Go version used doesn't
support `go list -m`.
The build failed with the following error:
```
• loading go mod information
⨯ release failed after 0s error=failed to get module path: exit status 2: flag provided but not defined: -m
usage: list [-e] [-f format] [-json] [build flags] [packages]
List lists the packages named by the import paths, one per line.
...
```
<!-- # Provide links to any relevant tickets, URLs or other resources
-->
...
the publish pipe, which runs all publishers, already skips all
publishers if skip publish is set, so this check is not needed here.
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
the publish pipe, which runs all publishers, already skips all
publishers if skip publish is set, so this check is not needed here.
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
the publish pipe, which runs all publishers, already skips all
publishers if skip publish is set, so this check is not needed here.
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Currently, GoReleaser will assume you're running against github, gitea
or gitlab.
You could set `release.disable: true`, but it would still set and try to
use some defaults that could break things up.
Now, if you disable the release, goreleaser will not set these defaults.
It'll also hard error in some cases in which it would happily produce
invalid resources before, namely, if `release.disable` is set, and, for
example, `brews.url_template` is empty (in which case it would try to
use the one from the release, usually github).
closes#4208
if the base branch is empty, it'll try to fetch the default branch,
which would fail if base repo name/owner are also empty.
the default behavior when base owner/name are missing is to using
head's, so I changed it do that before trying to get the default branch,
which should fix the issue.
<!--
Hi, thanks for contributing!
Please make sure you read our CONTRIBUTING guide.
Also, add tests and the respective documentation changes as well.
-->
<!-- If applied, this commit will... -->
...
<!-- Why is this change being made? -->
...
<!-- # Provide links to any relevant tickets, URLs or other resources
-->
...
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
allows to disable a specific custom publisher based on a template, akin
to other pipes.
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
<!--
Hi, thanks for contributing!
Please make sure you read our CONTRIBUTING guide.
Also, add tests and the respective documentation changes as well.
-->
`docker` packaging does not honor the path structure defined in
builds/binary
it copies all binaries to temp docker build folder
this PR fixes the behavior and make it same as `archive`
for example
```
builds:
- id: xxx
binary: plugins/xxx
```
before:
```
/tmp/goreleaserdocker2210262014/xxx
```
after:
```
/tmp/goreleaserdocker2210262014/plugins/xxx
```
<!-- If applied, this commit will... -->
<!-- Why is this change being made? -->
<!-- # Provide links to any relevant tickets, URLs or other resources
-->
- improves deprecation warning styles a bit so they caught the readers
eye faster and are easier to read
- warns if the user uses `builds.target` in conjunction with other
options which are ignored in that case
- improved env output
- improved no configuration found warning
some of the changes:
<img width="1263" alt="CleanShot 2023-07-24 at 21 38 41@2x"
src="https://github.com/goreleaser/goreleaser/assets/245435/40465853-7177-44d6-b07b-61b67590669a">
---------
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
If an archive filename contains `/` characters, they can sneak into
Winget's `RelativeFilePath`.
In this PR, I make sure that `RelativeFilePath` only uses `\` directory
separators.
This commit adds a `make_latest` boolean to the release configuration,
to allow signaling to GitHub if the release should be marked as latest.
Albeit being a boolean, the internal Go type is a string to allow
to distinguish an empty string (default behavior: `true`) from an
explicit `false`.
For more information around the GitHub API field, see
https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#create-a-release
I did not include the `legacy` option, to not adopt something which
appears to be scheduled for removal in the future.
In addition, I opted for `make_latest` over `latest` because the
option is only available for GitHub. Which keeps the latter key
reserved for e.g. future use of a config option which is used across
Git providers.
Fixes#4159
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This commit adds a `make_latest` boolean to the release configuration,
to allow signaling to GitHub if the release should be marked as latest.
Albeit being a boolean, the internal Go type is a string to allow
to distinguish an empty string (default behavior: `true`) from an
explicit `false`.
For more information around the GitHub API field, see
https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#create-a-release
I did not include the `legacy` option, to not adopt something which
appears to be scheduled for removal in the future.
In addition, I opted for `make_latest` over `latest` because the
option is only available for GitHub. Which keeps the latter key
reserved for e.g. future use of a config option which is used across
Git providers.
Fixes#4159
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
<!--
Hi, thanks for contributing!
Please make sure you read our CONTRIBUTING guide.
Also, add tests and the respective documentation changes as well.
-->
<!-- If applied, this commit will... -->
Delete the temporary directory used for building Docker images.
<!-- Why is this change being made? -->
Leaving the temporary directory leads to wasted disk space.
<!-- # Provide links to any relevant tickets, URLs or other resources
-->
This adds missing fields:
- LicenseURL
- CopyrightURL
- Tags
As well as make several more fields templateable.
cc/ @twpayne
Co-authored-by: Tom Payne <tom.payne@flarm.com>
- nix.description, nix.path, and nix.homepage should allow templates
- nix.path was defaulting to wrong value, fixed
---------
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
The check to skip Scoop releases when SCM ones are disabled seems to be
the only place where this is happening and in conflict to Brew releases.
These two need not be linked as users can configure the `url_template`
to point elsewhere.
---
Consider the following use case:
```
* goreleaser/my-app.yml
- builds: spec for building a Go binary for my-app
- dockers: spec for packaging my-app in a container and pushing to Artifactory & GCP
- archives: spec for zipping up my-app binary
- artifactories: spec for pushing archives of my-app to a private jfrog artifactory
- brews: spec for publishing my-app through brew on macOS with URLs from artifactory
- scoop: spec for publishing my-app through scoop on Windows with URLs from artifactory
- release: disabled SCM (e.g. GitHub) release
```
Running `goreleaser release -f goreleaser/my-app.yml` with the above
setup results in the correct artifacts (archives & containers) being
published to Artifactory, GCP, Brew, but no Scoop.
Given that Scoop's `skip_upload` cannot be templated in 1.18 and I do
not wish to have SCM releases & tags on every release, one can be rather
stuck.
We have been using `t.Setenv` is most of our tests. This PR replaces the
remaining `os.Setenv` with `t.Setenv`.
Reference: https://pkg.go.dev/testing#T.Setenv
```go
func TestFoo(t *testing.T) {
// before
os.Setenv(key, "new value")
defer os.Unsetenv(key)
// after
t.Setenv(key, "new value")
}
```
---------
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
It will otherwise create the empty fields in the yaml, and snapcraft
then complains they are empty and fail.
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
mimic the structure to be created in the target repo, and put each of
them in its own folder.
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
nfpm was updated, but we never allowed to configure the umask field in
goreleaser.
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
closes#3989
Basically, when some of these pipes fail, the error will be memorized,
and all errors will be thrown in the end.
Meaning: the exit code will still be 1, but it'll not have stopped in
the first error.
Thinking of maybe adding a `--fail-fast` flag to disable this behavior
as well 🤔
---------
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
using the new multiple files api to have a single commit/push for all
files of a package.
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
this is needed when we run part of the pipeline on windows, and the rest
on linux, for example, the split build pro feature.
extracted from https://github.com/goreleaser/goreleaser/pull/3795
+ added tests for relative path thing
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
this will add support to winget into goreleaser.
Basically, the plan is:
- we generate the 3 needed yaml files
- we commit them to a repo
and that's it.
Initially, will probably have limited options support, and will only
have the default locale.
###### TODO
- [x] docs
- [x] review by someone who knows how this works?
- [x] test install somewhere
- [x] more tests maybe?
- [x] PR templates via API?
https://github.com/goreleaser/goreleaser/pull/4105
- [x] real project test
- [x] setup goreleaser to pr to winget as well
- [x] document sync fork stuff
https://github.com/goreleaser/goreleaser/pull/4106
---------
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
check if there is a `.github/PULL_REQUEST_TEMPLATE.md` file, and use it
as body of the pull request if there is.
---------
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
It should make goreleaser easier to use, as a `repository` is now always
called `repository`.
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
since this will be a late, big release, let's remove the deprecated
stuff that expired
---------
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This should make it easier to use the same config file with both oss and
pro versions when only the nightly feature is used, e.g. in #3501.
Currently, that would fail because `IsNightly` is not a template field,
so you won't really be able to do it without keeping a second
`.goreleaser.yml` file. With this change, `IsNightly` always eval to
false on OSS, and keeps working as before on Pro.