release 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/env bash
  2. # Parse command line arguments
  3. minor=false
  4. while [ "$#" -gt 0 ]; do
  5. case "$1" in
  6. --minor) minor=true; shift 1;;
  7. *) echo "Unknown parameter: $1"; exit 1;;
  8. esac
  9. done
  10. # Get the latest release from GitHub
  11. latest_tag=$(gh release list --limit 1 --json tagName --jq '.[0].tagName')
  12. # If there is no tag, exit the script
  13. if [ -z "$latest_tag" ]; then
  14. echo "No tags found"
  15. exit 1
  16. fi
  17. echo "Latest tag: $latest_tag"
  18. # Remove the 'v' prefix and split into major, minor, and patch numbers
  19. version_without_v=${latest_tag#v}
  20. IFS='.' read -ra VERSION <<< "$version_without_v"
  21. if [ "$minor" = true ]; then
  22. # Increment the minor version and reset patch to 0
  23. minor_number=${VERSION[1]}
  24. let "minor_number++"
  25. new_version="${VERSION[0]}.$minor_number.0"
  26. else
  27. # Increment the patch version
  28. patch_number=${VERSION[2]}
  29. let "patch_number++"
  30. new_version="${VERSION[0]}.${VERSION[1]}.$patch_number"
  31. fi
  32. echo "New version: $new_version"
  33. gh workflow run publish.yml -f version="$new_version"