Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makefile: Use file modification checking and better use of Make featu… #28

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
33 changes: 18 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,37 @@ PACKAGE_DEV=@patternslib/dev
PACKAGE_NAME := $(shell node -p "require('./package.json').name")
BUNDLE_NAME := $(subst @patternslib/,,$(subst @plone/,,$(PACKAGE_NAME)))

.PHONY: install
stamp-yarn install:
$(YARN) install

install-husky .husky/_/husky.sh:
@echo DEBUG: install husky
# Install pre commit hook
$(YARN) husky install
touch stamp-yarn


clean-dist:
install node_modules/: yarn.lock install-husky
@echo DEBUG: install
$(YARN) install


clean-dist dist/: package.json
rm -Rf dist/


.PHONY: clean
clean: clean-dist
rm -f stamp-yarn
clean node_modules/: yarn.lock clean-dist
rm -Rf node_modules/


.PHONY: eslint
eslint: stamp-yarn
eslint: install
$(ESLINT) ./src


.PHONY: check
check: stamp-yarn eslint
check: install eslint
$(YARN) run test


.PHONY: bundle-pre
bundle-pre:
@# Override this in your project to add some tasks before the bundle is built.
@# Example: Unlink any linked dependencies.
Expand All @@ -57,16 +60,15 @@ bundle-pre:
# Compile the bundle.
# NOTE: When using the normal workflow - e.g. `make release-minor`, the
# relase-it config runs `make bundle` after the version bump.
.PHONY: bundle
bundle: clean-dist bundle-pre stamp-yarn
bundle dist/: package.json clean-dist bundle-pre install
ifneq "$(PACKAGE_NAME)" "$(PACKAGE_DEV)"
@# Do not build a bundle for @patternslib/dev
$(YARN) run build
endif


# Create a ZIP file from the bundle which is uploaded to the GitHub release tag.
release-zip:
release-zip $(BUNDLE_NAME)-bundle-$(PACKAGE_VERSION).zip:
ifneq "$(PACKAGE_NAME)" "$(PACKAGE_DEV)"
@# Do not create a zip release for @patternslib/dev
$(eval PACKAGE_VERSION := $(shell node -p "require('./package.json').version"))
Expand Down Expand Up @@ -104,17 +106,18 @@ endif


# Do the npm release.
release-npm: prepare-release
release-npm: prepare-release build
npx release-it $(RELEASE_IT_LEVEL)


# Do the GitHub release.
release-github: prepare-release release-zip
release-github: prepare-release build release-zip
@# NOTE: PACKAGE_VERSION is defined in release-zip

npx release-it \
--no-increment \
--no-git \
--no-git.tag \
--no-npm \
--github.release \
--github.update \
Expand Down
Loading