diff --git a/.releaserc.json b/.releaserc.json index d1ccc61..2191b99 100644 --- a/.releaserc.json +++ b/.releaserc.json @@ -13,10 +13,76 @@ "@semantic-release/commit-analyzer", { "preset": "angular", - "releaseRules": "./scripts/release-rules.cjs" + "releaseRules": "./release/release-rules.cjs" + } + ], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "perf", + "section": "Performance Improvements" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "style", + "section": "Styles" + }, + { + "type": "refactor", + "section": "Code Refactoring", + "hidden": true + }, + { + "type": "test", + "section": "Tests", + "hidden": true + }, + { + "type": "build", + "section": "Build System" + }, + { + "type": "ci", + "section": "Continuous Integration" + }, + { + "type": "revert", + "section": "Reverts" + }, + { + "type": "sec", + "section": "Security" + }, + { + "type": "chore", + "section": "Chores" + } + ], + "preMajor": true + }, + "writerOpts": { + "commitsSort": [ + "subject", + "scope" + ] + } } ], - "@semantic-release/release-notes-generator", "@semantic-release/github" ] } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index b1b9235..153c38f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,11 @@ { - "go.testTimeout": "15m" + "go.testTimeout": "15m", + "json.schemas": [ + { + "fileMatch": [ + "/workspaces/gocache/release/.releaserc.submodule.json", + ], + "url": "https://json.schemastore.org/semantic-release.json" + } + ] } \ No newline at end of file diff --git a/memcache/.releaserc.json b/memcache/.releaserc.json deleted file mode 100644 index e8a966f..0000000 --- a/memcache/.releaserc.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": [ - "../.releaserc.json", - "../.releaserc.submodule.json" - ], - "tagFormat": "memcache/v${version}" -} \ No newline at end of file diff --git a/memcache/.releaserc.yml b/memcache/.releaserc.yml new file mode 100644 index 0000000..fcaaf7e --- /dev/null +++ b/memcache/.releaserc.yml @@ -0,0 +1,3 @@ +extends: + - ../release/.releaserc.submodule.json +tagFormat: memcache/v${version} diff --git a/package.json b/package.json index 2e8b010..a92f9a0 100644 --- a/package.json +++ b/package.json @@ -8,9 +8,10 @@ }, "dependencies": { "@semantic-release/git": "^10.0.1", + "conventional-changelog-conventionalcommits": "^8.0.0", "semantic-release": "^24.0.0" }, "scripts": { - "release": "cd $GOMODDIR && semantic-release" + "release": "cd $RELEASEDIR && semantic-release" } -} \ No newline at end of file +} diff --git a/ramcache/.releaserc.json b/ramcache/.releaserc.json deleted file mode 100644 index 315fcbc..0000000 --- a/ramcache/.releaserc.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": [ - "../.releaserc.json", - "../.releaserc.submodule.json" - ], - "tagFormat": "ramcache/v${version}" -} \ No newline at end of file diff --git a/ramcache/.releaserc.yml b/ramcache/.releaserc.yml new file mode 100644 index 0000000..f1dc93d --- /dev/null +++ b/ramcache/.releaserc.yml @@ -0,0 +1,3 @@ +extends: + - ../release/.releaserc.submodule.json +tagFormat: ramcache/v${version} diff --git a/redis/.releaserc.json b/redis/.releaserc.json deleted file mode 100644 index 88d504e..0000000 --- a/redis/.releaserc.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": [ - "../.releaserc.json", - "../.releaserc.submodule.json" - ], - "tagFormat": "redis/v${version}" -} \ No newline at end of file diff --git a/redis/.releaserc.yml b/redis/.releaserc.yml new file mode 100644 index 0000000..22f8185 --- /dev/null +++ b/redis/.releaserc.yml @@ -0,0 +1,3 @@ +extends: + - ../release/.releaserc.submodule.json +tagFormat: redis/v${version} diff --git a/rediscluster/.releaserc.json b/rediscluster/.releaserc.json deleted file mode 100644 index 8797130..0000000 --- a/rediscluster/.releaserc.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": [ - "../.releaserc.json", - "../.releaserc.submodule.json" - ], - "tagFormat": "rediscluster/v${version}" -} \ No newline at end of file diff --git a/rediscluster/.releaserc.yml b/rediscluster/.releaserc.yml new file mode 100644 index 0000000..f2f3c05 --- /dev/null +++ b/rediscluster/.releaserc.yml @@ -0,0 +1,3 @@ +extends: + - ../release/.releaserc.submodule.json +tagFormat: rediscluster/v${version} diff --git a/.releaserc.submodule.json b/release/.releaserc.submodule.json similarity index 62% rename from .releaserc.submodule.json rename to release/.releaserc.submodule.json index 4bb6563..1058e8e 100644 --- a/.releaserc.submodule.json +++ b/release/.releaserc.submodule.json @@ -1,10 +1,13 @@ { + "extends": [ + "../.releaserc.json" + ], "plugins": [ [ "@semantic-release/commit-analyzer", { "preset": "angular", - "releaseRules": "../scripts/release-rules.cjs" + "releaseRules": "../release/release-rules.cjs" } ], "@semantic-release/git" diff --git a/release/README.md b/release/README.md new file mode 100644 index 0000000..bc45462 --- /dev/null +++ b/release/README.md @@ -0,0 +1,3 @@ +# release + +This directory contains the semantic-release configuration for this monorepo. \ No newline at end of file diff --git a/scripts/release-rules.cjs b/release/release-rules.cjs similarity index 61% rename from scripts/release-rules.cjs rename to release/release-rules.cjs index f6ad6b7..1e4b092 100644 --- a/scripts/release-rules.cjs +++ b/release/release-rules.cjs @@ -1,10 +1,20 @@ /** * Custom `releaseRules` rules before v1.0.0. + * For the original rules, see: https://github.com/semantic-release/commit-analyzer/blob/master/lib/default-release-rules.js * - * @type {Array} - */ + * @type {Array<{ +* breaking?: boolean; +* revert?: boolean; +* type?: "feat" | "fix" | "perf" | "chore" | "docs" | "style" | "refactor" | "test" | "build" | "ci" | "revert"; +* scope?: string; +* emoji?: string; +* tag?: string; +* component?: string; +* release: "patch" | "minor" | "major"; +* }>} +*/ module.exports = [ - { breaking: true, release: "minor" }, + { breaking: true, release: "minor" }, // Custom rule for breaking changes { revert: true, release: "patch" }, // Angular { type: "feat", release: "minor" }, @@ -21,7 +31,7 @@ module.exports = [ { tag: "FEATURE", release: "minor" }, { tag: "SECURITY", release: "patch" }, // ESLint - { tag: "Breaking", release: "minor" }, + { tag: "Breaking", release: "minor" }, // Custom rule for breaking changes { tag: "Fix", release: "patch" }, { tag: "Update", release: "minor" }, { tag: "New", release: "minor" }, diff --git a/scripts/release.sh b/scripts/release.sh index 041acac..b978daf 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -1,7 +1,18 @@ #!/usr/bin/env bash set -euo pipefail -# This script is used to release the project in all directories that contain a .releaserc.json file. +# This script is used to release the project in all directories that contain a .releaserc.(json|yml|yaml) file. + +if [[ -z "${CI-}" ]] && [[ "$*" != *--dry-run* ]]; then + echo "🚨 WARNING: You are about to release without the --dry-run flag." + echo "🚨 WARNING: This will publish the new version(s) and create a new git tag(s)." + echo "🚨 WARNING: Are you sure you want to continue? (y/N)" + read -r response + if [[ ! "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then + echo "🚫 Release process aborted." + exit 1 + fi +fi echo "================================================================================" echo "🔧 Starting Release Process" @@ -9,13 +20,17 @@ echo "========================================================================== yarn install -releasedirs=$(find . -name '.releaserc.json' -type f -exec dirname {} \; | sort) +releasercs=$(find . \ + -name '.releaserc.json' -type f \ + -o -name '.releaserc.yml' -type f \ + -o -name '.releaserc.yaml' -type f | sort) -for dir in $releasedirs; do +for rc in $releasercs; do echo "--------------------------------------------------------------------------------" - echo "Releasing in: $dir" + echo "Releasing for $rc" echo "--------------------------------------------------------------------------------" - GOMODDIR=$dir yarn run release "$@" + dir=$(dirname "$rc") + RELEASEDIR=$dir yarn run release "$@" echo " ✔️ Released successfully." done diff --git a/yarn.lock b/yarn.lock index 087aded..be98a32 100644 --- a/yarn.lock +++ b/yarn.lock @@ -858,6 +858,13 @@ conventional-changelog-angular@^8.0.0: dependencies: compare-func "^2.0.0" +conventional-changelog-conventionalcommits@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/conventional-changelog-conventionalcommits/-/conventional-changelog-conventionalcommits-8.0.0.tgz#3fa2857c878701e7f0329db5a1257cb218f166fe" + integrity sha512-eOvlTO6OcySPyyyk8pKz2dP4jjElYunj9hn9/s0OB+gapTO8zwS9UQWrZ1pmF2hFs3vw1xhonOLGcGjy/zgsuA== + dependencies: + compare-func "^2.0.0" + conventional-changelog-writer@^8.0.0: version "8.0.0" resolved "https://registry.yarnpkg.com/conventional-changelog-writer/-/conventional-changelog-writer-8.0.0.tgz#81522ed40400a4ca8ab78a42794aae9667c745ae"