new-feature-version.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/bin/bash
  2. # Get the current version from package.json
  3. PREV_VERSION=$(jq -r '.version' package.json)
  4. echo "Prev Feature Version $PREV_VERSION"
  5. # Extract the version number by removing the "-unstable" suffix
  6. VERSION="${PREV_VERSION%-unstable}"
  7. echo "New Master Version $VERSION"
  8. # Split the version number into major, minor, and patch components
  9. IFS='.' read -ra VERSION_ARRAY <<< "$VERSION"
  10. # Extract the minor and patch components
  11. MINOR_VERSION="${VERSION_ARRAY[1]}"
  12. PATCH_VERSION="${VERSION_ARRAY[2]}"
  13. # Decrement the minor version for backport branch
  14. ((MINOR_VERSION--))
  15. # Increment patch for new backport branch
  16. NEXT_BACK_PORT_VERSION="${VERSION_ARRAY[0]}.${MINOR_VERSION}.x"
  17. # Increment the minor component for the new unstable version
  18. ((MINOR_VERSION++))
  19. ((MINOR_VERSION++))
  20. # Construct the new unstable version
  21. NEXT_VERSION="${VERSION_ARRAY[0]}.${MINOR_VERSION}.0-unstable"
  22. echo "Next Unstable Version: $NEXT_VERSION"
  23. echo "Next Backport Version: $NEXT_BACK_PORT_VERSION"
  24. # Export the versions to the GitHub Actions environment
  25. echo "VERSION=$VERSION" >> "$GITHUB_ENV"
  26. echo "NEXT_VERSION=$NEXT_VERSION" >> "$GITHUB_ENV"
  27. echo "NEXT_BACK_PORT_VERSION=$NEXT_BACK_PORT_VERSION" >> "$GITHUB_ENV"