Skip to content

Commit

Permalink
Merge branch 'release/1.2.12'
Browse files Browse the repository at this point in the history
  • Loading branch information
ygini committed Sep 13, 2017
2 parents ed81cd2 + cb1f94c commit c0be60c
Show file tree
Hide file tree
Showing 17 changed files with 220 additions and 34 deletions.
53 changes: 51 additions & 2 deletions package/BuildAndPackage.command
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,58 @@

CONFIGURATION="Release"

GIT_ROOT_DIR="$(dirname $(dirname ${BASH_SOURCE[0]}))"
DEFAULT_DEVELOPER_ID_INSTALLER="Developer ID Installer: Yoann GINI (CRXPBZF3N4)"
DEVELOPER_ID_INSTALLER=${CUSTOM_DEVELOPER_ID_INSTALLER:-${DEFAULT_DEVELOPER_ID_INSTALLER}}

echo "Packaging will use ${DEVELOPER_ID_INSTALLER}"

GIT_ROOT_DIR="$(git rev-parse --show-toplevel)"
PROJECT_DIR="${GIT_ROOT_DIR}/src"
BUILT_PRODUCTS_DIR="$(mktemp -d)"

cd "${GIT_ROOT_DIR}"

CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)

if [[ "$CURRENT_BRANCH" == "master" ]]
then
CONFIGURATION="Release"
elif [[ "$CURRENT_BRANCH" == release* ]]
then
CONFIGURATION="Release"
else
CONFIGURATION="Debug"
fi

UNCOMMITED_CHANGE=$(git status -s | wc -l | bc)

if [ -z $FORCE_SKIP_REPO_STATE ]
then
if [ $UNCOMMITED_CHANGE -ne 0 ] && [ "$CONFIGURATION" == "Release" ]
then
echo "Your are on ${CURRENT_BRANCH} and there"
echo "is some uncommited change to the repo."
echo "Please, commit and try again or use"
echo "a development branch."
exit 1
fi
fi

PKG_VERSION=$(/usr/libexec/PlistBuddy -c "print CFBundleShortVersionString" "${PROJECT_DIR}/Hello IT/Info.plist")

if [[ "$CURRENT_BRANCH" == release* ]]
then
CONFIGURATION="Release"
VERSION_FROM_BRANCH=$(echo "${CURRENT_BRANCH}" | awk -F'/' '{print $2}')
if [[ "$VERSION_FROM_BRANCH" =~ ^[0-9]+\.[0-9]+ ]]
then
PKG_VERSION=$VERSION_FROM_BRANCH
/usr/libexec/PlistBuddy -c "Set CFBundleShortVersionString $PKG_VERSION" "${PROJECT_DIR}/Hello IT/Info.plist"
git add "${PROJECT_DIR}/Hello IT/Info.plist"
git commit -m "Update app version number according to release branch"
fi
fi

BASE_RELEASE_LOCATION="${GIT_ROOT_DIR}/package/build"
RELEASE_LOCATION="${BASE_RELEASE_LOCATION}/${PKG_VERSION}-${CONFIGURATION}"
RELEASE_PRODUCT_LOCATION="${RELEASE_LOCATION}/Products"
Expand Down Expand Up @@ -54,7 +98,12 @@ cp -r "${GIT_ROOT_DIR}/package/LaunchAgents/com.github.ygini.hello-it.plist" "${

#sudo chown -R root:wheel "${PKG_ROOT}"

pkgbuild --sign "Developer ID Installer: Yoann GINI (CRXPBZF3N4)" --root "${PKG_ROOT}" --scripts "${GIT_ROOT_DIR}/package/pkg_scripts" --identifier "com.github.ygini.hello-it" --version "${PKG_VERSION}" "${RELEASE_LOCATION}/Hello-IT-${PKG_VERSION}-${CONFIGURATION}.pkg"
PBK_BUILD_COMPONENT="${BUILT_PRODUCTS_DIR}/components.plist"
pkgbuild --analyze --root "${PKG_ROOT}" "${PBK_BUILD_COMPONENT}"

/usr/libexec/PlistBuddy -c "Set 0:BundleIsRelocatable bool false" "${PBK_BUILD_COMPONENT}"
/usr/libexec/PlistBuddy -c "Print" "${PBK_BUILD_COMPONENT}"
pkgbuild --component-plist "${PBK_BUILD_COMPONENT}" --sign "${DEVELOPER_ID_INSTALLER}" --root "${PKG_ROOT}" --scripts "${GIT_ROOT_DIR}/package/pkg_scripts" --identifier "com.github.ygini.hello-it" --version "${PKG_VERSION}" "${RELEASE_LOCATION}/Hello-IT-${PKG_VERSION}-${CONFIGURATION}.pkg"

