-
Notifications
You must be signed in to change notification settings - Fork 536
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
name: Check and Update Versions | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
|
||
jobs: | ||
update-version: | ||
env: | ||
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 | ||
#testing | ||
pwd | ||
ls | ||
# 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 | ||
pwd | ||
else | ||
echo "Version is up-to-date." | ||
fi | ||
echo "-------------------------------------" | ||
done |