Skip to content

return version to normal #41

return version to normal

return version to normal #41

Workflow file for this run

name: Check and Update Versions
on:
push:
branches:
- '**'
jobs:
update-version:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: pip install poetry jq
- name: Execute version check script
run: |
#!/bin/bash
get_latest_version() {
package_name=$1
latest_version=$(curl -s "https://pypi.org/pypi/$package_name/json" | jq -r '.info.version')
echo "$latest_version"
}
files=$(find . -type f -name "pyproject.toml")
for file in $files; do
current_version=$(grep '^version =' "$file" | awk -F'"' '{print $2}')
package_name=$(grep '^name =' "$file" | awk -F'"' '{print $2}')
latest_version=$(get_latest_version "$package_name")
echo "File: $file"
echo "Current Version: $current_version"
echo "Latest Version on PyPI: $latest_version"
if [ "$current_version" != "$latest_version" ]; then
echo "Version is outdated. Updating..."
# Go to the directory of the relevant pyproject.toml file
dir=$(dirname "$file")
cd "$dir"
# Run poetry lock
poetry lock
# Run pip install -e .
pip install -e .
# Configure poetry to use the PyPI token
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}
# Run poetry publish
# poetry publish --build
# Install the latest package and confirm the version is updated
# installed_version=$(pip show "$package_name" | grep '^Version:' | awk '{print $2}')
if [ "$installed_version" == "$latest_version" ]; then
echo "Version successfully updated."
else
echo "Version update failed." >&2
exit 1
fi
# Return to the root of the repository
cd - > /dev/null
else
echo "Version is up-to-date."
fi
echo "-------------------------------------"
done