@@ -30,6 +30,9 @@ type GitMetadata struct {
30
30
31
31
// IsTaggedRelease indicates if the build is for a versioned tag
32
32
IsTaggedRelease bool
33
+
34
+ // Repository is the owner+name of the current repository
35
+ Repository string
33
36
}
34
37
35
38
func (m GitMetadata ) ShouldPublishPermalink () bool {
@@ -41,8 +44,9 @@ func (m GitMetadata) ShouldPublishPermalink() bool {
41
44
func LoadMetadata () GitMetadata {
42
45
loadMetadata .Do (func () {
43
46
gitMetadata = GitMetadata {
44
- Version : getVersion (),
45
- Commit : getCommit (),
47
+ Version : getVersion (),
48
+ Commit : getCommit (),
49
+ Repository : getRepository (),
46
50
}
47
51
48
52
gitMetadata .Permalink , gitMetadata .IsTaggedRelease = getPermalink ()
@@ -51,12 +55,16 @@ func LoadMetadata() GitMetadata {
51
55
log .Println ("Permalink:" , gitMetadata .Permalink )
52
56
log .Println ("Version:" , gitMetadata .Version )
53
57
log .Println ("Commit:" , gitMetadata .Commit )
58
+ log .Println ("Repository:" , gitMetadata .Repository )
54
59
})
55
60
56
- // Save the metadata as environment variables to use later in the CI pipeline
57
- p , _ := ci .DetectBuildProvider ()
58
- mgx .Must (p .SetEnv ("PERMALINK" , gitMetadata .Permalink ))
59
- mgx .Must (p .SetEnv ("VERSION" , gitMetadata .Version ))
61
+ // Workaround to avoid writing to GITHUB_ENV when building the Homebrew formula.
62
+ if gitMetadata .Repository != "Homebrew/homebrew-core" {
63
+ // Save the metadata as environment variables to use later in the CI pipeline
64
+ p , _ := ci .DetectBuildProvider ()
65
+ mgx .Must (p .SetEnv ("PERMALINK" , gitMetadata .Permalink ))
66
+ mgx .Must (p .SetEnv ("VERSION" , gitMetadata .Version ))
67
+ }
60
68
61
69
return gitMetadata
62
70
}
@@ -162,3 +170,12 @@ func getPermalink() (string, bool) {
162
170
return fmt .Sprintf ("%s-%s" , permalinkPrefix , strings .TrimPrefix (branch , "release/" )), taggedRelease
163
171
}
164
172
}
173
+
174
+ func getRepository () string {
175
+ repository , ok := os .LookupEnv ("GITHUB_REPOSITORY" )
176
+ if ! ok {
177
+ repository = "getporter/porter"
178
+ }
179
+
180
+ return repository
181
+ }
0 commit comments