// SaveSetupSuccessForVersion ... func SaveSetupSuccessForVersion(ver string) error { if err := EnsureBitriseConfigDirExists(); err != nil { return err } configPth := getBitriseConfigVersionSetupFilePath() return fileutil.WriteStringToFile(configPth, ver) }
func saveRawOutputToLogFile(rawXcodebuildOutput string, isRunSuccess bool) error { tmpDir, err := pathutil.NormalizedOSTempDirPath("xcodebuild-output") if err != nil { return fmt.Errorf("Failed to create temp dir, error: %s", err) } logFileName := "raw-xcodebuild-output.log" logPth := filepath.Join(tmpDir, logFileName) if err := fileutil.WriteStringToFile(logPth, rawXcodebuildOutput); err != nil { return fmt.Errorf("Failed to write xcodebuild output to file, error: %s", err) } if !isRunSuccess { deployDir := os.Getenv("BITRISE_DEPLOY_DIR") if deployDir == "" { return errors.New("No BITRISE_DEPLOY_DIR found") } deployPth := filepath.Join(deployDir, logFileName) if err := cmdex.CopyFile(logPth, deployPth); err != nil { return fmt.Errorf("Failed to copy xcodebuild output log file from (%s) to (%s), error: %s", logPth, deployPth, err) } logPth = deployPth } if err := cmd.ExportEnvironmentWithEnvman("BITRISE_XCODE_RAW_TEST_RESULT_TEXT_PATH", logPth); err != nil { log.Warn("Failed to export: BITRISE_XCODE_RAW_TEST_RESULT_TEXT_PATH, error: %s", err) } return nil }
// ExportOutputFileContent ... func ExportOutputFileContent(content, destinationPth, envKey string) error { if err := fileutil.WriteStringToFile(destinationPth, content); err != nil { return err } return ExportOutputFile(destinationPth, destinationPth, envKey) }
func Test_ValidateTest(t *testing.T) { tmpDir, err := pathutil.NormalizedOSTempDirPath("__validate_test__") require.NoError(t, err) defer func() { require.NoError(t, os.RemoveAll(tmpDir)) }() t.Log("valid bitrise.yml") { cmd := cmdex.NewCommand(binPath(), "validate", "-c", "trigger_params_test_bitrise.yml") out, err := cmd.RunAndReturnTrimmedCombinedOutput() require.NoError(t, err) require.Equal(t, "Config is valid: \x1b[32;1mtrue\x1b[0m", out) } t.Log("valid - warning test - `-p` flag is deprecated") { cmd := cmdex.NewCommand(binPath(), "validate", "-p", "trigger_params_test_bitrise.yml") out, err := cmd.RunAndReturnTrimmedCombinedOutput() require.NoError(t, err) require.Equal(t, "Config is valid: \x1b[32;1mtrue\x1b[0m\nWarning(s):\n- 'path' key is deprecated, use 'config' instead!", out) } t.Log("valid - invalid workflow id") { configPth := filepath.Join(tmpDir, "bitrise.yml") require.NoError(t, fileutil.WriteStringToFile(configPth, invalidWorkflowIDBitriseYML)) cmd := cmdex.NewCommand(binPath(), "validate", "-c", configPth) out, err := cmd.RunAndReturnTrimmedCombinedOutput() require.NoError(t, err) expected := "Config is valid: \x1b[32;1mtrue\x1b[0m\nWarning(s):\n- invalid workflow ID (invalid:id): doesn't conform to: [A-Za-z0-9-_.]" require.Equal(t, expected, out) } t.Log("invalid - empty bitrise.yml") { configPth := filepath.Join(tmpDir, "bitrise.yml") require.NoError(t, fileutil.WriteStringToFile(configPth, emptyBitriseYML)) cmd := cmdex.NewCommand(binPath(), "validate", "-c", configPth) out, err := cmd.RunAndReturnTrimmedCombinedOutput() require.Error(t, err, out) expected := fmt.Sprintf("Config is valid: \x1b[31;1mfalse\x1b[0m\nError: \x1b[31;1mConfig (path:%s) is not valid: empty config\x1b[0m", configPth) require.Equal(t, expected, out) } }
func Test_ValidateTestJSON(t *testing.T) { tmpDir, err := pathutil.NormalizedOSTempDirPath("__validate_test__") require.NoError(t, err) defer func() { require.NoError(t, os.RemoveAll(tmpDir)) }() t.Log("valid bitrise.yml") { cmd := cmdex.NewCommand(binPath(), "validate", "-c", "trigger_params_test_bitrise.yml", "--format", "json") out, err := cmd.RunAndReturnTrimmedCombinedOutput() require.NoError(t, err) require.Equal(t, "{\"data\":{\"config\":{\"is_valid\":true}}}", out) } t.Log("valid - warning test - `-p` flag is deprecated") { cmd := cmdex.NewCommand(binPath(), "validate", "-p", "trigger_params_test_bitrise.yml", "--format", "json") out, err := cmd.RunAndReturnTrimmedCombinedOutput() require.NoError(t, err) require.Equal(t, "{\"data\":{\"config\":{\"is_valid\":true}},\"warnings\":[\"'path' key is deprecated, use 'config' instead!\"]}", out) } t.Log("valid - invalid workflow id") { configPth := filepath.Join(tmpDir, "bitrise.yml") require.NoError(t, fileutil.WriteStringToFile(configPth, invalidWorkflowIDBitriseYML)) cmd := cmdex.NewCommand(binPath(), "validate", "-c", configPth, "--format", "json") out, err := cmd.RunAndReturnTrimmedCombinedOutput() require.NoError(t, err) expected := "{\"data\":{\"config\":{\"is_valid\":true,\"warnings\":[\"invalid workflow ID (invalid:id): doesn't conform to: [A-Za-z0-9-_.]\"]}}}" require.Equal(t, expected, out) } t.Log("invalid - empty bitrise.yml") { configPth := filepath.Join(tmpDir, "bitrise.yml") require.NoError(t, fileutil.WriteStringToFile(configPth, emptyBitriseYML)) cmd := cmdex.NewCommand(binPath(), "validate", "-c", configPth, "--format", "json") out, err := cmd.RunAndReturnTrimmedCombinedOutput() require.Error(t, err, out) expected := fmt.Sprintf("{\"data\":{\"config\":{\"is_valid\":false,\"error\":\"Config (path:%s) is not valid: empty config\"}}}", configPth) require.Equal(t, expected, out) } }
func Test_SecretValidateTestJSON(t *testing.T) { tmpDir, err := pathutil.NormalizedOSTempDirPath("__validate_test__") require.NoError(t, err) defer func() { require.NoError(t, os.RemoveAll(tmpDir)) }() t.Log("valid secret") { cmd := cmdex.NewCommand(binPath(), "validate", "-i", "global_flag_test_secrets.yml", "--format", "json") out, err := cmd.RunAndReturnTrimmedCombinedOutput() require.NoError(t, err) require.Equal(t, "{\"data\":{\"secrets\":{\"is_valid\":true}}}", out) } t.Log("invalid - empty config") { secretsPth := filepath.Join(tmpDir, "secrets.yml") require.NoError(t, fileutil.WriteStringToFile(secretsPth, emptySecret)) cmd := cmdex.NewCommand(binPath(), "validate", "-i", secretsPth, "--format", "json") out, err := cmd.RunAndReturnTrimmedCombinedOutput() require.Error(t, err, out) expected := "{\"data\":{\"secrets\":{\"is_valid\":false,\"error\":\"empty config\"}}}" require.Equal(t, expected, out) } t.Log("invalid - invalid secret model") { secretsPth := filepath.Join(tmpDir, "secrets.yml") require.NoError(t, fileutil.WriteStringToFile(secretsPth, invalidSecret)) cmd := cmdex.NewCommand(binPath(), "validate", "-i", secretsPth, "--format", "json") out, err := cmd.RunAndReturnTrimmedCombinedOutput() require.Error(t, err, out) expected := "{\"data\":{\"secrets\":{\"is_valid\":false,\"error\":\"Invalid invetory format: yaml: unmarshal errors:\\n line 1: cannot unmarshal !!seq into models.EnvsYMLModel\"}}}" require.Equal(t, expected, out) } }
func Test_SecretValidateTest(t *testing.T) { tmpDir, err := pathutil.NormalizedOSTempDirPath("__validate_test__") require.NoError(t, err) defer func() { require.NoError(t, os.RemoveAll(tmpDir)) }() t.Log("valid secret") { cmd := cmdex.NewCommand(binPath(), "validate", "-i", "global_flag_test_secrets.yml") out, err := cmd.RunAndReturnTrimmedCombinedOutput() require.NoError(t, err) require.Equal(t, "Secret is valid: \x1b[32;1mtrue\x1b[0m", out) } t.Log("invalid - empty secret") { secretsPth := filepath.Join(tmpDir, "secrets.yml") require.NoError(t, fileutil.WriteStringToFile(secretsPth, emptySecret)) cmd := cmdex.NewCommand(binPath(), "validate", "-i", secretsPth) out, err := cmd.RunAndReturnTrimmedCombinedOutput() require.Error(t, err, out) expected := "Secret is valid: \x1b[31;1mfalse\x1b[0m\nError: \x1b[31;1mempty config\x1b[0m" require.Equal(t, expected, out) } t.Log("invalid - invalid secret model") { secretsPth := filepath.Join(tmpDir, "secrets.yml") require.NoError(t, fileutil.WriteStringToFile(secretsPth, invalidSecret)) cmd := cmdex.NewCommand(binPath(), "validate", "-i", secretsPth) out, err := cmd.RunAndReturnTrimmedCombinedOutput() require.Error(t, err, out) expected := "Secret is valid: \x1b[31;1mfalse\x1b[0m\nError: \x1b[31;1mInvalid invetory format: yaml: unmarshal errors:\n line 1: cannot unmarshal !!seq into models.EnvsYMLModel\x1b[0m" require.Equal(t, expected, out) } }
func saveSecretsToFile(pth, secretsStr string) (bool, error) { if exists, err := pathutil.IsPathExists(pth); err != nil { return false, err } else if exists { ask := fmt.Sprintf("A secrets file already exists at %s - do you want to overwrite it?", pth) if val, err := goinp.AskForBool(ask); err != nil { return false, err } else if !val { log.Infoln("Init canceled, existing file (" + pth + ") won't be overwritten.") return false, nil } } if err := fileutil.WriteStringToFile(pth, secretsStr); err != nil { return false, err } return true, nil }
func initConfig(c *cli.Context) error { PrintBitriseHeaderASCIIArt(c.App.Version) bitriseConfigFileRelPath := "./" + DefaultBitriseConfigFileName bitriseSecretsFileRelPath := "./" + DefaultSecretsFileName if exists, err := pathutil.IsPathExists(bitriseConfigFileRelPath); err != nil { log.Fatalf("Failed to init path (%s), error: %s", bitriseConfigFileRelPath, err) } else if exists { ask := fmt.Sprintf("A config file already exists at %s - do you want to overwrite it?", bitriseConfigFileRelPath) if val, err := goinp.AskForBool(ask); err != nil { log.Fatalf("Failed to ask for input, error: %s", err) } else if !val { log.Info("Init canceled, existing file won't be overwritten.") os.Exit(0) } } userInputProjectTitle := "" userInputDevBranch := "" if val, err := goinp.AskForString("What's the BITRISE_APP_TITLE?"); err != nil { log.Fatalf("Failed to ask for input, error: %s", err) } else { userInputProjectTitle = val } if val, err := goinp.AskForString("What's your development branch's name?"); err != nil { log.Fatalf("Failed to ask for input, error: %s", err) } else { userInputDevBranch = val } bitriseConfContent, warnings, err := generateBitriseYMLContent(userInputProjectTitle, userInputDevBranch) for _, warning := range warnings { log.Warnf("warning: %s", warning) } if err != nil { log.Fatalf("Invalid Bitrise YML, error: %s", err) } if err := fileutil.WriteStringToFile(bitriseConfigFileRelPath, bitriseConfContent); err != nil { log.Fatalf("Failed to init the bitrise config file, error: %s", err) } else { fmt.Println() fmt.Println("# NOTES about the " + DefaultBitriseConfigFileName + " config file:") fmt.Println() fmt.Println("We initialized a " + DefaultBitriseConfigFileName + " config file for you.") fmt.Println("If you're in this folder you can use this config file") fmt.Println(" with bitrise automatically, you don't have to") fmt.Println(" specify it's path.") fmt.Println() } if initialized, err := saveSecretsToFile(bitriseSecretsFileRelPath, defaultSecretsContent); err != nil { log.Fatalf("Failed to init the secrets file, error: %s", err) } else if initialized { fmt.Println() fmt.Println("# NOTES about the " + DefaultSecretsFileName + " secrets file:") fmt.Println() fmt.Println("We also created a " + DefaultSecretsFileName + " file") fmt.Println(" in this directory, to keep your passwords, absolute path configurations") fmt.Println(" and other secrets separate from your") fmt.Println(" main configuration file.") fmt.Println("This way you can safely commit and share your configuration file") fmt.Println(" and ignore this secrets file, so nobody else will") fmt.Println(" know about your secrets.") fmt.Println(colorstring.Yellow("You should NEVER commit this secrets file into your repository!!")) fmt.Println() } // add the general .bitrise* item // which will include both secret files like .bitrise.secrets.yml // and the .bitrise work temp dir if err := addToGitignore(".bitrise*"); err != nil { log.Fatalf("Failed to add .gitignore pattern, error: %s", err) } fmt.Println(colorstring.Green("For your convenience we added the pattern '.bitrise*' to your .gitignore file")) fmt.Println(" to make it sure that no secrets or temporary work directories will be") fmt.Println(" committed into your repository.") fmt.Println() fmt.Println("Hurray, you're good to go!") fmt.Println("You can simply run:") fmt.Println("-> bitrise run test") fmt.Println("to test the sample configuration (which contains") fmt.Println("an example workflow called 'test').") fmt.Println() fmt.Println("Once you tested this sample setup you can") fmt.Println(" open the " + DefaultBitriseConfigFileName + " config file,") fmt.Println(" modify it and then run a workflow with:") fmt.Println("-> bitrise run YOUR-WORKFLOW-NAME") fmt.Println(" or trigger a build with a pattern:") fmt.Println("-> bitrise trigger YOUR/PATTERN") return nil }
func scanXamarinProject(cmd *cobra.Command, args []string) error { absExportOutputDirPath, err := initExportOutputDir() if err != nil { return printXamarinScanFinishedWithError("Failed to prepare Export directory: %s", err) } logOutput := "" xamarinCmd := xamarin.CommandModel{} if paramXamarinOutputLogFilePath != "" { xamLog, err := fileutil.ReadStringFromFile(paramXamarinOutputLogFilePath) if err != nil { return printXamarinScanFinishedWithError("Failed to read log from the specified log file, error: %s", err) } logOutput = xamLog } else { // --- Inputs --- // Xamarin Solution Path xamarinCmd.SolutionFilePath = paramXamarinSolutionFilePath if xamarinCmd.SolutionFilePath == "" { askText := `Please drag-and-drop your Xamarin Solution (` + colorstring.Green(".sln") + `) file here, and then hit Enter` fmt.Println() projpth, err := goinp.AskForPath(askText) if err != nil { return printXamarinScanFinishedWithError("Failed to read input: %s", err) } xamarinCmd.SolutionFilePath = projpth } log.Debugf("xamSolutionPth: %s", xamarinCmd.SolutionFilePath) xamSln, err := solution.New(xamarinCmd.SolutionFilePath, true) if err != nil { return printXamarinScanFinishedWithError("Failed to analyze Xamarin solution: %s", err) } log.Debugf("xamSln: %#v", xamSln) // filter only the iOS "app"" projects xamarinProjectsToChooseFrom := []project.Model{} for _, aXamarinProject := range xamSln.ProjectMap { switch aXamarinProject.ProjectType { case constants.ProjectTypeIOS, constants.ProjectTypeTvOS, constants.ProjectTypeMacOS: if aXamarinProject.OutputType == "exe" { // possible project xamarinProjectsToChooseFrom = append(xamarinProjectsToChooseFrom, aXamarinProject) } default: continue } } log.Debugf("len(xamarinProjectsToChooseFrom): %#v", len(xamarinProjectsToChooseFrom)) log.Debugf("xamarinProjectsToChooseFrom: %#v", xamarinProjectsToChooseFrom) // Xamarin Project selectedXamarinProject := project.Model{} { if len(xamarinProjectsToChooseFrom) < 1 { return printXamarinScanFinishedWithError( "No acceptable Project found in the provided Solution, or none can be used for iOS Archive.", ) } if paramXamarinProjectName != "" { // project specified via flag/param for _, aProj := range xamarinProjectsToChooseFrom { if paramXamarinProjectName == aProj.Name { selectedXamarinProject = aProj break } } if selectedXamarinProject.Name == "" { return printXamarinScanFinishedWithError( `Invalid Project specified (%s), either not found in the provided Solution or it can't be used for iOS "Archive for Publishing".`, paramXamarinProjectName) } } else { // no project CLI param specified if len(xamarinProjectsToChooseFrom) == 1 { selectedXamarinProject = xamarinProjectsToChooseFrom[0] } else { projectNames := []string{} for _, aProj := range xamarinProjectsToChooseFrom { projectNames = append(projectNames, aProj.Name) } fmt.Println() answerValue, err := goinp.SelectFromStrings( `Select the Project Name you use for "Archive for Publishing" (usually ends with ".iOS", e.g.: MyProject.iOS)?`, projectNames, ) if err != nil { return printXamarinScanFinishedWithError("Failed to select Project: %s", err) } log.Debugf("selected project: %v", answerValue) for _, aProj := range xamarinProjectsToChooseFrom { if answerValue == aProj.Name { selectedXamarinProject = aProj break } } } } } xamarinCmd.ProjectName = selectedXamarinProject.Name log.Debugf("xamarinCmd.ProjectName: %s", xamarinCmd.ProjectName) log.Debugf("selectedXamarinProject.Configs: %#v", selectedXamarinProject.Configs) // Xamarin Configuration Name selectedXamarinConfigurationName := "" { acceptableConfigs := []string{} for configName, aConfig := range selectedXamarinProject.Configs { if aConfig.Platform == "iPhone" { if aConfig.Configuration == "Release" { // ios & tvOS app acceptableConfigs = append(acceptableConfigs, configName) } } else if aConfig.Platform == "x86" { if aConfig.Configuration == "Release" || aConfig.Configuration == "Debug" { // MacOS app acceptableConfigs = append(acceptableConfigs, configName) } } } if len(acceptableConfigs) < 1 { return printXamarinScanFinishedWithError( `No acceptable Configuration found in the provided Solution and Project, or none can be used for iOS "Archive for Publishing".`, ) } if paramXamarinConfigurationName != "" { // configuration specified via flag/param for _, aConfigName := range acceptableConfigs { if paramXamarinConfigurationName == aConfigName { selectedXamarinConfigurationName = aConfigName break } } if selectedXamarinConfigurationName == "" { return printXamarinScanFinishedWithError( "Invalid Configuration specified (%s), either not found in the provided Solution and Project or it can't be used for iOS Archive.", paramXamarinConfigurationName) } } else { // no configuration CLI param specified if len(acceptableConfigs) == 1 { selectedXamarinConfigurationName = acceptableConfigs[0] } else { fmt.Println() answerValue, err := goinp.SelectFromStrings( `Select the Configuration Name you use for "Archive for Publishing" (usually Release|iPhone)?`, acceptableConfigs, ) if err != nil { return printXamarinScanFinishedWithError("Failed to select Configuration: %s", err) } log.Debugf("selected configuration: %v", answerValue) selectedXamarinConfigurationName = answerValue } } } if selectedXamarinConfigurationName == "" { return printXamarinScanFinishedWithError( `No acceptable Configuration found (it was empty) in the provided Solution and Project, or none can be used for iOS "Archive for Publishing".`, ) } xamarinCmd.ConfigurationName = selectedXamarinConfigurationName fmt.Println() fmt.Println() log.Println(`🔦 Running a Build, to get all the required code signing settings...`) xamLogOut, err := xamarinCmd.GenerateLog() logOutput = xamLogOut // save the xamarin output into a debug log file logOutputFilePath := filepath.Join(absExportOutputDirPath, "xamarin-build-output.log") { log.Infof(" 💡 "+colorstring.Yellow("Saving xamarin output into file")+": %s", logOutputFilePath) if logWriteErr := fileutil.WriteStringToFile(logOutputFilePath, logOutput); logWriteErr != nil { log.Errorf("Failed to save xamarin build output into file (%s), error: %s", logOutputFilePath, logWriteErr) } else if err != nil { log.Infoln(colorstring.Yellow("Please check the logfile (" + logOutputFilePath + ") to see what caused the error")) log.Infoln(colorstring.Red(`and make sure that you can "Archive for Publishing" this project from Xamarin!`)) fmt.Println() log.Infoln("Open the project: ", xamarinCmd.SolutionFilePath) log.Infoln(`And do "Archive for Publishing", after selecting the Configuration: `, xamarinCmd.ConfigurationName) fmt.Println() } } if err != nil { return printXamarinScanFinishedWithError("Failed to run xamarin build command: %s", err) } } codeSigningSettings, err := xamarinCmd.ScanCodeSigningSettings(logOutput) if err != nil { return printXamarinScanFinishedWithError("Failed to detect code signing settings: %s", err) } log.Debugf("codeSigningSettings: %#v", codeSigningSettings) return exportCodeSigningFiles("Xamarin Studio", absExportOutputDirPath, codeSigningSettings) }
// WriteChangelog ... func WriteChangelog(commits, taggedCommits []git.CommitModel, config Config, append bool) error { newChangelog := generateChangelogContent(commits, taggedCommits, config.Release.Version) headerStr := "" footerStr := "" contentStr := "" // // Generate changelog header if config.Changelog.HeaderTemplate == "" && config.Changelog.FooterTemplate == "" { log.Debug() log.Debug("Write changelog WITHOUT header and footer template") } // Header if config.Changelog.HeaderTemplate != "" { log.Debug() log.Debug("Write changelog with header and footer template") headerTemplate := template.New("changelog_header").Funcs(changelogTemplateFuncMap) headerTemplate, err := headerTemplate.Parse(config.Changelog.HeaderTemplate) if err != nil { log.Fatalf("Failed to parse header template, error: %#v", err) } var headerBytes bytes.Buffer err = headerTemplate.Execute(&headerBytes, newChangelog) if err != nil { log.Fatalf("Failed to execute layout template, error: %#v", err) } headerStr = headerBytes.String() headerStr += "\n\n" + separator + "\n" } // Footer if config.Changelog.FooterTemplate != "" { footerTemplate := template.New("changelog_footer").Funcs(changelogTemplateFuncMap) footerTemplate, err := footerTemplate.Parse(config.Changelog.FooterTemplate) if err != nil { log.Fatalf("Failed to parse footer template, error: %#v", err) } var footerBytes bytes.Buffer err = footerTemplate.Execute(&footerBytes, newChangelog) if err != nil { log.Fatalf("Failed to execute footer template, error: %#v", err) } footerStr = footerBytes.String() footerStr = separator + "\n\n" + footerStr } log.Debug() log.Debug("Layout header: %s", headerStr) log.Debug("Layout footer: %s", footerStr) // // Generate changelog content changelogContentTemplateStr := ChangelogContentTemplate if config.Changelog.ContentTemplate != "" { changelogContentTemplateStr = config.Changelog.ContentTemplate } contentTemplate := template.New("changelog_content").Funcs(changelogTemplateFuncMap) contentTemplate, err := contentTemplate.Parse(changelogContentTemplateStr) if err != nil { log.Fatalf("Failed to parse content template, error: %#v", err) } var newContentBytes bytes.Buffer err = contentTemplate.Execute(&newContentBytes, newChangelog) if err != nil { log.Fatalf("Failed to execute template, error: %#v", err) } newContentStr := newContentBytes.String() newContentSplit := strings.Split(newContentStr, "\n") if len(newContentSplit) > 0 { newContentSplit = newContentSplit[0 : len(newContentSplit)-1] newContentStr = strings.Join(newContentSplit, "\n") } log.Debug() log.Debug("Content:") for _, line := range strings.Split(newContentStr, "\n") { log.Debug("%s", line) } // Join header and content if append { log.Debug() log.Debug("Previous changelog exist, append new conent") prevChangelogStr, err := fileutil.ReadStringFromFile(config.Changelog.Path) if err != nil { return err } prevContentStr := "" if config.Changelog.HeaderTemplate != "" && config.Changelog.FooterTemplate != "" { tmpPrevContentStr, err := parseChangelog(prevChangelogStr) if err != nil { log.Warnf("Failed to parse previous changelog: %s", err) } else { prevContentStr = tmpPrevContentStr } } else { prevContentStr = prevChangelogStr } log.Debug() log.Debug("Prev content:") for _, line := range strings.Split(prevContentStr, "\n") { log.Debugf("%s", line) } contentStr = fmt.Sprintf("%s\n%s", newContentStr, prevContentStr) log.Debug() log.Debug("Merged content:") contentSplits := strings.Split(contentStr, "\n") for _, line := range contentSplits { log.Debugf("%s", line) } } else { log.Debug() log.Debug("NO previous changelog exist") contentStr = newContentStr } changelogStr := headerStr + "\n" + contentStr + "\n" + footerStr return fileutil.WriteStringToFile(config.Changelog.Path, changelogStr) }
func main() { configs := createConfigsModelFromEnvs() fmt.Println() configs.print() if err := configs.validate(); err != nil { fail("Issue with input: %s", err) } customOptions := []string{} if configs.CarthageOptions != "" { options, err := shellquote.Split(configs.CarthageOptions) if err != nil { fail("Failed to shell split CarthageOptions (%s), error: %s", configs.CarthageOptions) } customOptions = options } // // Exit if bootstrap is cached log.Info("Check if cache is available") hasCachedItems, err := isCacheAvailable(configs.SourceDir) if err != nil { fail("Failed to check cached files, error: %s", err) } log.Detail("has cahched items: %v", hasCachedItems) if configs.CarthageCommand == "bootstrap" && hasCachedItems { log.Done("Using cached dependencies for bootstrap command. If you would like to force update your dependencies, select `update` as CarthageCommand and re-run your build.") os.Exit(0) } fmt.Println() // --- // // Run carthage command log.Info("Running Carthage command") args := append([]string{configs.CarthageCommand}, customOptions...) cmd := cmdex.NewCommand("carthage", args...) if configs.GithubAccessToken != "" { log.Detail("Appending GITHUB_ACCESS_TOKEN to process environments") cmd.AppendEnvs([]string{fmt.Sprintf("GITHUB_ACCESS_TOKEN=%s", configs.GithubAccessToken)}) } cmd.SetStdout(os.Stdout) cmd.SetStderr(os.Stderr) log.Done("$ %s", cmdex.PrintableCommandArgs(false, cmd.GetCmd().Args)) fmt.Println() if err := cmd.Run(); err != nil { fail("Carthage command failed, error: %s", err) } // --- // // Create cache if configs.CarthageCommand == "bootstrap" { fmt.Println() log.Info("Creating cache") cacheFilePth := filepath.Join(configs.SourceDir, carthageDirName, cacheFileName) swiftVersion, err := swiftVersion() if err != nil { fail("Failed to get swift version, error: %s", err) } resolvedFilePath := filepath.Join(configs.SourceDir, resolvedFileName) resolved, err := contentsOfCartfileResolved(resolvedFilePath) if err != nil { fail("Failed to get resolved file content, error: %s", err) } cacheContent := fmt.Sprintf("--Swift version: %s --Swift version \n --%s: %s --%s", swiftVersion, resolvedFileName, resolved, resolvedFileName) carthageDir := filepath.Join(configs.SourceDir, carthageDirName) if exist, err := pathutil.IsPathExists(carthageDir); err != nil { fail("Failed to check if dir exists at (%s), error: %s", carthageDir, err) } else if !exist { if err := os.Mkdir(carthageDir, 0777); err != nil { fail("Failed to create dir (%s), error: %s", carthageDir, err) } } if err := fileutil.WriteStringToFile(cacheFilePth, cacheContent); err != nil { fail("Failed to write cahe file, error: %s", err) } log.Done("Cachefile: %s", cacheFilePth) } // --- }
func scanXcodeProject(cmd *cobra.Command, args []string) error { absExportOutputDirPath, err := initExportOutputDir() if err != nil { return printXcodeScanFinishedWithError("Failed to prepare Export directory: %s", err) } xcodebuildOutput := "" xcodeCmd := xcode.CommandModel{} if paramXcodebuildOutputLogFilePath != "" { xcLog, err := fileutil.ReadStringFromFile(paramXcodebuildOutputLogFilePath) if err != nil { return printXcodeScanFinishedWithError("Failed to read log from the specified log file, error: %s", err) } xcodebuildOutput = xcLog } else { projectPath := paramXcodeProjectFilePath if projectPath == "" { askText := `Please drag-and-drop your Xcode Project (` + colorstring.Green(".xcodeproj") + `) or Workspace (` + colorstring.Green(".xcworkspace") + `) file, the one you usually open in Xcode, then hit Enter. (Note: if you have a Workspace file you should most likely use that)` fmt.Println() projpth, err := goinp.AskForPath(askText) if err != nil { return printXcodeScanFinishedWithError("Failed to read input: %s", err) } projectPath = projpth } log.Debugf("projectPath: %s", projectPath) xcodeCmd.ProjectFilePath = projectPath schemeToUse := paramXcodeScheme if schemeToUse == "" { fmt.Println() fmt.Println() log.Println("🔦 Scanning Schemes ...") schemes, err := xcodeCmd.ScanSchemes() if err != nil { return printXcodeScanFinishedWithError("Failed to scan Schemes: %s", err) } log.Debugf("schemes: %v", schemes) fmt.Println() selectedScheme, err := goinp.SelectFromStrings("Select the Scheme you usually use in Xcode", schemes) if err != nil { return printXcodeScanFinishedWithError("Failed to select Scheme: %s", err) } log.Debugf("selected scheme: %v", selectedScheme) schemeToUse = selectedScheme } xcodeCmd.Scheme = schemeToUse fmt.Println() fmt.Println() log.Println("🔦 Running an Xcode Archive, to get all the required code signing settings...") xcLog, err := xcodeCmd.GenerateLog() xcodebuildOutput = xcLog // save the xcodebuild output into a debug log file xcodebuildOutputFilePath := filepath.Join(absExportOutputDirPath, "xcodebuild-output.log") { log.Infof(" 💡 "+colorstring.Yellow("Saving xcodebuild output into file")+": %s", xcodebuildOutputFilePath) if logWriteErr := fileutil.WriteStringToFile(xcodebuildOutputFilePath, xcodebuildOutput); logWriteErr != nil { log.Errorf("Failed to save xcodebuild output into file (%s), error: %s", xcodebuildOutputFilePath, logWriteErr) } else if err != nil { log.Infoln(colorstring.Yellow("Please check the logfile (" + xcodebuildOutputFilePath + ") to see what caused the error")) log.Infoln(colorstring.Red("and make sure that you can Archive this project from Xcode!")) fmt.Println() log.Infoln("Open the project:", xcodeCmd.ProjectFilePath) log.Infoln("and Archive, using the Scheme:", xcodeCmd.Scheme) fmt.Println() } } if err != nil { return printXcodeScanFinishedWithError("Failed to run Xcode Archive: %s", err) } } codeSigningSettings, err := xcodeCmd.ScanCodeSigningSettings(xcodebuildOutput) if err != nil { return printXcodeScanFinishedWithError("Failed to detect code signing settings: %s", err) } log.Debugf("codeSigningSettings: %#v", codeSigningSettings) return exportCodeSigningFiles("Xcode", absExportOutputDirPath, codeSigningSettings) }
func main() { configs := createConfigsModelFromEnvs() fmt.Println() configs.print() if err := configs.validate(); err != nil { fail("Issue with input: %s", err) } log.Info("step determined configs:") // Detect Xcode major version xcodebuildVersion, err := utils.XcodeBuildVersion() if err != nil { fail("Failed to determin xcode version, error: %s", err) } log.Detail("- xcodebuildVersion: %s (%s)", xcodebuildVersion.XcodeVersion.String(), xcodebuildVersion.BuildVersion) xcodeMajorVersion := xcodebuildVersion.XcodeVersion.Segments()[0] if xcodeMajorVersion < minSupportedXcodeMajorVersion { fail("Invalid xcode major version (%s), should not be less then min supported: %d", xcodeMajorVersion, minSupportedXcodeMajorVersion) } // Detect xcpretty version if configs.OutputTool == "xcpretty" { if !utils.IsXcprettyInstalled() { fail(`xcpretty is not installed For xcpretty installation see: 'https://github.com/supermarin/xcpretty', or use 'xcodebuild' as 'output_tool'.`) } xcprettyVersion, err := utils.XcprettyVersion() if err != nil { fail("Failed to determin xcpretty version, error: %s", err) } log.Detail("- xcprettyVersion: %s", xcprettyVersion.String()) } // Validation CustomExportOptionsPlistContent if configs.CustomExportOptionsPlistContent != "" && xcodeMajorVersion < 7 { log.Warn("CustomExportOptionsPlistContent is set, but CustomExportOptionsPlistContent only used if xcodeMajorVersion > 6") configs.CustomExportOptionsPlistContent = "" } if configs.ForceProvisioningProfileSpecifier != "" && xcodeMajorVersion < 8 { log.Warn("ForceProvisioningProfileSpecifier is set, but ForceProvisioningProfileSpecifier only used if xcodeMajorVersion > 7") configs.ForceProvisioningProfileSpecifier = "" } if configs.ForceTeamID == "" && xcodeMajorVersion < 8 { log.Warn("ForceTeamID is set, but ForceTeamID only used if xcodeMajorVersion > 7") configs.ForceTeamID = "" } if configs.ForceProvisioningProfileSpecifier != "" && configs.ForceProvisioningProfile != "" { log.Warn("both ForceProvisioningProfileSpecifier and ForceProvisioningProfile are set, using ForceProvisioningProfileSpecifier") configs.ForceProvisioningProfile = "" } fmt.Println() // abs out dir pth absOutputDir, err := pathutil.AbsPath(configs.OutputDir) if err != nil { fail("Failed to expand OutputDir (%s), error: %s", configs.OutputDir, err) } configs.OutputDir = absOutputDir if exist, err := pathutil.IsPathExists(configs.OutputDir); err != nil { fail("Failed to check if OutputDir exist, error: %s", err) } else if !exist { if err := os.MkdirAll(configs.OutputDir, 0777); err != nil { fail("Failed to create OutputDir (%s), error: %s", configs.OutputDir, err) } } // output files tmpArchiveDir, err := pathutil.NormalizedOSTempDirPath("__archive__") if err != nil { fail("Failed to create temp dir for archives, error: %s", err) } tmpArchivePath := filepath.Join(tmpArchiveDir, configs.ArtifactName+".xcarchive") appPath := filepath.Join(configs.OutputDir, configs.ArtifactName+".app") ipaPath := filepath.Join(configs.OutputDir, configs.ArtifactName+".ipa") exportOptionsPath := filepath.Join(configs.OutputDir, "export_options.plist") rawXcodebuildOutputLogPath := filepath.Join(configs.OutputDir, "raw-xcodebuild-output.log") dsymZipPath := filepath.Join(configs.OutputDir, configs.ArtifactName+".dSYM.zip") archiveZipPath := filepath.Join(configs.OutputDir, configs.ArtifactName+".xcarchive.zip") ideDistributionLogsZipPath := filepath.Join(configs.OutputDir, "xcodebuild.xcdistributionlogs.zip") // cleanup filesToCleanup := []string{ appPath, ipaPath, exportOptionsPath, rawXcodebuildOutputLogPath, dsymZipPath, archiveZipPath, ideDistributionLogsZipPath, } for _, pth := range filesToCleanup { if exist, err := pathutil.IsPathExists(pth); err != nil { fail("Failed to check if path (%s) exist, error: %s", pth, err) } else if exist { if err := os.RemoveAll(pth); err != nil { fail("Failed to remove path (%s), error: %s", pth, err) } } } // // Create the Archive with Xcode Command Line tools log.Info("Create the Archive ...") fmt.Println() isWorkspace := false ext := filepath.Ext(configs.ProjectPath) if ext == ".xcodeproj" { isWorkspace = false } else if ext == ".xcworkspace" { isWorkspace = true } else { fail("Project file extension should be .xcodeproj or .xcworkspace, but got: %s", ext) } archiveCmd := xcodebuild.NewArchiveCommand(configs.ProjectPath, isWorkspace) archiveCmd.SetScheme(configs.Scheme) archiveCmd.SetConfiguration(configs.Configuration) if configs.ForceTeamID != "" { log.Detail("Forcing Development Team: %s", configs.ForceTeamID) archiveCmd.SetForceDevelopmentTeam(configs.ForceTeamID) } if configs.ForceProvisioningProfileSpecifier != "" { log.Detail("Forcing Provisioning Profile Specifier: %s", configs.ForceProvisioningProfileSpecifier) archiveCmd.SetForceProvisioningProfileSpecifier(configs.ForceProvisioningProfileSpecifier) } if configs.ForceProvisioningProfile != "" { log.Detail("Forcing Provisioning Profile: %s", configs.ForceProvisioningProfile) archiveCmd.SetForceProvisioningProfile(configs.ForceProvisioningProfile) } if configs.ForceCodeSignIdentity != "" { log.Detail("Forcing Code Signing Identity: %s", configs.ForceCodeSignIdentity) archiveCmd.SetForceCodeSignIdentity(configs.ForceCodeSignIdentity) } if configs.IsCleanBuild == "yes" { archiveCmd.SetCustomBuildAction("clean") } archiveCmd.SetArchivePath(tmpArchivePath) if configs.XcodebuildOptions != "" { options, err := shellquote.Split(configs.XcodebuildOptions) if err != nil { fail("Failed to shell split XcodebuildOptions (%s), error: %s", configs.XcodebuildOptions) } archiveCmd.SetCustomOptions(options) } if configs.OutputTool == "xcpretty" { xcprettyCmd := xcpretty.New(archiveCmd) logWithTimestamp(colorstring.Green, "$ %s", xcprettyCmd.PrintableCmd()) fmt.Println() if rawXcodebuildOut, err := xcprettyCmd.Run(); err != nil { if err := utils.ExportOutputFileContent(rawXcodebuildOut, rawXcodebuildOutputLogPath, bitriseXcodeRawResultTextEnvKey); err != nil { log.Warn("Failed to export %s, error: %s", bitriseXcodeRawResultTextEnvKey, err) } else { log.Warn(`If you can't find the reason of the error in the log, please check the raw-xcodebuild-output.log The log file is stored in $BITRISE_DEPLOY_DIR, and its full path is available in the $BITRISE_XCODE_RAW_RESULT_TEXT_PATH environment variable`) } fail("Archive failed, error: %s", err) } } else { logWithTimestamp(colorstring.Green, "$ %s", archiveCmd.PrintableCmd()) fmt.Println() if err := archiveCmd.Run(); err != nil { fail("Archive failed, error: %s", err) } } fmt.Println() // Ensure xcarchive exists if exist, err := pathutil.IsPathExists(tmpArchivePath); err != nil { fail("Failed to check if archive exist, error: %s", err) } else if !exist { fail("No archive generated at: %s", tmpArchivePath) } // // Exporting the ipa with Xcode Command Line tools /* You'll get a "Error Domain=IDEDistributionErrorDomain Code=14 "No applicable devices found."" error if $GEM_HOME is set and the project's directory includes a Gemfile - to fix this we'll unset GEM_HOME as that's not required for xcodebuild anyway. This probably fixes the RVM issue too, but that still should be tested. See also: - http://stackoverflow.com/questions/33041109/xcodebuild-no-applicable-devices-found-when-exporting-archive - https://gist.github.com/claybridges/cea5d4afd24eda268164 */ log.Info("Exporting ipa from the archive...") fmt.Println() envsToUnset := []string{"GEM_HOME", "GEM_PATH", "RUBYLIB", "RUBYOPT", "BUNDLE_BIN_PATH", "_ORIGINAL_GEM_PATH", "BUNDLE_GEMFILE"} for _, key := range envsToUnset { if err := os.Unsetenv(key); err != nil { fail("Failed to unset (%s), error: %s", key, err) } } if xcodeMajorVersion == 6 || configs.UseDeprecatedExport == "yes" { log.Detail("Using legacy export") /* Get the name of the profile which was used for creating the archive --> Search for embedded.mobileprovision in the xcarchive. It should contain a .app folder in the xcarchive folder under the Products/Applications folder */ embeddedProfilePth, err := xcarchive.EmbeddedMobileProvisionPth(tmpArchivePath) if err != nil { fail("Failed to get embedded profile path, error: %s", err) } provProfile, err := provisioningprofile.NewFromFile(embeddedProfilePth) if err != nil { fail("Failed to create provisioning profile model, error: %s", err) } if provProfile.Name == nil { fail("Profile name empty") } legacyExportCmd := xcodebuild.NewLegacyExportCommand() legacyExportCmd.SetExportFormat("ipa") legacyExportCmd.SetArchivePath(tmpArchivePath) legacyExportCmd.SetExportPath(ipaPath) legacyExportCmd.SetExportProvisioningProfileName(*provProfile.Name) if configs.OutputTool == "xcpretty" { xcprettyCmd := xcpretty.New(legacyExportCmd) logWithTimestamp(colorstring.Green, xcprettyCmd.PrintableCmd()) fmt.Println() if rawXcodebuildOut, err := xcprettyCmd.Run(); err != nil { if err := utils.ExportOutputFileContent(rawXcodebuildOut, rawXcodebuildOutputLogPath, bitriseXcodeRawResultTextEnvKey); err != nil { log.Warn("Failed to export %s, error: %s", bitriseXcodeRawResultTextEnvKey, err) } else { log.Warn(`If you can't find the reason of the error in the log, please check the raw-xcodebuild-output.log The log file is stored in $BITRISE_DEPLOY_DIR, and its full path is available in the $BITRISE_XCODE_RAW_RESULT_TEXT_PATH environment variable`) } fail("Export failed, error: %s", err) } } else { logWithTimestamp(colorstring.Green, legacyExportCmd.PrintableCmd()) fmt.Println() if err := legacyExportCmd.Run(); err != nil { fail("Export failed, error: %s", err) } } } else { log.Detail("Using export options") if configs.CustomExportOptionsPlistContent != "" { log.Detail("Custom export options content provided:") fmt.Println(configs.CustomExportOptionsPlistContent) if err := fileutil.WriteStringToFile(exportOptionsPath, configs.CustomExportOptionsPlistContent); err != nil { fail("Failed to write export options to file, error: %s", err) } } else { log.Detail("Generating export options") var method exportoptions.Method if configs.ExportMethod == "auto-detect" { log.Detail("auto-detect export method, based on embedded profile") embeddedProfilePth, err := xcarchive.EmbeddedMobileProvisionPth(tmpArchivePath) if err != nil { fail("Failed to get embedded profile path, error: %s", err) } provProfile, err := provisioningprofile.NewFromFile(embeddedProfilePth) if err != nil { fail("Failed to create provisioning profile model, error: %s", err) } method = provProfile.GetExportMethod() log.Detail("detected export method: %s", method) } else { log.Detail("using export-method input: %s", configs.ExportMethod) parsedMethod, err := exportoptions.ParseMethod(configs.ExportMethod) if err != nil { fail("Failed to parse export options, error: %s", err) } method = parsedMethod } var exportOpts exportoptions.ExportOptions if method == exportoptions.MethodAppStore { options := exportoptions.NewAppStoreOptions() options.UploadBitcode = (configs.UploadBitcode == "yes") options.TeamID = configs.TeamID exportOpts = options } else { options := exportoptions.NewNonAppStoreOptions(method) options.CompileBitcode = (configs.CompileBitcode == "yes") options.TeamID = configs.TeamID exportOpts = options } log.Detail("generated export options content:") fmt.Println() fmt.Println(exportOpts.String()) if err = exportOpts.WriteToFile(exportOptionsPath); err != nil { fail("Failed to write export options to file, error: %s", err) } } fmt.Println() tmpDir, err := pathutil.NormalizedOSTempDirPath("__export__") if err != nil { fail("Failed to create tmp dir, error: %s", err) } exportCmd := xcodebuild.NewExportCommand() exportCmd.SetArchivePath(tmpArchivePath) exportCmd.SetExportDir(tmpDir) exportCmd.SetExportOptionsPlist(exportOptionsPath) if configs.OutputTool == "xcpretty" { xcprettyCmd := xcpretty.New(exportCmd) logWithTimestamp(colorstring.Green, xcprettyCmd.PrintableCmd()) fmt.Println() if xcodebuildOut, err := xcprettyCmd.Run(); err != nil { // xcodebuild raw output if err := utils.ExportOutputFileContent(xcodebuildOut, rawXcodebuildOutputLogPath, bitriseXcodeRawResultTextEnvKey); err != nil { log.Warn("Failed to export %s, error: %s", bitriseXcodeRawResultTextEnvKey, err) } else { log.Warn(`If you can't find the reason of the error in the log, please check the raw-xcodebuild-output.log The log file is stored in $BITRISE_DEPLOY_DIR, and its full path is available in the $BITRISE_XCODE_RAW_RESULT_TEXT_PATH environment variable`) } // xcdistributionlogs if logsDirPth, err := findIDEDistrubutionLogsPath(xcodebuildOut); err != nil { log.Warn("Failed to find xcdistributionlogs, error: %s", err) } else if err := utils.ExportOutputDirAsZip(logsDirPth, ideDistributionLogsZipPath, bitriseIDEDistributionLogsPthEnvKey); err != nil { log.Warn("Failed to export %s, error: %s", bitriseIDEDistributionLogsPthEnvKey, err) } else { log.Warn(`Also please check the xcdistributionlogs The logs directory is stored in $BITRISE_DEPLOY_DIR, and its full path is available in the $BITRISE_IDEDISTRIBUTION_LOGS_PATH environment variable`) } fail("Export failed, error: %s", err) } } else { logWithTimestamp(colorstring.Green, exportCmd.PrintableCmd()) fmt.Println() if xcodebuildOut, err := exportCmd.RunAndReturnOutput(); err != nil { // xcdistributionlogs if logsDirPth, err := findIDEDistrubutionLogsPath(xcodebuildOut); err != nil { log.Warn("Failed to find xcdistributionlogs, error: %s", err) } else if err := utils.ExportOutputDirAsZip(logsDirPth, ideDistributionLogsZipPath, bitriseIDEDistributionLogsPthEnvKey); err != nil { log.Warn("Failed to export %s, error: %s", bitriseIDEDistributionLogsPthEnvKey, err) } else { log.Warn(`If you can't find the reason of the error in the log, please check the xcdistributionlogs The logs directory is stored in $BITRISE_DEPLOY_DIR, and its full path is available in the $BITRISE_IDEDISTRIBUTION_LOGS_PATH environment variable`) } fail("Export failed, error: %s", err) } } // Search for ipa pattern := filepath.Join(tmpDir, "*.ipa") ipas, err := filepath.Glob(pattern) if err != nil { fail("Failed to collect ipa files, error: %s", err) } if len(ipas) == 0 { fail("No ipa found with pattern: %s", pattern) } else if len(ipas) == 1 { if err := cmdex.CopyFile(ipas[0], ipaPath); err != nil { fail("Failed to copy (%s) -> (%s), error: %s", ipas[0], ipaPath, err) } } else { log.Warn("More than 1 .ipa file found") for _, ipa := range ipas { base := filepath.Base(ipa) deployPth := filepath.Join(configs.OutputDir, base) if err := cmdex.CopyFile(ipa, deployPth); err != nil { fail("Failed to copy (%s) -> (%s), error: %s", ipas[0], ipaPath, err) } ipaPath = ipa } } } log.Info("Exporting outputs...") // // Export outputs // Export .xcarchive fmt.Println() if err := utils.ExportOutputDir(tmpArchivePath, tmpArchivePath, bitriseXCArchivePthEnvKey); err != nil { fail("Failed to export %s, error: %s", bitriseXCArchivePthEnvKey, err) } log.Done("The xcarchive path is now available in the Environment Variable: %s (value: %s)", bitriseXCArchivePthEnvKey, tmpArchivePath) if configs.IsExportXcarchiveZip == "yes" { if err := utils.ExportOutputDirAsZip(tmpArchivePath, archiveZipPath, bitriseXCArchiveZipPthEnvKey); err != nil { fail("Failed to export %s, error: %s", bitriseXCArchiveZipPthEnvKey, err) } log.Done("The xcarchive zip path is now available in the Environment Variable: %s (value: %s)", bitriseXCArchiveZipPthEnvKey, archiveZipPath) } // Export .app fmt.Println() exportedApp, err := xcarchive.FindApp(tmpArchivePath) if err != nil { fail("Failed to find app, error: %s", err) } if err := utils.ExportOutputDir(exportedApp, exportedApp, bitriseAppDirPthEnvKey); err != nil { fail("Failed to export %s, error: %s", bitriseAppDirPthEnvKey, err) } log.Done("The app directory is now available in the Environment Variable: %s (value: %s)", bitriseAppDirPthEnvKey, appPath) // Export .ipa fmt.Println() if err := utils.ExportOutputFile(ipaPath, ipaPath, bitriseIPAPthEnvKey); err != nil { fail("Failed to export %s, error: %s", bitriseIPAPthEnvKey, err) } log.Done("The ipa path is now available in the Environment Variable: %s (value: %s)", bitriseIPAPthEnvKey, ipaPath) // Export .dSYMs fmt.Println() appDSYM, frameworkDSYMs, err := xcarchive.FindDSYMs(tmpArchivePath) if err != nil { fail("Failed to export dsyms, error: %s", err) } dsymDir, err := pathutil.NormalizedOSTempDirPath("__dsyms__") if err != nil { fail("Failed to create tmp dir, error: %s", err) } if err := cmdex.CopyDir(appDSYM, dsymDir, false); err != nil { fail("Failed to copy (%s) -> (%s), error: %s", appDSYM, dsymDir, err) } if configs.ExportAllDsyms == "yes" { for _, dsym := range frameworkDSYMs { if err := cmdex.CopyDir(dsym, dsymDir, false); err != nil { fail("Failed to copy (%s) -> (%s), error: %s", dsym, dsymDir, err) } } } if err := utils.ExportOutputDir(dsymDir, dsymDir, bitriseDSYMDirPthEnvKey); err != nil { fail("Failed to export %s, error: %s", bitriseDSYMDirPthEnvKey, err) } log.Done("The dSYM dir path is now available in the Environment Variable: %s (value: %s)", bitriseDSYMDirPthEnvKey, dsymDir) if err := utils.ExportOutputDirAsZip(dsymDir, dsymZipPath, bitriseDSYMPthEnvKey); err != nil { fail("Failed to export %s, error: %s", bitriseDSYMPthEnvKey, err) } log.Done("The dSYM zip path is now available in the Environment Variable: %s (value: %s)", bitriseDSYMPthEnvKey, dsymZipPath) }