Skip to content

Commit

Permalink
Invoke post_compile hook before install and add pre/post_install hooks (
Browse files Browse the repository at this point in the history
#68)

* Execute post_compile hook before install step

* add pre_install and post_install hooks

* Update README.md
  • Loading branch information
seeppp authored Jan 19, 2022
1 parent 219c56a commit 4d11b09
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,13 @@ $ git push heroku master
### Hooks

You can place custom scripts to be run before and after compiling your Swift
You can place custom scripts to be run before and after compiling and installing your Swift
source code inside the following files in your repository:

- `bin/pre_compile`
- `bin/post_compile`
- `bin/pre_install`
- `bin/post_install`

This is useful if you need to customize the final image.

Expand Down
5 changes: 3 additions & 2 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,15 @@ cd $BUILD_DIR
source "$BIN_DIR/steps/hooks/pre_compile" "$BUILD_DIR" "$CACHE_DIR" "$ENV_DIR"
source "$BIN_DIR/steps/ssh"
source "$BIN_DIR/steps/swift-build"
source "$BIN_DIR/steps/hooks/post_compile" "$BUILD_DIR" "$CACHE_DIR" "$ENV_DIR"
if [[ -z "$RUN_TESTS" ]]; then
source "$BIN_DIR/steps/hooks/pre_install" "$BUILD_DIR" "$CACHE_DIR" "$ENV_DIR"
source "$BIN_DIR/steps/swift-install"
source "$BIN_DIR/steps/hooks/post_install" "$BUILD_DIR" "$CACHE_DIR" "$ENV_DIR"
fi

# Setup application environment
mkdir -p $BUILD_DIR/.profile.d

set-env PATH '$HOME/.swift-bin:$PATH'
set-env LD_LIBRARY_PATH '$LD_LIBRARY_PATH:$HOME/.swift-lib'

source "$BIN_DIR/steps/hooks/post_compile" "$BUILD_DIR" "$CACHE_DIR" "$ENV_DIR"
7 changes: 7 additions & 0 deletions bin/steps/hooks/post_install
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

if [ -f bin/post_install ]; then
echo "-----> Running post-install hook"
chmod +x bin/post_install
./bin/post_install
fi
6 changes: 6 additions & 0 deletions bin/steps/hooks/pre_install
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

if [ -f bin/pre_install ]; then
echo "-----> Running pre-install hook"
source ./bin/pre_install
fi

0 comments on commit 4d11b09

Please sign in to comment.