-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathMakefile
More file actions
112 lines (93 loc) · 3.26 KB
/
Makefile
File metadata and controls
112 lines (93 loc) · 3.26 KB
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
108
109
110
111
112
.PHONY: update-version increment-major increment-minor increment-patch test build clean install check format
# Version file location
VERSION_FILE := VERSION
GEMSPEC_FILE := chargebee.gemspec
LIB_FILE := lib/chargebee.rb
# Ruby commands
RUBY := ruby
GEM := gem
BUNDLE := bundle
RSPEC := bundle exec rspec
update-version:
@echo "$(VERSION)" > $(VERSION_FILE)
@perl -pi -e 's|s\.version\s*=\s*'\''[.\-\d\w]+'\''|s.version = '\''$(VERSION)'\''|' $(GEMSPEC_FILE)
@perl -pi -e 's|VERSION = '\''[.\-\d\w]+'\''|VERSION = '\''$(VERSION)'\''|' $(LIB_FILE)
@perl -pi -e "s|s\\.date\\s*=\\s*'[^']*'|s.date = '$(shell date +%Y-%m-%d)'|" $(GEMSPEC_FILE)
@echo "Updated version to $(VERSION) and date to $(shell date +%Y-%m-%d)"
@if [ -f "Gemfile.lock" ]; then \
echo "Updating Gemfile.lock..."; \
$(BUNDLE) install --quiet; \
fi
increment-major:
$(eval CURRENT := $(shell cat $(VERSION_FILE)))
$(eval MAJOR := $(shell echo $(CURRENT) | cut -d. -f1))
$(eval NEW_VERSION := $(shell echo $$(($(MAJOR) + 1)).0.0))
@$(MAKE) update-version VERSION=$(NEW_VERSION)
@echo "Version bumped from $(CURRENT) to $(NEW_VERSION)"
increment-minor:
$(eval CURRENT := $(shell cat $(VERSION_FILE)))
$(eval MAJOR := $(shell echo $(CURRENT) | cut -d. -f1))
$(eval MINOR := $(shell echo $(CURRENT) | cut -d. -f2))
$(eval NEW_VERSION := $(MAJOR).$(shell echo $$(($(MINOR) + 1))).0)
@$(MAKE) update-version VERSION=$(NEW_VERSION)
@echo "Version bumped from $(CURRENT) to $(NEW_VERSION)"
increment-patch:
$(eval CURRENT := $(shell cat $(VERSION_FILE)))
$(eval MAJOR := $(shell echo $(CURRENT) | cut -d. -f1))
$(eval MINOR := $(shell echo $(CURRENT) | cut -d. -f2))
$(eval PATCH := $(shell echo $(CURRENT) | cut -d. -f3))
$(eval NEW_VERSION := $(MAJOR).$(MINOR).$(shell echo $$(($(PATCH) + 1))))
@$(MAKE) update-version VERSION=$(NEW_VERSION)
@echo "Version bumped from $(CURRENT) to $(NEW_VERSION)"
install:
@echo "Installing dependencies..."
@$(BUNDLE) install --without development
install-dev:
@echo "Installing development dependencies..."
@$(BUNDLE) install
test:
@echo "Running tests..."
@$(RSPEC)
validate:
@echo "Validating gemspec..."
@$(GEM) build $(GEMSPEC_FILE) --strict --verbose > /dev/null
@rm -f *.gem
@echo "Gemspec is valid"
check: test
@echo "All checks passed!"
build: clean update-manifest
@echo "Building gem..."
@$(GEM) build $(GEMSPEC_FILE)
clean:
@echo "Cleaning build artifacts..."
@rm -f *.gem
@rm -rf pkg/
@rm -rf coverage/
@find . -type f -name '.DS_Store' -delete
clean-bundle:
@echo "Cleaning bundle..."
@rm -rf vendor/bundle
@rm -f Gemfile.lock
update:
@echo "Updating dependencies..."
@$(BUNDLE) update
security-check:
@echo "Checking for security vulnerabilities..."
@$(BUNDLE) audit check --update
outdated:
@echo "Checking for outdated dependencies..."
@$(BUNDLE) outdated
format:
@echo "Formatter not configured."
update-manifest:
@echo "Updating file manifest in $(GEMSPEC_FILE)..."
@$(RUBY) -e \
'files = `git ls-files`.split("\n").sort \
.reject { |f| f =~ /^\./ } \
.reject { |f| f =~ /^(rdoc|pkg)/ } \
.map { |f| " #{f}" } \
.join("\n"); \
spec = File.read("$(GEMSPEC_FILE)"); \
spec.sub!(/s\.files = %w\[.*?\]/m, "s.files = %w[\n#{files}\n ]"); \
File.write("$(GEMSPEC_FILE)", spec)'
@echo "Manifest updated."