mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 21:56:43 +00:00
fix(build): internal env fetching of github actions
This commit is contained in:
parent
f92ae3095f
commit
dc2ccd770e
1 changed files with 21 additions and 1 deletions
|
|
@ -98,6 +98,14 @@ func Env() Environment {
|
||||||
isPR := os.Getenv("GITHUB_HEAD_REF") != ""
|
isPR := os.Getenv("GITHUB_HEAD_REF") != ""
|
||||||
tag := ""
|
tag := ""
|
||||||
branch := ""
|
branch := ""
|
||||||
|
if reftype == "" {
|
||||||
|
gref := os.Getenv("GITHUB_REF")
|
||||||
|
if strings.HasPrefix(gref, "refs/heads/") {
|
||||||
|
reftype = "branch"
|
||||||
|
} else if strings.HasPrefix(gref, "refs/tags/") {
|
||||||
|
reftype = "tag"
|
||||||
|
}
|
||||||
|
}
|
||||||
switch {
|
switch {
|
||||||
case isPR:
|
case isPR:
|
||||||
branch = os.Getenv("GITHUB_BASE_REF")
|
branch = os.Getenv("GITHUB_BASE_REF")
|
||||||
|
|
@ -106,6 +114,18 @@ func Env() Environment {
|
||||||
case reftype == "tag":
|
case reftype == "tag":
|
||||||
tag = os.Getenv("GITHUB_REF_NAME")
|
tag = os.Getenv("GITHUB_REF_NAME")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fallback: If tag or branch is still empty, derive from GITHUB_REF.
|
||||||
|
if tag == "" && branch == "" {
|
||||||
|
if gref := os.Getenv("GITHUB_REF"); gref != "" {
|
||||||
|
if strings.HasPrefix(gref, "refs/tags/") {
|
||||||
|
tag = strings.TrimPrefix(gref, "refs/tags/")
|
||||||
|
} else if strings.HasPrefix(gref, "refs/heads/") {
|
||||||
|
branch = strings.TrimPrefix(gref, "refs/heads/")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return Environment{
|
return Environment{
|
||||||
CI: true,
|
CI: true,
|
||||||
Name: "github-actions",
|
Name: "github-actions",
|
||||||
|
|
@ -126,7 +146,7 @@ func Env() Environment {
|
||||||
|
|
||||||
// LocalEnv returns build environment metadata gathered from git.
|
// LocalEnv returns build environment metadata gathered from git.
|
||||||
func LocalEnv() Environment {
|
func LocalEnv() Environment {
|
||||||
env := applyEnvFlags(Environment{Name: "local", Repo: "ethereum/go-ethereum"})
|
env := applyEnvFlags(Environment{Name: "local", Repo: "berachain/bera-geth"})
|
||||||
|
|
||||||
head := readGitFile("HEAD")
|
head := readGitFile("HEAD")
|
||||||
if fields := strings.Fields(head); len(fields) == 2 {
|
if fields := strings.Fields(head); len(fields) == 2 {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue