Skip to content

Commit

Permalink
revert: skip writing to GITHUB_ENV when building formula
Browse files Browse the repository at this point in the history
Signed-off-by: Ruihua Wen <spiffyeight77@gmail.com>
  • Loading branch information
SpiffyEight77 committed Jun 30, 2024
1 parent 081303e commit 4c16cdd
Showing 1 changed file with 6 additions and 23 deletions.
29 changes: 6 additions & 23 deletions releases/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ type GitMetadata struct {

// IsTaggedRelease indicates if the build is for a versioned tag
IsTaggedRelease bool

// Repository is the owner+name of the current repository
Repository string
}

func (m GitMetadata) ShouldPublishPermalink() bool {
Expand All @@ -44,9 +41,8 @@ func (m GitMetadata) ShouldPublishPermalink() bool {
func LoadMetadata() GitMetadata {
loadMetadata.Do(func() {
gitMetadata = GitMetadata{
Version: getVersion(),
Commit: getCommit(),
Repository: getRepository(),
Version: getVersion(),
Commit: getCommit(),
}

gitMetadata.Permalink, gitMetadata.IsTaggedRelease = getPermalink()
Expand All @@ -55,16 +51,12 @@ func LoadMetadata() GitMetadata {
log.Println("Permalink:", gitMetadata.Permalink)
log.Println("Version:", gitMetadata.Version)
log.Println("Commit:", gitMetadata.Commit)
log.Println("Repository:", gitMetadata.Repository)
})

// Workaround to avoid writing to GITHUB_ENV when building the Homebrew formula.
if gitMetadata.Repository != "Homebrew/homebrew-core" {
// Save the metadata as environment variables to use later in the CI pipeline
p, _ := ci.DetectBuildProvider()
mgx.Must(p.SetEnv("PERMALINK", gitMetadata.Permalink))
mgx.Must(p.SetEnv("VERSION", gitMetadata.Version))
}
// Save the metadata as environment variables to use later in the CI pipeline
p, _ := ci.DetectBuildProvider()
mgx.Must(p.SetEnv("PERMALINK", gitMetadata.Permalink))
mgx.Must(p.SetEnv("VERSION", gitMetadata.Version))

return gitMetadata
}
Expand Down Expand Up @@ -170,12 +162,3 @@ func getPermalink() (string, bool) {
return fmt.Sprintf("%s-%s", permalinkPrefix, strings.TrimPrefix(branch, "release/")), taggedRelease
}
}

func getRepository() string {
repository, ok := os.LookupEnv("GITHUB_REPOSITORY")
if !ok {
repository = "getporter/porter"
}

return repository
}

0 comments on commit 4c16cdd

Please sign in to comment.