Skip to content

Commit 73bb15b

Browse files
feat: add makefile for building git-semver (#24)
Signed-off-by: Andrew Brandt <andrew.brandt@hashgraph.com>
1 parent afbe261 commit 73bb15b

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ git-semver
33
.testworkdir
44

55
dist/
6+
7+
/bin

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,19 @@ $ docker pull psanetra/git-semver
1515

1616
To build locally for testing, ensure you have `go` installed.
1717

18+
Run `make build` to generate a `git-semver` package at `/bin/git-semver`.
19+
20+
The make file also allows for input of filenames.
21+
22+
To manually build without the use of the make file:
23+
1824
1. `cd` to the `cli` folder of the repo.
1925
2. Run `go build -o <output_file>` to build the package.
20-
3. Once complete, copy the package to a location in your terminal's path.
21-
4. Run `source ~/.bashrc` (or appropriate `.rc` file for your terminal) to include the new package.
26+
27+
Once the build is complete, follow these steps to ensure you can run the package:
28+
29+
1. Once complete, copy the package to a location in your terminal's path.
30+
2. Run `source ~/.bashrc` (or appropriate `.rc` file for your terminal) to include the new package.
2231

2332
## Commands
2433

makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Makefile at repo root
2+
3+
BINARY_NAME ?= git-semver
4+
BUILD_DIR := cli
5+
BIN_DIR := bin
6+
7+
.PHONY: all build clean test
8+
9+
all: build
10+
11+
## Build the CLI into ./bin/
12+
build:
13+
@echo "Building $(BINARY_NAME) from $(BUILD_DIR)..."
14+
@mkdir -p $(BIN_DIR)
15+
@cd $(BUILD_DIR) && go build -o ../$(BIN_DIR)/$(BINARY_NAME)
16+
17+
## Run all Go tests
18+
test:
19+
@echo "Running tests..."
20+
@go test ./...
21+
22+
## Remove build artifacts
23+
clean:
24+
@echo "Cleaning build artifacts..."
25+
@rm -rf $(BIN_DIR)/

0 commit comments

Comments
 (0)