rm -rf "${PKG_ROOT}"

Expand Down
2 changes: 1 addition & 1 deletion package/LaunchAgents/com.github.ygini.hello-it.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<false/>
<true/>
<key>Label</key>
<string>com.github.ygini.hello-it</string>
<key>ProgramArguments</key>
Expand Down
31 changes: 31 additions & 0 deletions package/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Building Hello-IT

To prepare a new Hello-IT release, some steps must be followed in a specific order.

## Preparation

General code submission follows the git flow pattern.

Once `develop` branch is ready for a new version, a new `release` branch named with the version number only (no `v` first).

## Building the release

To build the release once in the release branch, use the `BuildAndPackage.command` script.

By default, build script will look for the Developer ID Installer named `Developer ID Installer: Yoann GINI (CRXPBZF3N4)`. Use `CUSTOM_DEVELOPER_ID_INSTALLER` environmental variable to specify your own.

The script will build the app with all dependencies in the right order, sign it, create the package, and sign it too.

The script will build the app in `Release` config when the current branch is under `release` or is `master`. All other branches will be built in `Debug` config.

App version will be grabbed from git branches name or let untouched if the branch name does not match the pattern `release/version`. If version number is updated, it will automatically be committed before building the release.

Build version is generated from the number of git commits in the history from the current branch point of view.

Once built and tested, and only for final release (not for beta), the release branch must be merged in the master tree. Last commit to merge should be the one updating the app version. Returning to this exact commit will allow a developer to recreate the app in the exact same states (and so build version will be the same).

The build will deny to start if there is some uncommitted change to the repo.

## Distribution

