Skip to content

Commit

Permalink
Merge pull request #90 from multiversx/add-build-script
Browse files Browse the repository at this point in the history
Add build script
  • Loading branch information
ssd04 authored Jan 10, 2024
2 parents 6b47d48 + 10bf77e commit f35eb11
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ help:

build:
cd ${cmd_dir} && \
go build -v -ldflags="-X main.appVersion=$(git describe --tags --long --dirty)" -o ${binary}
go build -v -ldflags="-X main.appVersion=$(shell git describe --tags --long --dirty)" -o ${binary}

publisher_type="rabbitmq"
run: build
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,20 @@ deprecated in the future.
Using the `cmd/notifier` package as root, execute the following commands:

- install go dependencies: `go install`
- build executable: `go build -o event-notifier`
- build executable: `go build -ldflags="-X main.appVersion=$(git describe --tags --long --dirty)" -o event-notifier`
- run `./event-notifier`

Or use the build script:
```bash
bash scripts/build.sh
```

---

This can also be done using a single command from `Makefile`:
```bash
# by default, rabbitmq type
# `run` command will also trigger make `build` command
make run

# specify notifier running mode (eq: rabbitmq, ws)
Expand Down
21 changes: 21 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

# set -x

cmd_dir="cmd/notifier"
binary=event-notifier

if ! [ -x "$(command -v go)" ]; then
echo -e "go has to be installed"
exit 1
fi

if ! [ -x "$(command -v git)" ]; then
echo -e "git has to be installed"
exit 1
fi

cd ${cmd_dir} && \
go build -v \
-ldflags="-X main.appVersion=$(git describe --tags --long --dirty)" \
-o ${binary}

0 comments on commit f35eb11

Please sign in to comment.