diff --git a/.github/actions/version-tools/action.yml b/.github/actions/version-tools/action.yml index 5dc82dd5..7f2135ce 100644 --- a/.github/actions/version-tools/action.yml +++ b/.github/actions/version-tools/action.yml @@ -104,8 +104,8 @@ runs: # Determine color and status based on version if [[ $VERSION == *"-dev"* ]]; then - COLOR="blue" - STATUS="Development" + COLOR="red" + STATUS="Unstable Development" elif [[ $VERSION == *"-alpha"* ]]; then COLOR="orange" STATUS="Alpha" @@ -113,7 +113,7 @@ runs: COLOR="yellow" STATUS="Beta" elif [[ $VERSION == *"-rc"* ]]; then - COLOR="yellowgreen" + COLOR="blue" STATUS="Release Candidate" else COLOR="brightgreen" @@ -135,52 +135,42 @@ runs: if [[ -f "README.md" ]]; then BADGES_CHANGED=false - # Extract current version from README badge - if grep -q "\[\!\[Version\]\]" README.md; then - # Extract the current version from the badge URL - CURRENT_VERSION_BADGE=$(grep "\[\!\[Version\]\]" README.md) - echo "Current version badge in README: $CURRENT_VERSION_BADGE" - - # Extract just the version number from the current badge - CURRENT_VERSION_IN_BADGE=$(echo "$CURRENT_VERSION_BADGE" | grep -oP 'version-\K[^-]*(?=-|-)' | sed 's/%2E/./g' | sed 's/--/-/g') - echo "Extracted version from README badge: $CURRENT_VERSION_IN_BADGE" + # Get the current version from Solution.props + echo "Current version from Solution.props: $VERSION" + + # Create new badge URLs + VERSION_BADGE_URL="https://img.shields.io/badge/version-$ENCODED_VERSION-$COLOR" + STATUS_BADGE_URL="https://img.shields.io/badge/status-$STATUS-$COLOR" + + # Create badge markdown + VERSION_BADGE="[![Version]($VERSION_BADGE_URL)](https://github.com/architects-toolkit/SmartHopper/releases)" + STATUS_BADGE="[![Status]($STATUS_BADGE_URL)](https://github.com/architects-toolkit/SmartHopper/releases)" + + echo "New version badge: $VERSION_BADGE" + echo "New status badge: $STATUS_BADGE" + + # Check if README contains version badge + if grep -q "\[\!\[Version\]" README.md; then + echo "Found version badge in README" - # Compare actual versions, not just badge strings - if [[ "$CURRENT_VERSION_IN_BADGE" != "$VERSION" ]]; then - echo "Version mismatch: README has '$CURRENT_VERSION_IN_BADGE', Solution.props has '$VERSION'" - # Use sed to replace the version badge - sed -i "s|\[\!\[Version\]\](https://img\.shields\.io/badge/version[^)]*)|[![Version]($VERSION_BADGE_URL)|g" README.md - echo "Updated version badge" - BADGES_CHANGED=true - else - echo "Version badge already up to date (both have version $VERSION)" - fi + # Always update the badges with the current version from Solution.props + sed -i "s|\[\!\[Version\](https://img\.shields\.io/badge/version[^)]*)|[![Version]($VERSION_BADGE_URL)|g" README.md + echo "Updated version badge" + BADGES_CHANGED=true else - echo "No version badge found in README" + echo "No version badge found in README to replace" fi - # Check if status badge exists and update it - if grep -q "\[\!\[Status\]\]" README.md; then - # Get current status badge - CURRENT_STATUS_BADGE=$(grep "\[\!\[Status\]\]" README.md) - echo "Current status badge in README: $CURRENT_STATUS_BADGE" - - # Extract the current status from the badge URL - CURRENT_STATUS_IN_BADGE=$(echo "$CURRENT_STATUS_BADGE" | grep -oP 'status-\K[^-]*(?=-)') - echo "Extracted status from README badge: $CURRENT_STATUS_IN_BADGE" + # Check if README contains status badge + if grep -q "\[\!\[Status\]" README.md; then + echo "Found status badge in README" - # Compare status values - if [[ "$CURRENT_STATUS_IN_BADGE" != "$STATUS" ]]; then - echo "Status mismatch: README has '$CURRENT_STATUS_IN_BADGE', should be '$STATUS'" - # Use sed to replace the status badge - sed -i "s|\[\!\[Status\]\](https://img\.shields\.io/badge/status[^)]*)|[![Status]($STATUS_BADGE_URL)|g" README.md - echo "Updated status badge" - BADGES_CHANGED=true - else - echo "Status badge already up to date (both have status $STATUS)" - fi + # Always update the status badge + sed -i "s|\[\!\[Status\](https://img\.shields\.io/badge/status[^)]*)|[![Status]($STATUS_BADGE_URL)|g" README.md + echo "Updated status badge" + BADGES_CHANGED=true else - echo "No status badge found in README" + echo "No status badge found in README to replace" fi # Check if badges were changed diff --git a/.github/workflows/chore-version-badge.yml b/.github/workflows/chore-version-badge.yml index 769a3770..2cf77d59 100644 --- a/.github/workflows/chore-version-badge.yml +++ b/.github/workflows/chore-version-badge.yml @@ -90,14 +90,25 @@ jobs: run: | echo "Creating new branch: ${{ env.BADGE_BRANCH }}" git checkout -b ${{ env.BADGE_BRANCH }} - git add README.md - git commit -m "docs: update version badge for ${{ env.TARGET_BRANCH }}" - git push origin ${{ env.BADGE_BRANCH }} + + # Check if there are actual changes to commit + if [[ -n "$(git status --porcelain README.md)" ]]; then + echo "Changes detected in README.md, committing and pushing" + git add README.md + git commit -m "docs: update version badge for ${{ env.TARGET_BRANCH }}" + git push origin ${{ env.BADGE_BRANCH }} + echo "CHANGES_PUSHED=true" >> $GITHUB_ENV + else + echo "No actual changes detected in README.md despite badges-changed=true" + echo "This might indicate a parsing issue in the version-tools action" + echo "::warning::No changes to commit for README.md despite badges-changed=true" + echo "CHANGES_PUSHED=false" >> $GITHUB_ENV + fi - name: Create PR - if: steps.update-badge.outputs.badges-changed == 'true' + if: steps.update-badge.outputs.badges-changed == 'true' && env.CHANGES_PUSHED == 'true' run: | - PR_TITLE="docs: update version badge for ${{ env.TARGET_BRANCH }} to ${{ steps.version-check.outputs.version }}" + PR_TITLE="docs: update version badge for ${{ env.TARGET_BRANCH }} to ${{ steps.update-badge.outputs.version }}" PR_BODY="This PR updates the version badge in the README.md to match the current version in Solution.props. This is an automated PR created by the Update Version Badge workflow." diff --git a/README.md b/README.md index 0a103e00..01f55b3f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # SmartHopper - AI-Powered Grasshopper3D Plugin -[![Version](https://img.shields.io/badge/version-0%2E1%2E3--dev%2E250319-yellow)](https://github.com/architects-toolkit/SmartHopper/releases) -[![Status](https://img.shields.io/badge/status-Unstable%20development-yellow)](https://github.com/architects-toolkit/SmartHopper/releases) +[![Version](https://img.shields.io/badge/version-0%2E1%2E3--dev%2E250330-red)](https://github.com/architects-toolkit/SmartHopper/releases) +[![Status](https://img.shields.io/badge/status-Development-red)](https://github.com/architects-toolkit/SmartHopper/releases) [![Grasshopper](https://img.shields.io/badge/plugin_for-Grasshopper3D-darkgreen?logo=rhinoceros)](https://www.rhino3d.com/) [![MistralAI](https://img.shields.io/badge/AI--powered-MistralAI-orange)](https://mistral.ai/) [![OpenAI](https://img.shields.io/badge/AI--powered-OpenAI-blue?logo=openai)](https://openai.com/)