-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Install bundler if a Gemfile.lock is present, use the version specified in the Gemfile.lock (by BUNDLED WITH) * Specify bundler version in `bundle install` command. * Update imports due to org migration * Bump bitrise.yml version
- Loading branch information
Showing
41 changed files
with
357 additions
and
9,242 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,20 @@ | ||
|
||
[[constraint]] | ||
branch = "master" | ||
name = "github.com/bitrise-io/go-steputils" | ||
|
||
[[constraint]] | ||
branch = "master" | ||
name = "github.com/bitrise-io/go-utils" | ||
|
||
[[constraint]] | ||
branch = "master" | ||
name = "github.com/kballard/go-shellquote" | ||
name = "github.com/bitrise-steplib/steps-deploy-to-itunesconnect-deliver" | ||
|
||
[[constraint]] | ||
name = "github.com/stretchr/testify" | ||
branch = "master" | ||
name = "github.com/kballard/go-shellquote" | ||
|
||
[prune] | ||
go-tests = true | ||
unused-packages = true | ||
|
||
[[constraint]] | ||
branch = "master" | ||
name = "github.com/bitrise-tools/go-steputils" | ||
|
||
[[constraint]] | ||
branch = "master" | ||
name = "github.com/bitrise-io/steps-deploy-to-itunesconnect-deliver" |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/bitrise-io/go-utils/command" | ||
"github.com/bitrise-io/go-utils/command/rubycommand" | ||
) | ||
|
||
func getInstallBundlerCommand(gemfileLockVersion gemVersion) (*command.Model, error) { | ||
installBundlerCmdParams := []string{"gem", "install", "bundler", "--force", "--no-document"} | ||
if gemfileLockVersion.found { | ||
installBundlerCmdParams = append(installBundlerCmdParams, []string{"-v", gemfileLockVersion.version}...) | ||
} | ||
|
||
return command.NewFromSlice(installBundlerCmdParams) | ||
} | ||
|
||
func getBundleInstallCommand(gemfileLockVersion gemVersion) (*command.Model, error) { | ||
bundleInstallCmdParams := []string{"bundle"} | ||
if gemfileLockVersion.found { | ||
bundleInstallCmdParams = append(bundleInstallCmdParams, "_"+gemfileLockVersion.version+"_") | ||
} | ||
bundleInstallCmdParams = append(bundleInstallCmdParams, []string{"install", "--jobs", "20", "--retry", "5"}...) | ||
|
||
return rubycommand.NewFromSlice(bundleInstallCmdParams) | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"path/filepath" | ||
"regexp" | ||
"strings" | ||
|
||
"github.com/bitrise-io/go-utils/fileutil" | ||
"github.com/bitrise-io/go-utils/log" | ||
"github.com/bitrise-io/go-utils/pathutil" | ||
) | ||
|
||
type gemVersion struct { | ||
version string | ||
found bool | ||
} | ||
|
||
type gemVersions struct { | ||
fastlane, bundler gemVersion | ||
} | ||
|
||
func parseGemfileLock(searchDir string) (gemVersions, error) { | ||
gemfileLockPth := filepath.Join(searchDir, "Gemfile.lock") | ||
log.Printf("Checking Gemfile.lock (%s) for fastlane and bundler gem", gemfileLockPth) | ||
|
||
if exist, err := pathutil.IsPathExists(gemfileLockPth); err != nil { | ||
return gemVersions{}, fmt.Errorf("failed to check if Gemfile.lock exist at (%s), error: %s", gemfileLockPth, err) | ||
} else if !exist { | ||
log.Printf("Gemfile.lock does not exist") | ||
return gemVersions{}, nil | ||
} | ||
|
||
content, err := fileutil.ReadStringFromFile(gemfileLockPth) | ||
if err != nil { | ||
return gemVersions{}, err | ||
} | ||
|
||
var gemVersions gemVersions | ||
|
||
gemVersions.fastlane = parseFastlaneVersion(content) | ||
if gemVersions.fastlane.found { | ||
log.Infof("Gemfile.lock defined fastlane version: %s", gemVersions.fastlane.version) | ||
} else { | ||
log.Infof("No fastlane version defined in Gemfile.lock") | ||
} | ||
|
||
gemVersions.bundler = parseBundlerVersion(content) | ||
if gemVersions.bundler.found { | ||
log.Infof("Gemfile.lock defined bundler version: %s", gemVersions.bundler.version) | ||
} else { | ||
log.Infof("No bundler version defined in Gemfile.lock") | ||
} | ||
|
||
return gemVersions, nil | ||
} | ||
|
||
func parseFastlaneVersion(gemfileLockContent string) gemVersion { | ||
return parseGemVersion("fastlane", gemfileLockContent) | ||
} | ||
|
||
func parseGemVersion(gemName string, content string) gemVersion { | ||
relevantLines := []string{} | ||
lines := strings.Split(content, "\n") | ||
|
||
specsStart := false | ||
for _, line := range lines { | ||
if strings.Contains(line, "specs:") { | ||
specsStart = true | ||
} | ||
|
||
trimmed := strings.Trim(line, " ") | ||
if trimmed == "" { | ||
specsStart = false | ||
} | ||
|
||
if specsStart { | ||
relevantLines = append(relevantLines, line) | ||
} | ||
} | ||
|
||
// fastlane (1.109.0) | ||
exp := regexp.MustCompile(fmt.Sprintf(`^%s \((.+)\)`, regexp.QuoteMeta(gemName))) | ||
for _, line := range relevantLines { | ||
match := exp.FindStringSubmatch(strings.TrimSpace(line)) | ||
if len(match) == 2 { | ||
return gemVersion{ | ||
version: match[1], | ||
found: true, | ||
} | ||
} | ||
} | ||
|
||
return gemVersion{} | ||
} | ||
|
||
func parseBundlerVersion(gemfileLockContent string) gemVersion { | ||
/* | ||
BUNDLED WITH | ||
1.17.1 | ||
*/ | ||
bundlerRegexp := regexp.MustCompile(`(?m)^BUNDLED WITH\n\s+(\S+)`) | ||
match := bundlerRegexp.FindStringSubmatch(gemfileLockContent) | ||
if match == nil { | ||
log.Warnf("failed to parse bundler version in Gemfile.lock: %s", gemfileLockContent) | ||
fmt.Println() | ||
return gemVersion{} | ||
} | ||
if len(match) != 2 { | ||
log.Warnf("unexpected regexp match: %v", match) | ||
return gemVersion{} | ||
} | ||
|
||
return gemVersion{ | ||
version: match[1], | ||
found: true, | ||
} | ||
} |
This file contains 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
Oops, something went wrong.