forked from goreleaser/goreleaser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
context.go
57 lines (50 loc) · 1.27 KB
/
context.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Package context provides gorelease context which is passed through the
// pipeline.
//
// The context extends the standard library context and add a few more
// fields and other things, so pipes can gather data provided by previous
// pipes without really knowing each other.
package context
import (
ctx "context"
"log"
"strings"
"sync"
"github.com/goreleaser/goreleaser/config"
)
// GitInfo includes tags and diffs used in some point
type GitInfo struct {
CurrentTag string
Commit string
}
// Context carries along some data through the pipes
type Context struct {
ctx.Context
Config config.Project
Token string
Git GitInfo
Archives map[string]string
Artifacts []string
ReleaseNotes string
Version string
Validate bool
Publish bool
}
var lock sync.Mutex
// AddArtifact adds a file to upload list
func (ctx *Context) AddArtifact(file string) {
lock.Lock()
defer lock.Unlock()
file = strings.TrimPrefix(file, ctx.Config.Dist)
file = strings.Replace(file, "/", "", -1)
ctx.Artifacts = append(ctx.Artifacts, file)
log.Println("Registered artifact", file)
}
// New context
func New(config config.Project) *Context {
return &Context{
Context: ctx.Background(),
Config: config,
Archives: map[string]string{},
}
}