Skip to content

Commit

Permalink
Add agent QSP for analytic (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-quiltt authored Feb 27, 2024
1 parent 16fb095 commit 2773a75
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Sources/QuilttConnector/QuilttConnectorWebview.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class QuilttConnectorWebview: WKWebView, WKNavigationDelegate {
self.onExitSuccess = onExitSuccess
self.onExitAbort = onExitAbort
self.onExitError = onExitError
if let url = URL(string: "https://\(config.connectorId).quiltt.app?mode=webview&oauth_redirect_url=\(config.oauthRedirectUrl)&sdk=swift") {
if let url = URL(string: "https://\(config.connectorId).quiltt.app?mode=webview&oauth_redirect_url=\(config.oauthRedirectUrl)&agent=ios-\(quilttSdkVersion)") {
let req = URLRequest(url: url)
return super.load(req)
}
Expand Down
3 changes: 3 additions & 0 deletions Sources/QuilttConnector/QuilttSdkVersion.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Foundation

public let quilttSdkVersion = "0.0.4"
51 changes: 38 additions & 13 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,47 +6,61 @@ default_platform :ios
REPO_NAME = 'quiltt/quiltt-ios'.freeze
GITHUB_TOKEN = ENV['GITHUB_TOKEN']

def release(level)
def bump_version_file(level)
client = ::Octokit::Client.new(access_token: GITHUB_TOKEN)
latest_release = client.latest_release(REPO_NAME)

current_version = Semantic::Version.new(latest_release.tag_name)
new_version = current_version.increment!(level).to_s
generate_release_version_file(new_version)
new_version
end

def release(new_version)
new_branch = "release/#{new_version}"
push_to_git_remote(new_branch)

set_github_release(
repository_name: REPO_NAME,
api_token: GITHUB_TOKEN,
name: new_version.to_s,
tag_name: new_version.to_s,
is_generate_release_notes: true,
commitish: 'main'
commitish: new_branch
)

create_pull_request(
repo: REPO_NAME,
api_token: GITHUB_TOKEN,
title: "Release #{new_version}",
head: new_branch,
base: 'main'
)
end

platform :ios do
desc 'Release patch version'
lane :release_patch do
new_version = bump_version_file(:patch)
build_example_app
# test_example_app
release(:patch)
release(new_version)
end

desc 'Release minor version'
lane :release_minor do
lane :release_minor do
build_example_app
# test_example_app
release(:minor)
end
new_version = bump_version_file(:minor)
build_example_app
# test_example_app
release(new_version)
end

desc 'Release major version'
lane :release_major do
lane :release_major do
build_example_app
# test_example_app
release(:major)
end
new_version = bump_version_file(:major)
build_example_app
# test_example_app
release(new_version)
end

desc 'Build Example App'
Expand All @@ -63,4 +77,15 @@ platform :ios do
# xcargs: '-allowProvisioningUpdates'
# )
end

def generate_release_version_file(version)
sh("echo \"import Foundation\npublic let quilttSdkVersion = \\\"#{version}\\\"\" > ../Sources/QuilttConnector/QuilttSdkVersion.swift")
end

def push_to_git_remote(branch)
sh("git checkout -b #{branch}")
sh('git add ../Sources/QuilttConnector/QuilttSdkVersion.swift')
sh('git commit -m "Bump version"')
sh("git push origin #{branch}")
end
end

0 comments on commit 2773a75

Please sign in to comment.