Skip to content

Commit

Permalink
Release 1.2.0 (#232)
Browse files Browse the repository at this point in the history
* FIX: Github Marketplace action not picking up the latest release automatically [#189]
* FIX: Calling variants setup on M1 mac uses M1 unsupported gems in Gemfile [#208]
* FIX: Variants setup on M1 mac does not automatically link variants.xcconfig to xcodeproject [#209]
* FIX: Some signing configurations not automatically set in Xcode 14 [#214]

* REFACTOR: Signing configuration is updated not only during `setup` but also during `switch` [#215]
* REFACTOR: Items in `variants.xcconfig` should be sorted alphabetically [#219]

* FEATURE: Ability to add a `postSwitch` command/script, both globally or variant specific [#221]
* FEATURE:  Add ability to override app name per variant [#216]
* FEATURE: Expose configuration keys as static variables in swift [#125]
 
---------
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: romanhu-bb <93975733+romanhu-bb@users.noreply.github.com>
Co-authored-by: Aksay Pudukudi Kandhadai (BB) <akshayp@backbase.com>
Co-authored-by: Divine Dube <dubedivine@gmail.com>
Co-authored-by: Nour Sandid <nour@backbase.com>
Co-authored-by: noursandidb <92526468+noursandidb@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Gabriel Minucci <gabriel@minucci.com.br>
Co-authored-by: Alex Kuziaev <theperfectprogrammer@gmail.com>
  • Loading branch information
arthurpalves authored Oct 19, 2023
1 parent cdc4695 commit 096ca0d
Show file tree
Hide file tree
Showing 127 changed files with 2,862 additions and 1,087 deletions.
36 changes: 26 additions & 10 deletions .github/ISSUE_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,34 @@
---
name: Bug
about: Issue a bug
title: Bug:
labels: bug
name: Bug report
about: Create a report to help us improve
title: ''
labels: 'bug'
assignees: ''

---

## Basic information
### Environment ###
**Variants:**
- Way of installation: [e.g. Homebrew, Make, SPM]
- Version [e.g. 1.1.13]

Variants version:
macOS version:
Swift version:
**Your machine:**
- OS: [e.g. MacOS, Windows]
- Processor [e.g. Intel, Apple Silicon]

## Bug/Issue
**Project's platform:**
- Platform: [e.g. iOS, Android]

Describe the bug you've encountered here.
### Describe the bug ###
A clear and concise description of what the bug is.

**Steps to reproduce**
1. Go to '...'
2. Execute command '....'
3. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Logs**
If applicable, add error logs.
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Slack Variants channel
url: https://backbase.slack.com/archives/s-variants/
about: Please ask your questions here.
11 changes: 7 additions & 4 deletions .github/workflows/secrets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ jobs:
gitleaks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: wget
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Fetch .rules.toml
uses: wei/wget@v1
with:
args: -O .rules.toml https://raw.githubusercontent.com/fnxpt/gitleaks-action/rules/.rules.toml
- name: gitleaks-action
- name: Gitleaks
uses: gitleaks/gitleaks-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE}}
GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE }}
GITLEAKS_CONFIG: .rules.toml
21 changes: 14 additions & 7 deletions Dangerfile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,20 @@ var bigPRThreshold = 500

let swiftFilesWithoutCopyright = changedFiles.filter {
$0.fileType == .swift
&& !danger.utils.readFile($0).contains(
"""
//
// Variants
//
// Copyright (c) Backbase B.V. - https://www.backbase.com
""")
&& (
!danger.utils.readFile($0).contains(
"""
//
// Variants
"""
)

|| !danger.utils.readFile($0).contains(
"""
// Copyright (c) Backbase B.V. - https://www.backbase.com
"""
)
)
}

if swiftFilesWithoutCopyright.count > 0 {
Expand Down
11 changes: 7 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ GEM
specs:
CFPropertyList (3.0.5)
rexml
activesupport (7.0.4)
activesupport (7.0.4.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
Expand All @@ -12,15 +12,17 @@ GEM
claide (1.1.0)
clamp (1.3.2)
colored2 (3.1.2)
concurrent-ruby (1.1.10)
concurrent-ruby (1.2.0)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
minitest (5.16.3)
minitest (5.17.0)
nanaimo (0.3.0)
nokogiri (1.13.8-arm64-darwin)
racc (~> 1.4)
nokogiri (1.13.8-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.13.8-x86_64-linux)
racc (~> 1.4)
racc (1.6.0)
rexml (3.2.5)
slather (2.7.2)
Expand All @@ -29,7 +31,7 @@ GEM
clamp (~> 1.3)
nokogiri (~> 1.12)
xcodeproj (~> 1.21)
tzinfo (2.0.5)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
xcodeproj (1.22.0)
CFPropertyList (>= 2.3.3, < 4.0)
Expand All @@ -42,6 +44,7 @@ GEM
PLATFORMS
arm64-darwin-21
x86_64-darwin-21
x86_64-linux

DEPENDENCIES
nokogiri (>= 1.13.2)
Expand Down
2 changes: 1 addition & 1 deletion Sources/Variants/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct Variants: ParsableCommand {
static var configuration = CommandConfiguration(
commandName: "variants",
abstract: "A command-line tool to setup deployment variants and working CI/CD setup",
version: "1.1.3",
version: "1.2.0",
subcommands: [
Initializer.self,
Setup.self,
Expand Down
17 changes: 12 additions & 5 deletions Sources/VariantsCore/Custom Types/Project/iOSProject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ class iOSProject: Project {
} catch {
throw RuntimeError("Unable to switch variants - Check your YAML spec")
}

if let postSwitchScript = desiredVariant.postSwitchScript {
try self.runPostSwitchScript(postSwitchScript)
}
}

override func list(spec: String) throws -> [Variant] {
Expand All @@ -60,11 +64,7 @@ class iOSProject: Project {

// MARK: - Private

private func loadConfiguration(_ path: String?) throws -> iOSConfiguration? {
guard let path = path else {
throw ValidationError("Error: Use '-s' to specify the configuration file")
}

private func loadConfiguration(_ path: String) throws -> iOSConfiguration? {
let configurationPath = Path(path)
guard !configurationPath.isDirectory else {
throw ValidationError("Error: \(configurationPath) is a directory path")
Expand Down Expand Up @@ -109,6 +109,11 @@ class iOSProject: Project {
try parametersFactory.createMatchFile(using: variant, target: namedTarget.value)
}
}

private func runPostSwitchScript(_ script: String) throws {
guard let outputString = try Bash("bash", arguments: "-c", script).capture() else { return }
Logger.shared.logInfo(item: outputString)
}

private func createVariants(with configuration: iOSConfiguration, spec: String) throws {
try configuration.targets
Expand Down Expand Up @@ -233,3 +238,5 @@ class iOSProject: Project {
private let configFactory: XCFactory
private let parametersFactory: ParametersFactory
}

// swiftlint:enable type_name
3 changes: 2 additions & 1 deletion Sources/VariantsCore/Factory/ProjectFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ struct ProjectFactory {
templatePath: Path("/ios/variants-template.yml"),
userInputSource: interactiveShell,
userInput: { readLine() }
)
),
configFactory: XCConfigFactory(logger: logger)
)
case .android:
return AndroidProject(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,46 +9,44 @@ import Foundation
import PathKit
import Stencil

class SecretsFactory {
class VariantsFileFactory {
init(logger: Logger = Logger(verbose: false)) {
self.logger = logger
}

/// Updates `Variants.swift` with `Variants.Secrets` containing
/// encrypted static variables
/// Updates `Variants.swift` with `Variants.Secrets` containing encrypted static variables
/// and `Variants.ConfigurationValueKey` as keys for custom configuration values
/// - Parameters:
/// - configFilePath: Path to XCConfig file
/// - variant: Chosen variant, as seen in `variants.yml`
func updateSecrets(with configFilePath: Path, variant: iOSVariant) {
func updateVariantsFile(with configFilePath: Path, variant: iOSVariant) {
do {
let path = try TemplateDirectory().path
guard let variantsGybTemplatePath = try? path.safeJoin(path: Path("ios/"))
else { return }
let secrets = variant.custom?.secrets() ?? []
let configurationValues = variant.custom?.configurationValues() ?? []
let context = [
"secrets": secrets,
"configurationValues": configurationValues
] as [String: Any]

if let secrets = variant.custom?.envVars() {
let context = [
"secrets": secrets
] as [String: Any]

let environment = Environment(loader: FileSystemLoader(paths: [variantsGybTemplatePath.absolute()]))
let rendered = try environment.renderTemplate(name: StaticPath.Template.variantsSwiftGybFileName,
context: context)

// Replace multiple empty lines by one only
let lines = rendered.split(whereSeparator: \.isNewline)
let content = lines.joined(separator: "\n")

try write(Data(content.utf8), using: configFilePath.parent().absolute())

let variantsGybFile = try configFilePath.parent().absolute()
.safeJoin(path: Path(StaticPath.Xcode.variantsGybFileName))
try variantsGybFile.delete()
}
let environment = Environment(loader: FileSystemLoader(paths: [variantsGybTemplatePath.absolute()]))
let rendered = try environment.renderTemplate(name: StaticPath.Template.variantsSwiftGybFileName,
context: context)
// Replace multiple empty lines by one only
let lines = rendered.split(whereSeparator: \.isNewline)
let content = lines.joined(separator: "\n")

try write(Data(content.utf8), using: configFilePath.parent().absolute())
let variantsGybFile = try configFilePath.parent().absolute()
.safeJoin(path: Path(StaticPath.Xcode.variantsGybFileName))
try variantsGybFile.delete()
} catch {
let variantsFile = try? configFilePath.parent().absolute()
.safeJoin(path: Path(StaticPath.Xcode.variantsFileName))
logger.logWarning(item: """
Something went wrong while generating 'Variants.Secrets' in '\(variantsFile ?? "Variants.swift")'
Something went wrong while generating '\(variantsFile ?? "Variants.swift")'
""")
dump(error)
}
Expand Down Expand Up @@ -96,7 +94,7 @@ class SecretsFactory {
}

fileprivate extension Sequence where Iterator.Element == CustomProperty {
func envVars() -> [CustomProperty] {
func secrets() -> [CustomProperty] {
return self
.filter({ $0.destination == .project && $0.isEnvironmentVariable })
.map { (property) -> CustomProperty in
Expand All @@ -106,7 +104,7 @@ fileprivate extension Sequence where Iterator.Element == CustomProperty {
}
}

func literal() -> [CustomProperty] {
func configurationValues() -> [CustomProperty] {
return self
.filter({ $0.destination == .project && !$0.isEnvironmentVariable })
}
Expand Down
Loading

0 comments on commit 096ca0d

Please sign in to comment.