Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(samsungknox-fastlane): application version same error ignore
  • Loading branch information
jieey1140 authored Nov 27, 2023
2 parents 7d636ed + 839c286 commit bbe5bb4
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 18 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/samsungknox-fastlane-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ jobs:
working-directory: packages/knox-fastlane-plugin
run: bundle install

- name: Rake install
working-directory: packages/knox-fastlane-plugin
run: bundle exec rake install

- name: Release Gem
working-directory: packages/knox-fastlane-plugin
run: bundle exec rake releases
run: bundle exec rake release
env:
RUBYGEMS_AUTH_TOKEN: ${{ secrets.RUBYGEMS_AUTH_TOKEN }}
7 changes: 7 additions & 0 deletions packages/knox-fastlane-plugin/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @redredgroup/knox-fastlane-plugin

## 0.1.1

### Patch Changes

- If there are duplicate packages in the upload, skip the upload rather than raise an error.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def self.run(params)
KnoxConfigureLibraryUploadApp.upload_app(
access_token[:token],
params[:app_file_path],
params[:app_description]
params[:app_description],
params[:api_region].downcase
)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,35 @@ module Fastlane
UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")

module KnoxConfigureLibraryUploadApp
def self.upload_app(access_token, app_file_path, app_description)
uri = URI('https://eu-kcs-api.samsungknox.com/kcs/v1/kc/applications/upload')
def self.upload_app(access_token, app_file_path, app_description, api_region)
UI.header('Step: 📲 Upload Application to Knox Configure Library 📲 ')

uri = URI("https://#{api_region}-kcs-api.samsungknox.com/kcs/v1/kc/applications/upload")

File.open(app_file_path) do |file|
request = Net::HTTP::Post::Multipart.new uri,
"file" => UploadIO.new(file, "multipart/form-data", File.basename(app_file_path))

request['X-KNOX-APITOKEN'] = access_token

UI.message("⌛ Uploading the #{'APP'}.")
UI.message("⌛ Uploading the Application. Please wait a moment...")
response = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http|
http.request(request)
end

if response.is_a?(Net::HTTPSuccess)
data = JSON.parse(response.body)
UI.success(data)
uploadResponseBody = JSON.parse(response.body)
successResponse = uploadResponseBody['successResponse'][0]
appInfo = successResponse['appInfo'][0]
UI.success("🎉 Uploaded Application [#{appInfo['name']}] v#{appInfo['packageVersion']} successfully!")
else
raise "Request failed with response: #{response.body}"
end
uploadResponseBody = JSON.parse(response.body)
if uploadResponseBody['data'].strip == 'APP_BINARY_EXISTS'
UI.success("✅ The same Application was found in release with no changes, skipping.")
else
raise "Request failed with response: #{response.body}"
end
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def self.get_access_token(validity_for_access_token_in_minutes, base64_encoded_s

if response.is_a?(Net::HTTPSuccess)
data = JSON.parse(response.body)
UI.success('✅ ams accessToken generated successfully!')
UI.success('✅ ams accessToken generated successfully')
return data["accessToken"]
else
raise "Request failed with response: #{response.body}"
Expand All @@ -77,15 +77,15 @@ def self.get_access_token(validity_for_access_token_in_minutes, base64_encoded_s
def self.generate_knox_access_token(credential, clientIdentifierJwtToken, api_region)
UI.header('Step: 🔐 KNOX ACCESS TOKEN GENERATE 🔐 ')

UI.message(' Sign the knox token using the credential...')
UI.message('🔐 Sign in the knox token using the credential...')
generate_signed_jwt_result = generate_signed_jwt(credential, clientIdentifierJwtToken, true)

base64_encoding_public_Key = generate_signed_jwt_result[:public_key]
sign_by_client_identifier_jwt_token = generate_signed_jwt_result[:token]

UI.message('⏳ Request the knox client identifier jwt ams access token...')
UI.message('⏳ Request the knox client identifier jwt ams access token.')
ams_access_token = get_access_token(30, base64_encoding_public_Key, sign_by_client_identifier_jwt_token, api_region)
UI.message(' Sign the knox token using the ams access token and private key...')
UI.message('🔐 Sign the knox token using the ams access token and private key.')
token = generate_signed_jwt(credential, ams_access_token, false)

return { token: token[:token] }
Expand Down Expand Up @@ -114,7 +114,7 @@ def self.generate_signed_jwt(credential, token_or_access, is_client_identifier)

token = JWT.encode(payload, private_key, 'RS512')

UI.success('✅ token generated successfully!')
UI.success('✅ token generated successfully')
return { public_key: public_key, token: token }
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Fastlane
module Samsungknox
VERSION = "0.1.0"
VERSION = "0.1.1"
end
end
6 changes: 3 additions & 3 deletions packages/knox-fastlane-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "@redredgroup/knox-fastlane-plugin",
"version": "0.2.1",
"description": "",
"version": "0.1.1",
"scripts": {
"format": "prettier --write .",
"lint:format": "prettier --check ."
},
"devDependencies": {
"prettier": "3.0.0",
"@prettier/plugin-ruby": "4.0.2"
"@prettier/plugin-ruby": "4.0.2",
"prettier": "3.0.0"
}
}

0 comments on commit bbe5bb4

Please sign in to comment.