extension_ci: Use `head_ref` for version comparison (#49970)

Finn Evers created

Release Notes:

- N/A

Change summary

.github/workflows/extension_bump.yml                | 7 ++++---
.github/workflows/extension_tests.yml               | 7 ++++---
tooling/xtask/src/tasks/workflows/extension_bump.rs | 6 +++---
3 files changed, 11 insertions(+), 9 deletions(-)

Detailed changes

.github/workflows/extension_bump.yml 🔗

@@ -38,10 +38,9 @@ jobs:
       name: extension_bump::compare_versions
       run: |
         CURRENT_VERSION="$(sed -n 's/^version = \"\(.*\)\"/\1/p' < extension.toml | tr -d '[:space:]')"
-        PR_PARENT_SHA="${{ github.event.pull_request.head.sha }}"
 
-        if [[ -n "$PR_PARENT_SHA" ]]; then
-            git checkout "$PR_PARENT_SHA"
+        if [[ -n "$PR_PARENT_REF" ]]; then
+            git checkout "$PR_PARENT_REF"
         elif BRANCH_PARENT_SHA="$(git merge-base origin/main origin/zed-zippy-autobump)"; then
             git checkout "$BRANCH_PARENT_SHA"
         else
@@ -55,6 +54,8 @@ jobs:
             echo "version_changed=true" >> "$GITHUB_OUTPUT"
 
         echo "current_version=${CURRENT_VERSION}" >> "$GITHUB_OUTPUT"
+      env:
+        PR_PARENT_REF: ${{ github.head_ref }}
     outputs:
       version_changed: ${{ steps.compare-versions-check.outputs.version_changed }}
       current_version: ${{ steps.compare-versions-check.outputs.current_version }}

.github/workflows/extension_tests.yml 🔗

@@ -113,10 +113,9 @@ jobs:
       name: extension_bump::compare_versions
       run: |
         CURRENT_VERSION="$(sed -n 's/^version = \"\(.*\)\"/\1/p' < extension.toml | tr -d '[:space:]')"
-        PR_PARENT_SHA="${{ github.event.pull_request.head.sha }}"
 
-        if [[ -n "$PR_PARENT_SHA" ]]; then
-            git checkout "$PR_PARENT_SHA"
+        if [[ -n "$PR_PARENT_REF" ]]; then
+            git checkout "$PR_PARENT_REF"
         elif BRANCH_PARENT_SHA="$(git merge-base origin/main origin/zed-zippy-autobump)"; then
             git checkout "$BRANCH_PARENT_SHA"
         else
@@ -130,6 +129,8 @@ jobs:
             echo "version_changed=true" >> "$GITHUB_OUTPUT"
 
         echo "current_version=${CURRENT_VERSION}" >> "$GITHUB_OUTPUT"
+      env:
+        PR_PARENT_REF: ${{ github.head_ref }}
     - name: extension_tests::verify_version_did_not_change
       run: |
         if [[ ${{ steps.compare-versions-check.outputs.version_changed }} == "true" && "${{ github.event_name }}" == "pull_request" && "${{ github.event.pull_request.user.login }}" != "zed-zippy[bot]" ]] ; then

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

@@ -149,10 +149,9 @@ pub(crate) fn compare_versions() -> (Step<Run>, StepOutput, StepOutput) {
     let check_needs_bump = named::bash(formatdoc! {
     r#"
         CURRENT_VERSION="$({VERSION_CHECK})"
-        PR_PARENT_SHA="${{{{ github.event.pull_request.head.sha }}}}"
 
-        if [[ -n "$PR_PARENT_SHA" ]]; then
-            git checkout "$PR_PARENT_SHA"
+        if [[ -n "$PR_PARENT_REF" ]]; then
+            git checkout "$PR_PARENT_REF"
         elif BRANCH_PARENT_SHA="$(git merge-base origin/main origin/zed-zippy-autobump)"; then
             git checkout "$BRANCH_PARENT_SHA"
         else
@@ -168,6 +167,7 @@ pub(crate) fn compare_versions() -> (Step<Run>, StepOutput, StepOutput) {
         echo "current_version=${{CURRENT_VERSION}}" >> "$GITHUB_OUTPUT"
         "#
     })
+    .add_env(("PR_PARENT_REF", Context::github().head_ref()))
     .id("compare-versions-check");
 
     let version_changed = StepOutput::new(&check_needs_bump, "version_changed");