Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
.PHONY: update-version increment-major increment-minor increment-patch test build clean install check

# 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)
@echo "Updated version to $(VERSION)"
@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
@echo "Building gem..."
@$(GEM) build $(GEMSPEC_FILE)

clean:
@echo "Cleaning build artifacts..."
@rm -f *.gem
@rm -rf pkg/
@rm -rf coverage/
@rm -f Gemfile.lock
@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
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.67.0