The pkg created at the previous step can now be updated into the Github Release system with a nice description and the pkg as the only payload.
2 changes: 1 addition & 1 deletion src/HITDevKit/HITDevKit/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>178</string>
<string>199</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2015 Yoann Gini (Open Source Project). All rights reserved.</string>
<key>NSPrincipalClass</key>
Expand Down
2 changes: 1 addition & 1 deletion src/Hello IT/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ - (void)loadMenu {

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if ([keyPath isEqualToString:@"testState"]) {
int substate = 0;
int substate = HITPluginTestStateNone;

if ([self.statusMenuManager respondsToSelector:@selector(testState)]) {
substate |= [self.statusMenuManager testState];
Expand Down
4 changes: 2 additions & 2 deletions src/Hello IT/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.2.11</string>
<string>1.2.12</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>178</string>
<string>199</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion src/Plugins/OpenApplication/OpenApplication/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>178</string>
<string>199</string>
<key>HITPFunctionIdentifier</key>
<string>public.open.application</string>
<key>NSHumanReadableCopyright</key>
Expand Down
2 changes: 1 addition & 1 deletion src/Plugins/OpenResource/OpenResource/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>178</string>
<string>199</string>
<key>HITPFunctionIdentifier</key>
<string>public.open.resource</string>
<key>NSHumanReadableCopyright</key>
Expand Down
2 changes: 1 addition & 1 deletion src/Plugins/Quit/Quit/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>178</string>
<string>199</string>
<key>HITPFunctionIdentifier</key>
<string>public.quit</string>
<key>NSHumanReadableCopyright</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

. "$HELLO_IT_SCRIPT_FOLDER/com.github.ygini.hello-it.scriptlib.sh"

function updateTitleWithArgs {
function getHostname {
hostname=$(scutil --get HostName)
localhostname=$(scutil --get LocalHostName)
computername=$(scutil --get ComputerName)
Expand All @@ -25,12 +25,18 @@ function updateTitleWithArgs {
format="%C"
fi

title=$(echo "$format" | sed "s/%C/$computername/g" | sed "s/%H/$hostname/g" | sed "s/%L/$localhostname/g")
echo "$format" | sed "s/%C/$computername/g" | sed "s/%H/$hostname/g" | sed "s/%L/$localhostname/g"

}

function updateTitleWithArgs {
title=$(getHostname)
updateTitle "Hostname: $title"
}

function onClickAction {
updateTitleWithArgs "$@"
getHostname | pbcopy
}

function fromCronAction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@

. "$HELLO_IT_SCRIPT_FOLDER/com.github.ygini.hello-it.scriptlib.sh"

mode=0
mainBSDInterface=$(route -n get 8.8.8.8 | grep "interface: " | awk -F ": " '{print $2}')

while getopts "m:i:" o; do
case "${o}" in
m)
mode=${OPTARG}
;;
i)
mainBSDInterface=${OPTARG}
;;
esac
done

function handleStateUpdate {
mode=$1
requestedState=$2
Expand All @@ -37,23 +51,13 @@ function handleStateUpdate {
fi
}

function updateTitleWithArgs {
mode=0
mainBSDInterface=$(route -n get 8.8.8.8 | grep "interface: " | awk -F ": " '{print $2}')

while getopts "m:i:" o; do
case "${o}" in
m)
mode=${OPTARG}
;;
i)
mainBSDInterface=${OPTARG}
;;
esac
done

ipAddress=$(ifconfig "$mainBSDInterface" | grep "inet " | sed "s/.*inet \([0-9.]*\).*/\1/" | head -n1)
function getIP {
ifconfig "$mainBSDInterface" | grep "inet " | sed "s/.*inet \([0-9.]*\).*/\1/" | head -n1
}

function updateTitleWithArgs {
ipAddress=$(getIP "$@")

if [ -z "$ipAddress" ]
then
updateTitle "No IP Address"
Expand All @@ -66,7 +70,7 @@ function updateTitleWithArgs {
updateTooltip "No network connection available"
fi
else
updateTitle "IP: $ipAddress"
updateTitle "Local IP: $ipAddress"
handleStateUpdate $mode ${STATE[0]}
updateTooltip "Having an IP address doesn't mean you've Internet access"
fi
Expand All @@ -75,6 +79,7 @@ function updateTitleWithArgs {

function onClickAction {
updateTitleWithArgs "$@"
getIP "$@" | pbcopy
}

function fromCronAction {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#!/bin/bash

# Display Public IP address as title
# With no option, the script detect the public
# address using https://ip.abelionni.com/script/
#
# You can specify the test URL using -u
#
# You can specify the behavior if no IP
# are found with -m option:
# 0: show IP if available, hide if not
# 1: show IP if available, specify if not, no $STATE
# 2: show IP if available, specify if not, use $STATE

. "$HELLO_IT_SCRIPT_FOLDER/com.github.ygini.hello-it.scriptlib.sh"

mode=0
public_ip_url="https://ip.abelionni.com/script/"

while getopts "m:u:" o; do
case "${o}" in
m)
mode=${OPTARG}
;;
u)
public_ip_url=${OPTARG}
;;
esac
done

function handleStateUpdate {
mode=$1
requestedState=$2

if [ $mode -eq 0 ]
then
if [ "$requestedState" == ${STATE[0]} ]
then
setHidden NO
else
setHidden YES
fi
else
setHidden NO
if [ $mode -eq 1 ]
then
updateState ${STATE[4]}
else
updateState $requestedState
fi
fi
}

function getIP {
curl -s "$public_ip_url"
}

function updateTitleWithArgs {
ipAddress=$(curl -s "$public_ip_url")

if [ -z "$ipAddress" ]
then
updateTitle "No IP Address"
if [[ "$HELLO_IT_NETWORK_STATE" == "1" ]]
then
handleStateUpdate $mode ${STATE[2]}
updateTooltip "Please, check your Ethernet or WiFi connection"
else
handleStateUpdate $mode ${STATE[3]}
updateTooltip "No internet connection available"
fi
else
updateTitle "Public IP: $ipAddress"
handleStateUpdate $mode ${STATE[0]}
updateTooltip "You should have access to Internet"
fi

}

function onClickAction {
updateTitleWithArgs "$@"
getIP "$@" | pbcopy
}

function fromCronAction {
updateTitleWithArgs "$@"
}

function setTitleAction {
updateTitleWithArgs "$@"
}

main "$@"

exit 0
2 changes: 1 addition & 1 deletion src/Plugins/ScriptedItem/ScriptedItem/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>178</string>
<string>199</string>
<key>HITPFunctionIdentifier</key>
<string>public.script.item</string>
<key>NSHumanReadableCopyright</key>
Expand Down
2 changes: 1 addition & 1 deletion src/Plugins/Separator/Separator/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>178</string>
<string>199</string>
<key>HITPFunctionIdentifier</key>
<string>public.separator</string>
<key>NSHumanReadableCopyright</key>
Expand Down
2 changes: 1 addition & 1 deletion src/Plugins/SubMenu/SubMenu/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>178</string>
<string>199</string>
<key>HITPFunctionIdentifier</key>
<string>public.submenu</string>
<key>NSHumanReadableCopyright</key>
Expand Down
Loading

0 comments on commit c0be60c

Please sign in to comment.