-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathMakefile
107 lines (89 loc) · 3.17 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# Verion Variables
VERSION_FILE = version.txt
TAG_PREFIX = v
DEFAULT_VERSION = 0.0.1
MAJOR_BUMP = major
MINOR_BUMP = minor
PATCH_BUMP = patch
ALPHA_SUFFIX = -alpha
BETA_SUFFIX = -beta
TAG_REGEX = '^[0-9]\+\.[0-9]\+\.[0-9]\+$$' # Regex to match semantic version format (X.Y.Z)
# Get the current version from version.txt or set to default if file does not exist
CURRENT_VERSION = $(shell if [ -f $(VERSION_FILE) ]; then cat $(VERSION_FILE); else echo $(DEFAULT_VERSION); fi)
# Split version into major, minor, patch
CURRENT_MAJOR = $(word 1, $(subst ., ,$(CURRENT_VERSION)))
CURRENT_MINOR = $(word 2, $(subst ., ,$(CURRENT_VERSION)))
CURRENT_PATCH = $(word 3, $(subst ., ,$(CURRENT_VERSION)))
# Targets to bump the version and create a tag
# Bump the version based on the specified type (major, minor, patch)
bump-version:
@if [ "$(TYPE)" == "$(MAJOR_BUMP)" ]; then \
NEW_MAJOR=$$(($(CURRENT_MAJOR) + 1)); \
NEW_MINOR=0; \
NEW_PATCH=0; \
elif [ "$(TYPE)" == "$(MINOR_BUMP)" ]; then \
NEW_MAJOR=$(CURRENT_MAJOR); \
NEW_MINOR=$$(($(CURRENT_MINOR) + 1)); \
NEW_PATCH=0; \
elif [ "$(TYPE)" == "$(PATCH_BUMP)" ]; then \
NEW_MAJOR=$(CURRENT_MAJOR); \
NEW_MINOR=$(CURRENT_MINOR); \
NEW_PATCH=$$(($(CURRENT_PATCH) + 1)); \
else \
echo "Invalid version bump type. Use major, minor, or patch."; \
exit 1; \
fi; \
if [ "$(PRE_RELEASE)" == "alpha" ]; then \
NEW_VERSION=$${NEW_MAJOR}.$${NEW_MINOR}.$${NEW_PATCH}$(ALPHA_SUFFIX); \
elif [ "$(PRE_RELEASE)" == "beta" ]; then \
NEW_VERSION=$${NEW_MAJOR}.$${NEW_MINOR}.$${NEW_PATCH}$(BETA_SUFFIX); \
else \
NEW_VERSION=$${NEW_MAJOR}.$${NEW_MINOR}.$${NEW_PATCH}; \
fi; \
echo "New version: $${NEW_VERSION}"; \
echo $${NEW_VERSION} > $(VERSION_FILE); \
git commit -am "Bump version to $${NEW_VERSION}"; \
git tag $(TAG_PREFIX)$${NEW_VERSION}; \
echo "Version bumped and tagged as $(TAG_PREFIX)$${NEW_VERSION}"; \
cd ui && node updateVersion.js
echo "Version updated in the frontend"
# To create a release (alpha, beta, or final) based on the version bump type
release:
$(MAKE) bump-version TYPE=$(TYPE) PRE_RELEASE=$(PRE_RELEASE)
# Print current version and tag it
show-version:
@echo "Current version: $(CURRENT_VERSION)"
@echo "Current tag: $(TAG_PREFIX)$(CURRENT_VERSION)"
# Initialize the project by installing frontend dependencies
.PHONY: init build start dev electron-package webapp-install
init:
@echo "Initializing the project..."
cd ui && npm install
# Build the frontend and backend
build:
@echo "Building the frontend and backend..."
cd ui && npm run build
go build .
# Default target: run both frontend and backend in development
dev:
@echo "Starting the frontend and backend in development..."
(cd ui && npm start) & go run .
# Run the Electron app in development
electron-dev:
@echo "Starting the Electron app in development..."
(go run .) & cd ui && npm run electron-dev
# Package the Electron app
electron-package:
@echo "Packaging the Electron app..."
go build -o ./ui/build/zasper
cd ui && npm run electron-package
# Install the web app
webapp-install: build
@echo "Installing the web app..."
go install .
# Clean up build artifacts
clean:
@echo "Cleaning up..."
rm -f zasper
rm -rf ui/build
rm -rf ui/dist