Skip to content

Commit

Permalink
v0.0.9: Fix installer script and add Docker image for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Scott committed Jan 28, 2019
1 parent a2bbc6c commit 902abae
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ FROM ubuntu:latest
RUN apt-get update -qq && apt-get install curl -yy

# Install Homer with the one-liner script
COPY ../../docs/install.sh install.sh
RUN ./install.sh
COPY docs/install.sh install.sh
RUN bash install.sh
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ INSTALL_FILES=`find $(DIRS) -type f`
VERSION=`cat share/homer/VERSION`

# Install this script to /usr/local
all: clean test share/man/man1/homer.1 install
all: clean share/man/man1/homer.1 install

# Install gem dependencies
vendor/bundle:
Expand Down
40 changes: 30 additions & 10 deletions docs/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,47 @@
# sure that Bash will be there, though, so that's why this script is
# written in Bash instead of ZSH.

if [[ $(uname) == 'Darwin' ]]; then
mktmp="mktemp"
else
mktmp="mktmp"
fi

# Find latest released version from GitHub API
repo="https://api.github.com/repos/tubbo/homer/releases/latest"
version=$(curl --silent "$repo" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
tmpdir=$(mktmp -d)
name="homer-$version"
filename="$name.tar.gz"
tmpdir=$($mktmp -d)
sourcedir="homer-${version:1}"
filename="homer-$version.tar.gz"

pushd "$tmpdir"
pushd "$tmpdir" > /dev/null 2>&1

# Download release source code from GitHub
curl -L "https://github.com/tubbo/homer/archive/$version.tar.gz" -o "$filename"
echo "Downloading Homer $version from GitHub..."
curl -sL "https://github.com/tubbo/homer/archive/$version.tar.gz" -o "$filename"

# Extract the source code to /tmp
tar -zxvf "$filename"
tar -zxf "$filename"

pushd "$name"
export SUDO=$([ "$(id -u)" == "0" ] && "sudo")

# Install homer to /usr/local
sudo make && echo "Installed Homer v$version"
# Install homer from source to /usr/local and capture exit code
pushd "$sourcedir" > /dev/null 2>&1
output=$($SUDO make)
code=$?

popd;popd
# Print whether Homer was installed or not
if [[ "$code" == 0 ]]; then
echo "Homer $version has been installed!"
echo "Get started by running \`homer init [REPO]\`"
echo "Or, run \`homer\` to see the full list of commands"
else
echo "Error installing Homer"
fi

# Clean up the source directory
popd > /dev/null 2>&1
popd > /dev/null 2>&1
rm -rf "$tmpdir"

exit $code
2 changes: 1 addition & 1 deletion share/homer/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.0.8
v0.0.9
1 change: 1 addition & 0 deletions test/homer-install-test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
load test_helper

@test "install the latest version with the installer script" {
skip "disabled for now because it's too slow"
run docker run --rm -it homer:latest homer version

assert_success
Expand Down

0 comments on commit 902abae

Please sign in to comment.