This repository has been archived by the owner on Aug 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add 'make cutarelease' and other dev conveniences (#191)
Separate 'lint' and 'test'. Add testing of node v19.
- Loading branch information
Showing
5 changed files
with
86 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Lint this change with the latest node LTS. | ||
name: Lint | ||
|
||
# https://gitpro.ttaallkk.topmunity/t/how-to-trigger-an-action-on-push-or-pull-request-but-not-both/16662/2 | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths-ignore: | ||
- '*.md' | ||
pull_request: | ||
branches: | ||
- main | ||
paths-ignore: | ||
- '*.md' | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: '18' | ||
- run: npm install | ||
- run: npm run lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Some targets depend on https://github/trentm/json being on the PATH. | ||
JSON ?= json | ||
|
||
.PHONY: all | ||
all: | ||
npm install | ||
|
||
.PHONY: test | ||
test: | ||
npm test | ||
|
||
.PHONY: lint | ||
lint: | ||
npm run lint | ||
|
||
# Ensure CHANGELOG.md and package.json have the same version for a release. | ||
.PHONY: check-version | ||
check-version: | ||
@echo version is: $(shell cat package.json | json version) | ||
[[ v`cat package.json | $(JSON) version` == `grep '^## ' CHANGELOG.md | head -1 | tail -1 | awk '{print $$2}'` ]] | ||
|
||
.PHONY: check | ||
check: lint check-version | ||
|
||
# Tag and release a new release based on the current package.json#version. | ||
# This long bit of Makefile does the following: | ||
# - ensure the repo isn't dirty (changed files) | ||
# - warn if we have a tag for this release already | ||
# - interactively confirm | ||
# - git tag | ||
# - npm publish | ||
.PHONY: cutarelease | ||
cutarelease: check | ||
[[ `basename $(shell git symbolic-ref HEAD)` == 'main' ]] # Can only release from 'main' branch. | ||
[[ -z `git status --short` ]] # If this fails, the working dir is dirty. | ||
@which $(JSON) 2>/dev/null 1>/dev/null && \ | ||
ver=$(shell $(JSON) -f package.json version) && \ | ||
name=$(shell $(JSON) -f package.json name) && \ | ||
publishedVer=$(shell npm view -j $(shell $(JSON) -f package.json name)@$(shell $(JSON) -f package.json version) version 2>/dev/null) && \ | ||
if [[ -n "$$publishedVer" ]]; then \ | ||
echo "error: $$name@$$ver is already published to npm"; \ | ||
exit 1; \ | ||
fi && \ | ||
echo "** Are you sure you want to tag and publish $$name@$$ver to npm?" && \ | ||
echo "** Enter to continue, Ctrl+C to abort." && \ | ||
read | ||
ver=$(shell cat package.json | $(JSON) version) && \ | ||
date=$(shell date -u "+%Y-%m-%d") && \ | ||
git tag -a "v$$ver" -m "version $$ver ($$date)" && \ | ||
git push origin "v$$ver" && \ | ||
npm publish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters