diff --git a/scripts/release.sh b/scripts/release.sh index dafec3a..67fd455 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -1,12 +1,29 @@ #!/bin/bash set -e +# Run the build script npm run build + +# Get the version from package.json VERSION=$(node -p "require('./package.json').version") +# Get the changelog content CHANGELOG_CONTENT=$(cat docs/CHANGELOG.md) -git add . -git tag -a "v${VERSION}" -m "Release ${VERSION}: ${CHANGELOG_CONTENT}" -git commit -m "chore: release version ${VERSION}" -git push origin main --tags -npm publish --access public \ No newline at end of file + +# Check for changes in the working directory +if [ -n "$(git status --porcelain)" ]; then + # There are changes to commit + git add . + git commit -m "chore: release version ${VERSION}" + + # Tag the commit with the new version + git tag -a "v${VERSION}" -m "Release ${VERSION}: ${CHANGELOG_CONTENT}" + + # Push the commit and the tag + git push origin main --tags +else + echo "No changes to commit." +fi + +# Publish the package +npm publish --access public