Skip to content

Instantly share code, notes, and snippets.

@Tedfulk
Created March 12, 2024 19:08
Show Gist options
  • Save Tedfulk/11545e8a62eff0d58a780d0de02d355c to your computer and use it in GitHub Desktop.
Save Tedfulk/11545e8a62eff0d58a780d0de02d355c to your computer and use it in GitHub Desktop.
function update_pyproject_version
if test -f pyproject.toml
# Extract the current version
set current_version (awk -F '"' '/version =/ {print $2}' pyproject.toml)
# Break down the version into major, minor, and patch
set -l major (echo $current_version | cut -d'.' -f1)
set -l minor (echo $current_version | cut -d'.' -f2)
set -l patch (echo $current_version | cut -d'.' -f3)
# Increment the version
if test $patch = 9
set patch 0
set minor (math $minor + 1)
else
set patch (math $patch + 1)
end
# Construct the new version
set new_version "$major.$minor.$patch"
# Update the version in the file
sed -i '' "s/version = \"$current_version\"/version = \"$new_version\"/" pyproject.toml
echo "Version updated to $new_version."
# Building the package
poetry build
echo "Package built."
# Publishing the package - ensure you're authenticated or use 'poetry publish --build' to prompt for credentials
poetry publish
echo "Package published."
else
echo "pyproject.toml not found in the current directory."
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment