-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
166 lines (118 loc) · 4.07 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# This Makefile is meant to be exported by Patternslib or Mockup packages.
# .evn include, mainly for a GITHUB_TOKEN.
-include .env
export
# If you want to release on GitHub, make sure to have a .env file with a GITHUB_TOKEN.
# Also see:
# https://github.com/settings/tokens
# and https://github.com/release-it/release-it/blob/master/docs/github-releases.md#automated
ESLINT ?= npx eslint
YARN ?= npx yarn
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 pre commit hook
$(YARN) husky install
touch stamp-yarn
clean-dist:
rm -Rf dist/
.PHONY: clean
clean: clean-dist
rm -f stamp-yarn
rm -Rf node_modules/
.PHONY: eslint
eslint: stamp-yarn
$(ESLINT) ./src
.PHONY: check
check: stamp-yarn eslint
$(YARN) run test
bundle-pre:
@# Override this in your project to add some tasks before the bundle is built.
@# Example: Unlink any linked dependencies.
@# bundle-pre:
@# -yarn unlink @patternslib/patternslib
@# yarn install --force
# 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
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:
ifneq "$(PACKAGE_NAME)" "$(PACKAGE_DEV)"
@# Do not create a zip release for @patternslib/dev
$(eval PACKAGE_VERSION := $(shell node -p "require('./package.json').version"))
@echo Creating $(BUNDLE_NAME)-bundle-$(PACKAGE_VERSION).zip
mkdir -p $(BUNDLE_NAME)-bundle-$(PACKAGE_VERSION)
-cp -R dist/* $(BUNDLE_NAME)-bundle-$(PACKAGE_VERSION)
zip -r $(BUNDLE_NAME)-bundle-$(PACKAGE_VERSION).zip $(BUNDLE_NAME)-bundle-$(PACKAGE_VERSION)/
rm -Rf $(BUNDLE_NAME)-bundle-$(PACKAGE_VERSION)
endif
# Prepare some necessary variables.
prepare-release:
ifeq ($(LEVEL),$(filter $(LEVEL), alpha beta))
@# case alpha or beta pre-release
@# Changelog for the GitHub release when doing prereleases:
@# Include all the changes since the previous pre- or regular release.
$(eval RELEASE_IT_GITHUB_OPTIONS := "")
@# Set level argument for release-it.
$(eval RELEASE_IT_LEVEL := "--preRelease=$(LEVEL)")
else
@# case normal major/minor/patch release
@# Changelog for the GitHub release when doing regular releases:
@# Include all changes since the previous regular release, also including
@# changes from pre-releases.
@# See: https://github.com/release-it/release-it/blob/master/docs/pre-releases.md
$(eval RELEASE_IT_GITHUB_OPTIONS := "--git.tagExclude='*[-]*'")
@# Set level argument for release-it.
$(eval RELEASE_IT_LEVEL := $(LEVEL))
endif
# Do the npm release.
release-npm: prepare-release
npx release-it $(RELEASE_IT_LEVEL)
# Do the GitHub release.
release-github: prepare-release release-zip
@# NOTE: PACKAGE_VERSION is defined in release-zip
npx release-it \
--no-increment \
--no-git \
--no-npm \
--github.release \
--github.update \
--github.assets=$(BUNDLE_NAME)-bundle-$(PACKAGE_VERSION).zip \
--no-github.draft \
$(RELEASE_IT_GITHUB_OPTIONS)
@# Checkout CHANGES.md, which was modified just before
git checkout CHANGES.md
@# Remove the bundle from release-zip again.
@# But don't break if it doesn't exist.
-rm $(BUNDLE_NAME)-bundle-$(PACKAGE_VERSION).zip
release: clean install check release-npm release-github
@# Note: If you want to include the compiled bundle in your npm package you
@# have to allow it in a .npmignore file.
.PHONY: release-major
release-major:
make LEVEL=major release
.PHONY: release-minor
release-minor:
make LEVEL=minor release
.PHONY: release-patch
release-patch:
make LEVEL=patch release
.PHONY: prerelease-alpha
prerelease-alpha:
make LEVEL=alpha release
.PHONY: prerelease-beta
prerelease-beta:
make LEVEL=beta release
.PHONY: serve
serve: stamp-yarn
$(YARN) run start
#