You've already forked goreleaser
mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-11-06 09:09:29 +02:00
feat(tmpl): IsSingleTarget (#5122)
refs #5024 Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
301b193e6e
commit
e8da87cecb
@@ -173,6 +173,7 @@ func setupBuildContext(ctx *context.Context, options buildOpts) error {
|
||||
ctx.Clean = options.clean
|
||||
|
||||
if options.singleTarget {
|
||||
ctx.SingleTarget = true
|
||||
ctx.Partial = true
|
||||
}
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ const (
|
||||
patch = "Patch"
|
||||
prerelease = "Prerelease"
|
||||
isSnapshot = "IsSnapshot"
|
||||
isSingleTarget = "IsSingleTarget"
|
||||
isNightly = "IsNightly"
|
||||
isDraft = "IsDraft"
|
||||
env = "Env"
|
||||
@@ -118,6 +119,7 @@ func New(ctx *context.Context) *Template {
|
||||
patch: ctx.Semver.Patch,
|
||||
prerelease: ctx.Semver.Prerelease,
|
||||
isSnapshot: ctx.Snapshot,
|
||||
isSingleTarget: ctx.SingleTarget,
|
||||
isNightly: false,
|
||||
isDraft: ctx.Config.Release.Draft,
|
||||
releaseNotes: ctx.ReleaseNotes,
|
||||
|
||||
@@ -48,6 +48,7 @@ func TestWithArtifact(t *testing.T) {
|
||||
ctx.ModulePath = "github.com/goreleaser/goreleaser/v2"
|
||||
ctx.ReleaseNotes = "test release notes"
|
||||
ctx.Date = time.Unix(1678327562, 0)
|
||||
ctx.SingleTarget = true
|
||||
},
|
||||
)
|
||||
for expect, tmpl := range map[string]string{
|
||||
@@ -89,6 +90,7 @@ func TestWithArtifact(t *testing.T) {
|
||||
"2023-03-09T02:06:02Z": `{{ .Date }}`,
|
||||
"1678327562": `{{ .Timestamp }}`,
|
||||
"snapshot true": `snapshot {{.IsSnapshot}}`,
|
||||
"singletarget true": `singletarget {{.IsSingleTarget}}`,
|
||||
"nightly false": `nightly {{.IsNightly}}`,
|
||||
"draft true": `draft {{.IsDraft}}`,
|
||||
"dirty true": `dirty {{.IsGitDirty}}`,
|
||||
|
||||
@@ -102,6 +102,7 @@ type Context struct {
|
||||
Snapshot bool
|
||||
FailFast bool
|
||||
Partial bool
|
||||
SingleTarget bool
|
||||
SkipTokenCheck bool
|
||||
Clean bool
|
||||
PreRelease bool
|
||||
|
||||
@@ -10,7 +10,7 @@ Its intended usage is, for example, within Makefiles to avoid setting up ldflags
|
||||
|
||||
It also allows you to generate a local build for your current machine only using the `--single-target` option, and specific build IDs using the `--id` option in case you have more than one.
|
||||
|
||||
When using `--single-target`, the `GOOS` and `GOARCH` environment variables are used to determine the target, defaulting to the current machine target if not set.
|
||||
When using `--single-target`, the `GOOS`, `GOARCH`, `GOARM`, `GOAMD64`, and `GOMIPS` environment variables are used to determine the target, defaulting to the current machine target if not set.
|
||||
|
||||
|
||||
```
|
||||
|
||||
@@ -37,6 +37,7 @@ In fields that support templates, these fields are always available:
|
||||
| `.IsDraft` | `true` if `release.draft` is set in the configuration, `false` otherwise |
|
||||
| `.IsSnapshot` | `true` if `--snapshot` is set, `false` otherwise |
|
||||
| `.IsNightly` | `true` if `--nightly` is set, `false` otherwise |
|
||||
| `.IsSingleTarget` | `true` if `--single-target` is set, `false` otherwise |
|
||||
| `.Env` | a map with system's environment variables |
|
||||
| `.Date` | current UTC date in RFC 3339 format |
|
||||
| `.Now` | current UTC date as `time.Time` struct, allows all `time.Time` functions (e.g. `{{ .Now.Format "2006" }}`) |
|
||||
|
||||
Reference in New Issue
Block a user