extension_ci: Improve behavior when no Rust is present (#43953)

Finn Evers created

Release Notes:

- N/A

Change summary

.github/workflows/extension_bump.yml                | 20 ++++----
tooling/xtask/src/tasks/workflows/extension_bump.rs | 32 ++++++--------
2 files changed, 24 insertions(+), 28 deletions(-)

Detailed changes

.github/workflows/extension_bump.yml 🔗

@@ -114,21 +114,21 @@ jobs:
       run: |
         OLD_VERSION="${{ needs.check_bump_needed.outputs.current_version }}"
 
-        cat <<EOF > .bumpversion.cfg
-        [bumpversion]
-        current_version = "$OLD_VERSION"
+        if [[ -f "extension.toml" ]]; then
+            EXTENSION_TOML="extension.toml"
+        fi
 
-        [bumpversion:file:Cargo.toml]
+        if [[ -f "Cargo.toml" ]]; then
+            CARGO_TOML="Cargo.toml"
+        fi
 
-        [bumpversion:file:extension.toml]
+        bump2version --verbose --current-version "$OLD_VERSION" --no-configured-files ${{ inputs.bump-type }} "$EXTENSION_TOML" "$CARGO_TOML"
 
-        EOF
+        if [[ -f "Cargo.toml" ]]; then
+            cargo update --workspace
+        fi
 
-        bump2version --verbose ${{ inputs.bump-type }}
         NEW_VERSION="$(sed -n 's/version = \"\(.*\)\"/\1/p' < extension.toml)"
-        cargo update --workspace
-
-        rm .bumpversion.cfg
 
         echo "new_version=${NEW_VERSION}" >> "$GITHUB_OUTPUT"
       shell: bash -euxo pipefail {0}

tooling/xtask/src/tasks/workflows/extension_bump.rs 🔗

@@ -13,16 +13,6 @@ use crate::tasks::workflows::{
     },
 };
 
-const BUMPVERSION_CONFIG: &str = indoc! {r#"
-    [bumpversion]
-    current_version = "$OLD_VERSION"
-
-    [bumpversion:file:Cargo.toml]
-
-    [bumpversion:file:extension.toml]
-    "#
-};
-
 const VERSION_CHECK: &str = r#"sed -n 's/version = \"\(.*\)\"/\1/p' < extension.toml"#;
 
 // This is used by various extensions repos in the zed-extensions org to bump extension versions.
@@ -252,20 +242,26 @@ fn bump_version(current_version: &JobOutput, bump_type: &WorkflowInput) -> (Step
         indoc! {r#"
             OLD_VERSION="{}"
 
-            cat <<EOF > .bumpversion.cfg
-            {}
-            EOF
+            if [[ -f "extension.toml" ]]; then
+                EXTENSION_TOML="extension.toml"
+            fi
 
-            bump2version --verbose {}
-            NEW_VERSION="$({})"
-            cargo update --workspace
+            if [[ -f "Cargo.toml" ]]; then
+                CARGO_TOML="Cargo.toml"
+            fi
+
+            bump2version --verbose --current-version "$OLD_VERSION" --no-configured-files {} "$EXTENSION_TOML" "$CARGO_TOML"
 
-            rm .bumpversion.cfg
+            if [[ -f "Cargo.toml" ]]; then
+                cargo update --workspace
+            fi
+
+            NEW_VERSION="$({})"
 
             echo "new_version=${{NEW_VERSION}}" >> "$GITHUB_OUTPUT"
             "#
         },
-        current_version, BUMPVERSION_CONFIG, bump_type, VERSION_CHECK
+        current_version, bump_type, VERSION_CHECK
     ))
     .id("bump-version");