From 4c1d83e7b906b640d99cf2a62aefde939beeade9 Mon Sep 17 00:00:00 2001 From: marc-romu <49920661+marc-romu@users.noreply.github.com> Date: Sun, 30 Mar 2025 19:12:49 +0200 Subject: [PATCH 1/5] fix(workflow): not recognizing badge update required --- .github/actions/version-tools/action.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/actions/version-tools/action.yml b/.github/actions/version-tools/action.yml index 5dc82dd5..71752d98 100644 --- a/.github/actions/version-tools/action.yml +++ b/.github/actions/version-tools/action.yml @@ -136,9 +136,9 @@ runs: BADGES_CHANGED=false # Extract current version from README badge - if grep -q "\[\!\[Version\]\]" README.md; then + if grep -q "\[\!\[Version\]" README.md; then # Extract the current version from the badge URL - CURRENT_VERSION_BADGE=$(grep "\[\!\[Version\]\]" README.md) + 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 @@ -149,7 +149,7 @@ runs: 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 + 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 @@ -160,9 +160,9 @@ runs: fi # Check if status badge exists and update it - if grep -q "\[\!\[Status\]\]" README.md; then + if grep -q "\[\!\[Status\]" README.md; then # Get current status badge - CURRENT_STATUS_BADGE=$(grep "\[\!\[Status\]\]" README.md) + CURRENT_STATUS_BADGE=$(grep "\[\!\[Status\]" README.md) echo "Current status badge in README: $CURRENT_STATUS_BADGE" # Extract the current status from the badge URL @@ -173,7 +173,7 @@ runs: 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 + 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 From f831f6cd1a18265130d25062c7b131809d8f219f Mon Sep 17 00:00:00 2001 From: marc-romu <49920661+marc-romu@users.noreply.github.com> Date: Sun, 30 Mar 2025 19:17:51 +0200 Subject: [PATCH 2/5] fix(workflow): not properly updating version and status badges --- .github/actions/version-tools/action.yml | 66 ++++++++++------------- .github/workflows/chore-version-badge.yml | 21 ++++++-- 2 files changed, 44 insertions(+), 43 deletions(-) diff --git a/.github/actions/version-tools/action.yml b/.github/actions/version-tools/action.yml index 71752d98..010ea3be 100644 --- a/.github/actions/version-tools/action.yml +++ b/.github/actions/version-tools/action.yml @@ -135,52 +135,42 @@ runs: if [[ -f "README.md" ]]; then BADGES_CHANGED=false - # Extract current version from README 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 - # 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" + 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 + # Check if README contains status badge 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" + 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." From 6f663a27933785aae721908641556c0e6ae7cb79 Mon Sep 17 00:00:00 2001 From: marc-romu <49920661+marc-romu@users.noreply.github.com> Date: Sun, 30 Mar 2025 19:21:10 +0200 Subject: [PATCH 3/5] refactor(workflow): update color badges --- .github/actions/version-tools/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/version-tools/action.yml b/.github/actions/version-tools/action.yml index 010ea3be..62941ab3 100644 --- a/.github/actions/version-tools/action.yml +++ b/.github/actions/version-tools/action.yml @@ -104,7 +104,7 @@ runs: # Determine color and status based on version if [[ $VERSION == *"-dev"* ]]; then - COLOR="blue" + COLOR="red" STATUS="Development" elif [[ $VERSION == *"-alpha"* ]]; then COLOR="orange" @@ -113,7 +113,7 @@ runs: COLOR="yellow" STATUS="Beta" elif [[ $VERSION == *"-rc"* ]]; then - COLOR="yellowgreen" + COLOR="blue" STATUS="Release Candidate" else COLOR="brightgreen" From dd6d0020abf5116c93033c64fcd103a8f4697bc1 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Sun, 30 Mar 2025 17:21:41 +0000 Subject: [PATCH 4/5] docs: update version badge for main --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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/) From 7bfa5a88986cde96257f1dbfdb0b4fc1e0e3031c Mon Sep 17 00:00:00 2001 From: marc-romu <49920661+marc-romu@users.noreply.github.com> Date: Sun, 30 Mar 2025 19:24:09 +0200 Subject: [PATCH 5/5] refactor(workflow): rename development to unstable development --- .github/actions/version-tools/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/version-tools/action.yml b/.github/actions/version-tools/action.yml index 62941ab3..7f2135ce 100644 --- a/.github/actions/version-tools/action.yml +++ b/.github/actions/version-tools/action.yml @@ -105,7 +105,7 @@ runs: # Determine color and status based on version if [[ $VERSION == *"-dev"* ]]; then COLOR="red" - STATUS="Development" + STATUS="Unstable Development" elif [[ $VERSION == *"-alpha"* ]]; then COLOR="orange" STATUS="Alpha"