Skip to content

Commit

Permalink
v1.0.1
Browse files Browse the repository at this point in the history
+ changed deploy dir to apk path
+ typos
+ cleanup
  • Loading branch information
radimvaculik committed Oct 19, 2016
1 parent 4bef889 commit 9d343a4
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 63 deletions.
17 changes: 13 additions & 4 deletions bitrise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
app:
envs:
# define these in your .bitrise.secrets.yml
- BITRISE_DEPLOY_PATH: $BITRISE_DEPLOY_PATH
- BITRISE_APK_PATH: $BITRISE_APK_PATH
#
- STEP_VERSION: "1.0.0"
- STEP_VERSION: "1.0.1"

workflows:
# ----------------------------------------------------------------
Expand All @@ -28,7 +28,7 @@ workflows:
- path::./:
run_if: true
inputs:
- deploy_path: $BITRISE_DEPLOY_PATH
- apk_path: $BITRISE_APK_PATH
- script:
title: Output (generated by the Step) tests
inputs:
Expand All @@ -54,6 +54,15 @@ workflows:
set -ex
export CI=true
releaseman create --version $RELEASE_VERSION
audit-this-step:
steps:
- script:
inputs:
- content: |-
#!/bin/bash
set -ex
stepman audit --step-yml ./step.yml
publish-release:
steps:
- script:
Expand All @@ -71,7 +80,7 @@ workflows:
envs:
# if you want to share this step into a StepLib
- MY_STEPLIB_REPO_FORK_GIT_URL: https://github.com/thefuntasty/bitrise-steplib
- STEP_ID_IN_STEPLIB: bitrise-step-android-info
- STEP_ID_IN_STEPLIB: android-info
- STEP_GIT_VERION_TAG_TO_SHARE: $STEP_VERSION
- STEP_GIT_CLONE_URL: https://github.com/thefuntasty/bitrise-step-android-info.git
description: |-
Expand Down
57 changes: 10 additions & 47 deletions step.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require 'optparse'
require 'tempfile'

# -----------------------
# --- functions
Expand Down Expand Up @@ -92,11 +91,7 @@ def filter_min_sdk_version(infos)

def get_android_apk_info(apk_path)
puts
puts
puts "# Deploying apk file: #{apk_path}"

# - Analyze the apk / collect infos from apk
puts '--> Analyze the apk'
puts "# APK file: #{apk_path}"

aapt = aapt_path
infos = `#{aapt} dump badging #{apk_path}`
Expand All @@ -112,7 +107,6 @@ def get_android_apk_info(apk_path)

icon_path = File.dirname(apk_path) + "/icon.png"


apk_info_hsh = {
file_size_bytes: apk_file_size,
app_info: {
Expand All @@ -125,8 +119,6 @@ def get_android_apk_info(apk_path)
}
}



puts "#{apk_info_hsh}"

return apk_info_hsh
Expand All @@ -136,66 +128,37 @@ def get_android_apk_info(apk_path)
# --- Options

options = {
deploy_path: nil,
apk_path: nil,
}

parser = OptionParser.new do|opts|
opts.banner = 'Usage: step.rb [options]'
opts.on('-d', '--deploypath PATH', 'Deploy Path') { |d| options[:deploy_path] = d unless d.to_s == '' }
opts.on('-a', '--apkpath PATH', 'APK Path') { |d| options[:apk_path] = d unless d.to_s == '' }
opts.on('-h', '--help', 'Displays Help') do
exit
end
end
parser.parse!

fail_with_message('No deploy_path provided') unless options[:deploy_path]
fail_with_message('No apk_path provided') unless options[:apk_path]

options[:deploy_path] = File.absolute_path(options[:deploy_path])
options[:apk_path] = File.absolute_path(options[:apk_path])

if !Dir.exist?(options[:deploy_path]) && !File.exist?(options[:deploy_path])
fail_with_message('Deploy source path does not exist at the provided path: ' + options[:deploy_path])
if !Dir.exist?(options[:apk_path]) && !File.exist?(options[:apk_path])
fail_with_message('APK path does not exist: ' + options[:apk_path])
end

puts
puts '========== Configs =========='
puts " * deploy_path: #{options[:deploy_path]}"
puts " * apk_path: #{options[:apk_path]}"

# ----------------------------
# --- Main

begin
apk_info_hsh = ""
if File.directory?(options[:deploy_path])
puts
puts '## Uploading the content of the Deploy directory separately'
entries = Dir.entries(options[:deploy_path])
entries.delete('.')
entries.delete('..')

entries = entries
.map { |e| File.join(options[:deploy_path], e) }
.select { |e| !File.directory?(e) }

puts
puts '======= List of files ======='
puts ' No files found to deploy' if entries.length == 0
entries.each { |filepth| puts " * #{filepth}" }
puts '============================='
puts

entries.each do |filepth|
disk_file_path = filepth

if disk_file_path.match('.*.apk')
apk_info_hsh = get_android_apk_info(disk_file_path)
end
end
else
puts
puts '## Deploying single file'
if options[:deploy_path].match('.*.apk')
apk_info_hsh = get_android_apk_info(options[:deploy_path])
end
if options[:apk_path].match('.*.apk')
apk_info_hsh = get_android_apk_info(options[:apk_path])
end

# - Success
Expand Down
2 changes: 1 addition & 1 deletion step.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ bundle install --without test --jobs 20 --retry 5
echo
echo "=> Running the step ..."
echo
bundle exec ruby "$THIS_SCRIPT_DIR/step.rb" -d "${deploy_path}"
bundle exec ruby "$THIS_SCRIPT_DIR/step.rb" -a "${apk_path}"
14 changes: 3 additions & 11 deletions step.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,18 @@ source_code_url: https://github.com/thefuntasty/bitrise-step-android-info
support_url: https://github.com/thefuntasty/bitrise-step-android-info/issues
project_type_tags:
- "android"
- "apk"
type_tags:
- artifact
is_requires_admin_user: false
is_always_run: true
is_skippable: false
run_if: .IsCI
inputs:
- deploy_path: "$BITRISE_DEPLOY_DIR"
- apk_path: "$BITRISE_APK_PATH"
opts:
title: "Deploy directory or APK file path"
title: "APK file path"
description: |
Specify the directory or file path which will be deployed.
If the specified path is a directory then every file
in the directory will be deployed - but only the
files in the specified directory, sub-directories
won't be uploaded.
If you specify a file path then only the specified
file will be deployed.
File path to APK file to get info from.
is_required: true
outputs:
- ANDROID_APP_PACKAGE_NAME:
Expand Down

0 comments on commit 9d343a4

Please sign in to comment.