Skip to content

Commit

Permalink
Merge pull request #523 from nimblehq/release/4.8.0
Browse files Browse the repository at this point in the history
Release - 4.8.0
  • Loading branch information
blyscuit authored Sep 13, 2023
2 parents 5e7d284 + 3449d97 commit aa841f7
Show file tree
Hide file tree
Showing 19 changed files with 400 additions and 265 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/deploy_app_store.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,8 @@ jobs:
${{ env.DSYM_OUTPUT_PATH }}
env:
TAG_TYPE: App_Store

- name: Remove keychain
if: ${{ always() }}
run: bundle exec fastlane removeKeychain
continue-on-error: true
5 changes: 5 additions & 0 deletions .github/workflows/deploy_production_firebase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,8 @@ jobs:
${{ env.DSYM_OUTPUT_PATH }}
env:
TAG_TYPE: Production_Firebase

- name: Remove keychain
if: ${{ always() }}
run: bundle exec fastlane removeKeychain
continue-on-error: true
5 changes: 5 additions & 0 deletions .github/workflows/deploy_staging_firebase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,8 @@ jobs:
${{ env.DSYM_OUTPUT_PATH }}
env:
TAG_TYPE: Staging_Firebase

- name: Remove keychain
if: ${{ always() }}
run: bundle exec fastlane removeKeychain
continue-on-error: true
5 changes: 5 additions & 0 deletions .github/workflows/test_upload_build_to_firebase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,8 @@ jobs:
${{ env.DSYM_OUTPUT_PATH }}
env:
TAG_TYPE: Staging_Firebase

- name: Remove keychain
if: ${{ always() }}
run: bundle exec fastlane removeKeychain
continue-on-error: true
7 changes: 6 additions & 1 deletion .github/workflows/test_upload_build_to_test_flight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
run: sh make.sh --bundle-id co.nimblehq.ios.templates --bundle-id-staging co.nimblehq.ios.templates.staging --project-name TemplateApp --interface UIKit

- name: Start Setup Script for Template App TestFlight Upload
run: sh set_up_test_testflight.sh
run: cat Scripts/Swift/SetUpTestTestFlight.swift Scripts/Swift/Extensions/FileManager+Utils.swift | swift -
env:
MATCH_REPO: ${{ secrets.MATCH_REPO }}
API_KEY_ID: ${{ secrets.API_KEY_ID }}
Expand All @@ -70,3 +70,8 @@ jobs:
ISSUER_ID: ${{ secrets.ISSUER_ID }}
SKIP_FIREBASE_DSYM: "true"
BUMP_APP_STORE_BUILD_NUMBER: "true"

- name: Remove keychain
if: ${{ always() }}
run: bundle exec fastlane removeKeychain
continue-on-error: true
26 changes: 25 additions & 1 deletion Scripts/Swift/Extensions/FileManager+Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,28 @@ extension FileManager {
}
}

func copy(file: String, to destination: String) {
let currentDirectory = currentDirectoryPath
do {
try copyItem(
atPath: "\(currentDirectory)/\(file)",
toPath:"\(currentDirectory)/\(destination)"
)
} catch {
print("Error \(error)")
}
}

func createFile(name: String, at directory: String) {
let currentDirectory = currentDirectoryPath
do {
try createDirectory(atPath: "\(currentDirectory)/\(directory)", withIntermediateDirectories: true, attributes: nil)
} catch {
print("Error \(error)")
}
createFile(atPath: "\(currentDirectory)\(directory)\(name)", contents: nil)
}

