diff options
| author | Eugene Triguba <hello@eugenetriguba.com> | 2025-10-13 14:49:06 -0400 |
|---|---|---|
| committer | Eugene Triguba <hello@eugenetriguba.com> | 2025-10-13 14:49:06 -0400 |
| commit | cf3a4e09a85bc9d073b517906a0b473f526d43aa (patch) | |
| tree | adcf703d59052b6a48619f0ed4b6f173e7e02fb6 /release.sh | |
| parent | Remove setup in build.yml (diff) | |
| download | checkmate-cf3a4e09a85bc9d073b517906a0b473f526d43aa.zip | |
Add test script, scripts/ folder, and use test script in ci
Diffstat (limited to 'release.sh')
| -rwxr-xr-x | release.sh | 113 |
1 files changed, 0 insertions, 113 deletions
diff --git a/release.sh b/release.sh deleted file mode 100755 index e19c244..0000000 --- a/release.sh +++ /dev/null @@ -1,113 +0,0 @@ -#!/usr/bin/env bash -set -eou pipefail - -main() { - if [ $# -eq 0 ]; then - echo "Error: No version specified" >&2 - echo "Usage: $0 <version>" >&2 - echo "Example: $0 0.5.0" >&2 - exit 1 - fi - - local version=$1 - local today - today=$(date +%Y-%m-%d) - - validate_version_format "$version" - ensure_on_main_branch - ensure_no_uncommitted_changes - ensure_tag_does_not_exist "$version" - - echo "Creating release v$version..." - - echo "Updating CHANGELOG.md..." - update_changelog "$version" "$today" - - echo "Updating README.md..." - update_readme_version_badge "$version" - - echo "Creating commit and tag..." - create_release_commit_and_tag "$version" - - echo "Pushing to remote..." - git push && git push --tags - - echo "Release v$version created and pushed successfully!" -} - -validate_version_format() { - local version=$1 - if ! [[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo "Error: Invalid version format: $version" >&2 - echo "Version must follow semantic versioning (e.g., 0.5.0)" >&2 - exit 1 - fi -} - -ensure_on_main_branch() { - local current_branch - current_branch=$(git branch --show-current) - if [ "$current_branch" != "main" ]; then - echo "Error: Not on main branch (current: $current_branch)" >&2 - exit 1 - fi -} - -ensure_no_uncommitted_changes() { - if ! git diff-index --quiet HEAD --; then - echo "Error: Uncommitted changes detected. Please commit or stash them first." >&2 - exit 1 - fi -} - -ensure_tag_does_not_exist() { - local version=$1 - if git rev-parse "v$version" >/dev/null 2>&1; then - echo "Error: Tag v$version already exists" >&2 - exit 1 - fi -} - -update_changelog() { - local version=$1 - local today=$2 - - if ! grep -q "## \[Unreleased\]" CHANGELOG.md; then - echo "Error: No [Unreleased] section found in CHANGELOG.md" >&2 - exit 1 - fi - - if [[ "$OSTYPE" == "darwin"* ]]; then - sed -i '' "/## \[Unreleased\]/a\\ -\\ -## [$version] - $today -" CHANGELOG.md - else - sed -i "/## \[Unreleased\]/a\\\\n## [$version] - $today" CHANGELOG.md - fi -} - -update_readme_version_badge() { - local version=$1 - - if ! grep -q "version-.*-blue" README.md; then - echo "Error: Version badge not found in README.md" >&2 - exit 1 - fi - - if [[ "$OSTYPE" == "darwin"* ]]; then - sed -i '' "s/version-[0-9]*\.[0-9]*\.[0-9]*-blue/version-$version-blue/" README.md - else - sed -i "s/version-[0-9]*\.[0-9]*\.[0-9]*-blue/version-$version-blue/" README.md - fi -} - -create_release_commit_and_tag() { - local version=$1 - - git add CHANGELOG.md README.md - git commit -m "Release version v$version" - git tag "v$version" -} - -main "$@" |