Created
November 23, 2016 16:53
-
-
Save t0chas/e9cd033318c560567c1d833c39866780 to your computer and use it in GitHub Desktop.
Use the current date as BuildNumber on Xcode projects build with Bitrise.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"os/exec" | |
"time" | |
) | |
// RunEnvmanAdd ... | |
func RunEnvmanAdd(key, value string) error { | |
args := []string{"add", "--key", key, "--value", value} | |
return RunCommand("envman", args...) | |
} | |
// RunCommand ... | |
func RunCommand(name string, args ...string) error { | |
cmd := exec.Command(name, args...) | |
cmd.Stdin = os.Stdin | |
cmd.Stdout = os.Stdout | |
cmd.Stderr = os.Stderr | |
return cmd.Run() | |
} | |
func main() { | |
now := time.Now() | |
// iso8601 time format (timezone: RFC3339Nano) | |
// ex: 2015-07-07T16:34:05.51843664+02:00 | |
timeString := fmt.Sprintf("%v", now.Format("20060102")) | |
fmt.Println("Going to store BUILD_NUMBER_DATETIME:", timeString) | |
if err := RunEnvmanAdd("BUILD_NUMBER_DATETIME", timeString); err != nil { | |
fmt.Println("Failed to store BUILD_NUMBER_DATETIME:", err) | |
os.Exit(1) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment