Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release - 4.8.0 #523

Merged
merged 20 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
68d7f93
[#494] Add SetUpiOSProject.swift. Move SetUpInterface to struct
blyscuit Jul 18, 2023
508a9df
[#494] Add renaming to SetUpiOSProject.swift
blyscuit Jul 20, 2023
f9117bf
[#494] Add extra scripts to main set up
blyscuit Jul 20, 2023
20759d8
[#494] Refactor funcs
blyscuit Jul 21, 2023
4975f20
[#494] Add filter for unnessary files
blyscuit Aug 8, 2023
6a104b7
[#494] Add filter for unnessary files
blyscuit Aug 8, 2023
6fab661
[#494] Fix Danger import old files
blyscuit Aug 9, 2023
cba1e35
[#492] Create SetUpTestTestFlight.swift
ducbm051291 Aug 10, 2023
82fd58b
Merge pull request #512 from nimblehq/chore/492-migrate-set-up-test-t…
blyscuit Aug 15, 2023
f94af58
[#494] Fix comment
blyscuit Aug 15, 2023
00e6deb
Merge pull request #504 from nimblehq/chore/494-make-sh-swift-command
blyscuit Aug 22, 2023
c474f72
Revert "[Chore] [#423] Update a specific name for deploying staging b…
vnntsu Jan 31, 2023
123118f
[#423] Update names for workflows and their descriptions
nkhanh44 Jan 11, 2023
fa4a681
[#510] Add function remove in Keychain to remove keychain in case the…
ducbm051291 Aug 22, 2023
71ef49a
[#510] Clean up unused code
ducbm051291 Aug 22, 2023
c37549f
[#510] Update keychainName default value with "{PROJECT_NAME}" to be …
ducbm051291 Aug 24, 2023
3e873f8
[#510] Update keychainName default value
ducbm051291 Aug 24, 2023
07ef7e5
[fix] [517] Fix crash by setting appropriate string
Shayokh144 Aug 25, 2023
81d9e23
Merge pull request #513 from nimblehq/feature/510-github-actions-can-…
blyscuit Aug 30, 2023
3449d97
Merge pull request #520 from nimblehq/bug/517-fix-ui-test-crash
blyscuit Sep 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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