Skip to content

Commit

Permalink
ci: add commitizen
Browse files Browse the repository at this point in the history
  • Loading branch information
crgwbr committed Aug 8, 2024
1 parent f5b564f commit 0e65f8b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 34 deletions.
23 changes: 23 additions & 0 deletions .cz.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[tool.commitizen]
name = "cz_conventional_commits"
annotated_tag = true
gpg_sign = true
major_version_zero = true
tag_format = "v$version"
update_changelog_on_bump = true
changelog_merge_prerelease = true
version_provider = "npm"
version_scheme = "semver"
version_files = [
"package.json:version",
]
pre_bump_hooks = [
"npm i",
"npm run lint",
"npm run build",
"pre-commit run --all-files || true",
]
post_bump_hooks = [
"git push origin master $CZ_POST_CURRENT_TAG_VERSION",
"npm publish",
]
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,11 @@ repos:
rev: "v3.3.3"
hooks:
- id: prettier
exclude: "^.git/"

- repo: https://github.com/commitizen-tools/commitizen
rev: v3.28.0
hooks:
- id: commitizen

exclude: "^dist/"
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
## Unreleased
37 changes: 3 additions & 34 deletions bin/publish.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
#!/usr/bin/env bash

set -e

# Validate tag name
TAG_NAME="$1"
if [ -z "$TAG_NAME" ]; then
echo "Tag name is missing"
exit 1
fi

# Remove the "r" prefix from the tag name
PREFIX="v"
VERSION="${TAG_NAME#"$PREFIX"}"
set -euxo pipefail

# Check git status
git fetch --all
Expand All @@ -29,25 +18,5 @@ else
exit 1
fi

# Set version in packages/thelab-ui-js/package.json
PKG_FILE="package.json"
PKG_BK_FILE="${PKG_FILE}.bk"
jq --arg VERSION "$VERSION" '.version=$VERSION' "$PKG_FILE" > "$PKG_BK_FILE"
mv "$PKG_BK_FILE" "$PKG_FILE"
npm i
git add "$PKG_FILE" "package-lock.json"

# Build
npm run lint
npm run build

# Commit
git commit -m "release: ${TAG_NAME}"
git tag -a "$TAG_NAME" -m "New Release: $TAG_NAME"

# Push branch and tags. CI will see the new tag and run a job to publish the packages.
git push origin master
git push origin "$TAG_NAME"

# Publish to NPM
npm publish
# Update version and publish via commitizen
cz bump "$@"

0 comments on commit 0e65f8b

Please sign in to comment.