Skip to content

Commit

Permalink
Created Entitlements folder to contain new build task
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Hoefling committed May 17, 2018
1 parent 8f3cd3a commit 4df30a1
Show file tree
Hide file tree
Showing 8 changed files with 416 additions and 0 deletions.
Binary file added tasks/iOSEntitlementTransform/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
79 changes: 79 additions & 0 deletions tasks/iOSEntitlementTransform/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions tasks/iOSEntitlementTransform/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "iosbumpversion",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"vsts-task-lib": "^2.1.0"
},
"devDependencies": {
"@types/node": "^8.5.1",
"@types/q": "^1.0.6"
}
}
74 changes: 74 additions & 0 deletions tasks/iOSEntitlementTransform/task.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"id": "42284b34-be85-4034-890f-8755ad9f6249",
"name": "ios-bundle-version",
"friendlyName": "iOS Bundle Version Numbers",
"description": "Bump the version of your iOS info.plist file at build time.",
"helpMarkDown": "",
"category": "Utility",
"author": "James Montemagno",
"visibility": [
"Build",
"Release"
],
"version": {
"Major": 0,
"Minor": 6,
"Patch": 0
},
"instanceNameFormat": "Bump iOS Versions in $(sourcePath)",
"groups": [
{
"name": "advanced",
"displayName": "Advanced",
"isExpanded": false
}
],
"inputs": [
{
"name": "sourcePath",
"type": "filePath",
"label": "iOS info.plist File Path",
"defaultValue": "",
"required": true,
"helpMarkDown": "Full path to iOS info.plist file."
},
{
"name": "versionCode",
"type": "string",
"label": "Version Code (CFBundleVersion)",
"defaultValue": "$(Build.BuildId)",
"required": true,
"helpMarkDown": "Number to set the version code to, must be an integer to use offset, else can be anything."
},
{
"name": "versionCodeOffset",
"type": "string",
"label": "Version Code Offset",
"defaultValue": "",
"required": false,
"helpMarkDown": "A number to offset the version code below, must be an integer."
},
{
"name": "versionName",
"type": "string",
"label": "Version Name (CFBundleShortVersionString)",
"defaultValue": "1.0.$(Build.BuildId)",
"required": false,
"helpMarkDown": "The version number shown to users (leave blank to use existing value in info.plist)."
},
{
"name": "printFile",
"type": "boolean",
"label": "Print File",
"defaultValue": true,
"required": true,
"helpMarkDown": "If you would like to print the file contents before and after changing variables."
}
],
"execution": {
"Node": {
"target": "built/task.js",
"workingDirectory": "$(currentDirectory)"
}
}
}
75 changes: 75 additions & 0 deletions tasks/iOSEntitlementTransform/task.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
Param(
[string]$sourcePath,
[string]$versionCodeOffset,
[string]$versionCode,
[string]$versionName,
[bool]$printFile
)

# requies parameters
if(!$sourcePath)
{
write-host " [!] Missing required input: sourcePath"
exit 1
}

if(!(Test-Path $sourcePath))
{
Write-Host " [!] File doesn't exist at specified Info.plist path: $sourcePath"
exit 1
}

if(!$versionCode)
{
Write-Host " [!] No versionCode specified!"
exit 1
}

# ---------------------
# --- Configs:
Write-Host " (i) Provided Info.plist path: $sourcePath"

if($versionName)
{
Write-Host " (i) Version name (shortcode): $versionName"
}

if($versionCodeOffset)
{
Write-Host " (i) Build number versionCodeOffset: $versionCodeOffset"

$versionCode = $versionCode/1 + $versionCodeOffset/1
}

Write-Host " (i) Build number: $versionCode"

# ---------------------
# --- Main:

# ---- Current Bundle Version:

if($printFile)
{
Write-Host "Original info.Plist:"
Get-Content $sourcePath | Write-Host
}

& /usr/libexec/PlistBuddy -c "Print CFBundleVersion" $sourcePath

# ---- Set Bundle Version:
& /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $versionCode" $sourcePath

if($versionName)
{
# ---- Current Bundle Short Version String:
& /usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" $sourcePath

# ---- Set Bundle Short Version String:
& /usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $versionName" $sourcePath
}

if($printFile)
{
Write-Host "Final info.Plist:"
Get-Content $sourcePath | Write-Host
}
72 changes: 72 additions & 0 deletions tasks/iOSEntitlementTransform/task.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/bin/bash

# 1 = plist_path
# 2 = offset 0
# 3 = version number 1
# 4 = short code 1.1.1

# exit if a command fails
set -e

#
# Required parameters
if [ -z "${1}" ] ; then
echo " [!] Missing required input: plist_path"
exit 1
fi
if [ ! -f "${1}" ] ; then
echo " [!] File doesn't exist at specified Info.plist path: ${plist_path}"
exit 1
fi

if [ -z "${3}" ] ; then
echo " [!] No build_version specified!"
exit 1
fi

# ---------------------
# --- Configs:

CONFIG_project_info_plist_path="${1}"
CONFIG_new_build_short_version_string="${4}"
CONFIG_new_bundle_version="${3}"

echo " (i) Provided Info.plist path: ${CONFIG_project_info_plist_path}"

if [ ! -z "${CONFIG_new_build_short_version_string}" ] ; then
echo " (i) Version number: ${CONFIG_new_build_short_version_string}"
fi

if [ ! -z "${2}" ] ; then
echo " (i) Build number offset: ${2}"

CONFIG_new_bundle_version=$((${3} + ${2}))

echo " (i) Build number: ${CONFIG_new_bundle_version}"
else
echo " (i) Build number: ${CONFIG_new_bundle_version}"
fi


# ---------------------
# --- Main:

# verbose / debug print commands
set -v

# ---- Current Bundle Version:
/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${CONFIG_project_info_plist_path}"

# ---- Set Bundle Version:
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${CONFIG_new_bundle_version}" "${CONFIG_project_info_plist_path}"


if [ ! -z "${CONFIG_new_build_short_version_string}" ] ; then
# ---- Current Bundle Short Version String:
/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${CONFIG_project_info_plist_path}"

# ---- Set Bundle Short Version String:
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString ${CONFIG_new_build_short_version_string}" "${CONFIG_project_info_plist_path}"
fi

# ==> Bundle Version and Short Version changed
Loading

0 comments on commit 4df30a1

Please sign in to comment.