Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "chore: skip writing to GITHUB_ENV when building formula" #42

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
Loading