|
| 1 | +.PHONY: update-version increment-major increment-minor increment-patch test build clean install check |
| 2 | + |
| 3 | +# Version file location |
| 4 | +VERSION_FILE := VERSION |
| 5 | +GEMSPEC_FILE := chargebee.gemspec |
| 6 | +LIB_FILE := lib/chargebee.rb |
| 7 | + |
| 8 | +# Ruby commands |
| 9 | +RUBY := ruby |
| 10 | +GEM := gem |
| 11 | +BUNDLE := bundle |
| 12 | +RSPEC := bundle exec rspec |
| 13 | + |
| 14 | +update-version: |
| 15 | + @echo "$(VERSION)" > $(VERSION_FILE) |
| 16 | + @perl -pi -e 's|s\.version\s*=\s*'\''[.\-\d\w]+'\''|s.version = '\''$(VERSION)'\''|' $(GEMSPEC_FILE) |
| 17 | + @perl -pi -e 's|VERSION = '\''[.\-\d\w]+'\''|VERSION = '\''$(VERSION)'\''|' $(LIB_FILE) |
| 18 | + @echo "Updated version to $(VERSION)" |
| 19 | + @if [ -f "Gemfile.lock" ]; then \ |
| 20 | + echo "Updating Gemfile.lock..."; \ |
| 21 | + $(BUNDLE) install --quiet; \ |
| 22 | + fi |
| 23 | + |
| 24 | +increment-major: |
| 25 | + $(eval CURRENT := $(shell cat $(VERSION_FILE))) |
| 26 | + $(eval MAJOR := $(shell echo $(CURRENT) | cut -d. -f1)) |
| 27 | + $(eval NEW_VERSION := $(shell echo $$(($(MAJOR) + 1)).0.0)) |
| 28 | + @$(MAKE) update-version VERSION=$(NEW_VERSION) |
| 29 | + @echo "Version bumped from $(CURRENT) to $(NEW_VERSION)" |
| 30 | + |
| 31 | +increment-minor: |
| 32 | + $(eval CURRENT := $(shell cat $(VERSION_FILE))) |
| 33 | + $(eval MAJOR := $(shell echo $(CURRENT) | cut -d. -f1)) |
| 34 | + $(eval MINOR := $(shell echo $(CURRENT) | cut -d. -f2)) |
| 35 | + $(eval NEW_VERSION := $(MAJOR).$(shell echo $$(($(MINOR) + 1))).0) |
| 36 | + @$(MAKE) update-version VERSION=$(NEW_VERSION) |
| 37 | + @echo "Version bumped from $(CURRENT) to $(NEW_VERSION)" |
| 38 | + |
| 39 | +increment-patch: |
| 40 | + $(eval CURRENT := $(shell cat $(VERSION_FILE))) |
| 41 | + $(eval MAJOR := $(shell echo $(CURRENT) | cut -d. -f1)) |
| 42 | + $(eval MINOR := $(shell echo $(CURRENT) | cut -d. -f2)) |
| 43 | + $(eval PATCH := $(shell echo $(CURRENT) | cut -d. -f3)) |
| 44 | + $(eval NEW_VERSION := $(MAJOR).$(MINOR).$(shell echo $$(($(PATCH) + 1)))) |
| 45 | + @$(MAKE) update-version VERSION=$(NEW_VERSION) |
| 46 | + @echo "Version bumped from $(CURRENT) to $(NEW_VERSION)" |
| 47 | + |
| 48 | +install: |
| 49 | + @echo "Installing dependencies..." |
| 50 | + @$(BUNDLE) install --without development |
| 51 | + |
| 52 | +install-dev: |
| 53 | + @echo "Installing development dependencies..." |
| 54 | + @$(BUNDLE) install |
| 55 | + |
| 56 | +test: |
| 57 | + @echo "Running tests..." |
| 58 | + @$(RSPEC) |
| 59 | + |
| 60 | +validate: |
| 61 | + @echo "Validating gemspec..." |
| 62 | + @$(GEM) build $(GEMSPEC_FILE) --strict --verbose > /dev/null |
| 63 | + @rm -f *.gem |
| 64 | + @echo "Gemspec is valid" |
| 65 | + |
| 66 | +check: test |
| 67 | + @echo "All checks passed!" |
| 68 | + |
| 69 | +build: clean |
| 70 | + @echo "Building gem..." |
| 71 | + @$(GEM) build $(GEMSPEC_FILE) |
| 72 | + |
| 73 | +clean: |
| 74 | + @echo "Cleaning build artifacts..." |
| 75 | + @rm -f *.gem |
| 76 | + @rm -rf pkg/ |
| 77 | + @rm -rf coverage/ |
| 78 | + @rm -f Gemfile.lock |
| 79 | + @find . -type f -name '.DS_Store' -delete |
| 80 | + |
| 81 | +clean-bundle: |
| 82 | + @echo "Cleaning bundle..." |
| 83 | + @rm -rf vendor/bundle |
| 84 | + @rm -f Gemfile.lock |
| 85 | + |
| 86 | +update: |
| 87 | + @echo "Updating dependencies..." |
| 88 | + @$(BUNDLE) update |
| 89 | + |
| 90 | +security-check: |
| 91 | + @echo "Checking for security vulnerabilities..." |
| 92 | + @$(BUNDLE) audit check --update |
| 93 | + |
| 94 | +outdated: |
| 95 | + @echo "Checking for outdated dependencies..." |
| 96 | + @$(BUNDLE) outdated |
0 commit comments