Skip to content

Commit 9808687

Browse files
authored
Merge pull request #40 from SpiffyEight77/chore/skip-github-env-write
chore: skip writing to GITHUB_ENV when building formula
2 parents f20a07c + f31d018 commit 9808687

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

releases/git.go

+23-6
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ type GitMetadata struct {
3030

3131
// IsTaggedRelease indicates if the build is for a versioned tag
3232
IsTaggedRelease bool
33+
34+
// Repository is the owner+name of the current repository
35+
Repository string
3336
}
3437

3538
func (m GitMetadata) ShouldPublishPermalink() bool {
@@ -41,8 +44,9 @@ func (m GitMetadata) ShouldPublishPermalink() bool {
4144
func LoadMetadata() GitMetadata {
4245
loadMetadata.Do(func() {
4346
gitMetadata = GitMetadata{
44-
Version: getVersion(),
45-
Commit: getCommit(),
47+
Version: getVersion(),
48+
Commit: getCommit(),
49+
Repository: getRepository(),
4650
}
4751

4852
gitMetadata.Permalink, gitMetadata.IsTaggedRelease = getPermalink()
@@ -51,12 +55,16 @@ func LoadMetadata() GitMetadata {
5155
log.Println("Permalink:", gitMetadata.Permalink)
5256
log.Println("Version:", gitMetadata.Version)
5357
log.Println("Commit:", gitMetadata.Commit)
58+
log.Println("Repository:", gitMetadata.Repository)
5459
})
5560

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+
}
6068

6169
return gitMetadata
6270
}
@@ -162,3 +170,12 @@ func getPermalink() (string, bool) {
162170
return fmt.Sprintf("%s-%s", permalinkPrefix, strings.TrimPrefix(branch, "release/")), taggedRelease
163171
}
164172
}
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

Comments
 (0)