func removeItems(in directory: String) {
let currentDirectory = currentDirectoryPath
do {
Expand Down Expand Up @@ -63,9 +85,11 @@ extension FileManager {
if let enumerator = enumerator(
at: url,
includingPropertiesForKeys: [.isRegularFileKey],
options: [.skipsHiddenFiles, .skipsPackageDescendants]
options: [.skipsPackageDescendants]
) {
let hiddenFolderRegex = "\(directory.replacingOccurrences(of: "/", with: "\\/"))\\/\\..*\\/"
for case let fileURL as URL in enumerator {
guard !(fileURL.relativePath ~= hiddenFolderRegex) else { continue }
let fileAttributes = try? fileURL.resourceValues(forKeys:[.isRegularFileKey])
guard fileAttributes?.isRegularFile ?? false else { continue }
files.append(fileURL)
Expand Down
8 changes: 8 additions & 0 deletions Scripts/Swift/Extensions/String+Utils.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
extension String {

static func ~= (lhs: String, rhs: String) -> Bool {
guard let regex = try? NSRegularExpression(pattern: rhs) else { return false }
let range = NSRange(location: 0, length: lhs.utf16.count)
return regex.firstMatch(in: lhs, options: [], range: range) != nil
}
}
89 changes: 45 additions & 44 deletions Scripts/Swift/SetUpCICDService.swift
Original file line number Diff line number Diff line change
@@ -1,50 +1,51 @@
#!/usr/bin/swift

import Foundation

let fileManager = FileManager.default

enum CICDService {
case github, bitrise, codemagic, later

init?(_ name: String) {
switch name.lowercased() {
case "g", "github":
self = .github
case "b", "bitrise":
self = .bitrise
case "c", "codemagic":
self = .codemagic
case "l", "later":
self = .later
default:
return nil
struct SetUpCICDService {

enum CICDService {

case github, bitrise, codemagic, later

init?(_ name: String) {
switch name.lowercased() {
case "g", "github":
self = .github
case "b", "bitrise":
self = .bitrise
case "c", "codemagic":
self = .codemagic
case "l", "later":
self = .later
default:
return nil
}
}
}
}

var service: CICDService? = nil
private let fileManager = FileManager.default

while service == nil {
print("Which CI/CD service do you use (Can be edited later) [(g)ithub/(b)itrise/(c)odemagic/(l)ater]: ")
service = CICDService(readLine() ?? "")
}
func perform() {
var service: CICDService? = nil
while service == nil {
print("Which CI/CD service do you use (Can be edited later) [(g)ithub/(b)itrise/(c)odemagic/(l)ater]: ")
service = CICDService(readLine() ?? "")
}

switch service {
case .github:
print("Setting template for Github Actions")
fileManager.removeItems(in: "bitrise.yml")
fileManager.removeItems(in: "codemagic.yaml")
case .bitrise:
print("Setting template for Bitrise")
fileManager.removeItems(in: "codemagic.yaml")
fileManager.removeItems(in: ".github/workflows")
case .codemagic:
print("Setting template for CodeMagic")
fileManager.removeItems(in: "bitrise.yml")
fileManager.removeItems(in: ".github/workflows")
case .later, .none:
print("You can manually setup the template later.")
}
switch service {
case .github:
print("Setting template for Github Actions")
fileManager.removeItems(in: "bitrise.yml")
fileManager.removeItems(in: "codemagic.yaml")
case .bitrise:
print("Setting template for Bitrise")
fileManager.removeItems(in: "codemagic.yaml")
fileManager.removeItems(in: ".github/workflows")
case .codemagic:
print("Setting template for CodeMagic")
fileManager.removeItems(in: "bitrise.yml")
fileManager.removeItems(in: ".github/workflows")
case .later, .none:
print("You can manually setup the template later.")
}

print("✅ Completed")
print("✅ Completed")
}
}
31 changes: 17 additions & 14 deletions Scripts/Swift/SetUpDeliveryConstants.swift
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
#!/usr/bin/swift
struct SetUpDeliveryConstants {

import Foundation
func perform() {
print("Do you want to set up Constants values? (Can be edited later) [Y/n]: ")

let fileManager = FileManager.default
let arg = readLine() ?? "y"

print("Do you want to set up Constants values? (Can be edited later) [Y/n]: ")

var arg = readLine() ?? "y"

switch arg.lowercased() {
case "y", "yes", "":
let error = try safeShell("open -a Xcode fastlane/Constants/Constant.swift")
guard let error = error, !error.isEmpty else { break }
print("Could not open Xcode. Make sure Xcode is installed and try again.\nRaw error: \(error)")
default:
print("✅ Completed. You can edit this file at 'fastlane/Constants/Constant.swift'.")
switch arg.lowercased() {
case "y", "yes":
do {
let error = try safeShell("open -a Xcode fastlane/Constants/Constant.swift")
guard let error = error, !error.isEmpty else { break }
print("Could not open Xcode. Make sure Xcode is installed and try again.\nRaw error: \(error)")
} catch {
print("Error: \(error)")
}
default:
print("✅ Completed. You can edit this file at 'fastlane/Constants/Constant.swift'.")
}
}
}
69 changes: 45 additions & 24 deletions Scripts/Swift/SetUpInterface.swift
Original file line number Diff line number Diff line change
@@ -1,25 +1,46 @@
#!/usr/bin/swift

import Foundation

let fileManager = FileManager.default

var interface = "UIKit"

switch CommandLine.arguments[1] {
case "SwiftUI", "s", "S":
print("=> 🦅 Setting up SwiftUI")
interface = "SwiftUI"
let swiftUIAppDirectory = "tuist/Interfaces/SwiftUI/Sources/Application"
fileManager.rename(
file: "\(swiftUIAppDirectory)/App.swift",
to: "\(swiftUIAppDirectory)/\(CommandLine.arguments[2])App.swift"
)
default:
print("=> 🦉 Setting up UIKit")
interface = "UIKit"
}
struct SetUpInterface {

enum Interface {

case swiftUI, uiKit

init?(_ name: String) {
switch name.lowercased() {
case "s", "swiftui":
self = .swiftUI
case "u", "uikit":
self = .uiKit
default: return nil
}
}

var folderName: String {
switch self {
case .swiftUI: return "SwiftUI"
case .uiKit: return "UIKit"
}
}
}

fileManager.moveFiles(in: "tuist/Interfaces/\(interface)/Project", to: "")
fileManager.moveFiles(in: "tuist/Interfaces/\(interface)/Sources", to: "{PROJECT_NAME}/Sources")
fileManager.removeItems(in: "tuist/Interfaces")
private let fileManager = FileManager.default

func perform(_ interface: Interface, _ projectName: String) {
switch interface {
case .swiftUI:
print("=> 🦅 Setting up SwiftUI")
let swiftUIAppDirectory = "tuist/Interfaces/SwiftUI/Sources/Application"
fileManager.rename(
file: "\(swiftUIAppDirectory)/App.swift",
to: "\(swiftUIAppDirectory)/\(projectName)App.swift"
)
case .uiKit:
print("=> 🦉 Setting up UIKit")
}

let folderName = interface.folderName

fileManager.moveFiles(in: "tuist/Interfaces/\(folderName)/Project", to: "")
fileManager.moveFiles(in: "tuist/Interfaces/\(folderName)/Sources", to: "TemplateApp/Sources")
fileManager.removeItems(in: "tuist/Interfaces")
}
}
16 changes: 16 additions & 0 deletions Scripts/Swift/SetUpTestTestFlight.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
let teamIdPlaceholder = "<#teamId#>"
let apiKeyIdPlaceholder = "<#API_KEY_ID#>"
let issuerIdPlaceholder = "<#ISSUER_ID#>"
let matchRepoPlaceholder = "[email protected]:{organization}/{repo}.git"

let envMatchRepo = ProcessInfo.processInfo.environment["MATCH_REPO"] ?? ""
let envApiKey = ProcessInfo.processInfo.environment["API_KEY_ID"] ?? ""
let envIssuerId = ProcessInfo.processInfo.environment["ISSUER_ID"] ?? ""
let envTeamId = ProcessInfo.processInfo.environment["TEAM_ID"] ?? ""

let fileManager = FileManager.default

fileManager.replaceAllOccurrences(of: teamIdPlaceholder, to: envTeamId)
fileManager.replaceAllOccurrences(of: apiKeyIdPlaceholder, to: envApiKey)
fileManager.replaceAllOccurrences(of: issuerIdPlaceholder, to: envIssuerId)
fileManager.replaceAllOccurrences(of: matchRepoPlaceholder, to: envMatchRepo)
Loading

0 comments on commit aa841f7

Please sign in to comment.