From 69a5083fae140b72fd5aadb8e0a08122424f3c24 Mon Sep 17 00:00:00 2001
From: Patrick Weyck
Date: Wed, 10 Sep 2025 16:45:34 +0200
Subject: [PATCH 01/17] feat: use better matching algo
---
shopware-version/shopware-version.bash | 82 ++++++++++++++++++++++----
1 file changed, 70 insertions(+), 12 deletions(-)
diff --git a/shopware-version/shopware-version.bash b/shopware-version/shopware-version.bash
index 978bd04..9e9ec25 100755
--- a/shopware-version/shopware-version.bash
+++ b/shopware-version/shopware-version.bash
@@ -1,47 +1,105 @@
#!/usr/bin/bash
+# Global environment variables required:
+# REF - The current git reference (e.g., refs/heads/6.4.1.0)
+# BASE_REF - The base reference for pull requests (e.g., 6.4.1.0)
+# HEAD_REF - The head reference for pull requests (optional)
+# REPO - The target repository to search for matching branches (e.g., shopware/shopware or https://github.com/shopware/shopware)
+# CURRENT_REPO - The current repository (e.g., shopware/platform)
+# FALLBACK - The fallback branch to use if no matching branch is found (default: trunk)
+
set -e
set pipefail
get_ref() {
local ref
+ PR_NR=$(echo "${REF}" | sed -E -n "s|^refs/heads/gh-readonly-queue/[^/]+/pr-([0-9]+)-.*$|\1|p")
+ if [[ -n "${PR_NR}" ]]; then
+ echo "refs/heads/$(gh pr view --repo "${CURRENT_REPO}" "${PR_NR}" --jq '.headRefName' --json headRefName)"
+ fi
+
if [[ -n "${HEAD_REF}" ]]; then
echo "refs/heads/${HEAD_REF}"
else
echo "${REF}"
fi
-
}
-ref="$(get_ref)"
-echo "Local ref: ${ref}"
+get_base_ref() {
+ PR_NR=$(echo "${1}" | sed -E -n "s|^refs/heads/gh-readonly-queue/[^/]+/pr-([0-9]+)-.*$|\1|p")
+ if [[ -n "${PR_NR}" ]]; then
+ echo "$(gh pr view --repo "${CURRENT_REPO}" "${PR_NR}" --jq '.baseRefName' --json baseRefName)"
+ fi
-PR_NR=$(echo "${ref}" | sed -E -n "s|^refs/heads/gh-readonly-queue/[^/]+/pr-([0-9]+)-.*$|\1|p")
-if [[ -n "${PR_NR}" ]]; then
- echo "Found merge queue ref with PR Nr. ${PR_NR}" 2>&1
+ if [[ -n "${BASE_REF}" ]]; then
+ echo "${BASE_REF}"
+ fi
+}
- ref="refs/heads/$(gh pr view --repo "${CURRENT_REPO}" "${PR_NR}" --jq '.headRefName' --json headRefName)"
- BASE_REF="$(gh pr view --repo "${CURRENT_REPO}" "${PR_NR}" --jq '.baseRefName' --json baseRefName)"
-fi
+REF="$(get_ref)"
+echo "ref: ${REF}"
+BASE_REF="$(get_base_ref "${REF}")"
+echo "base ref: ${BASE_REF}"
# if REPO does not start with https add https://github.com/
if [[ "${REPO}" != https://* ]]; then
REPO="https://github.com/${REPO}"
fi
-remote_ref=$(git ls-remote --heads "${REPO}" "${ref}" | cut -f 2)
+# Algo for finding the matching branch in another repo
+# 1. if REF exists in target repo, use it
+# 2. if BASE_REF exists in target repo, use it
+# 3. if the next minor branch of BASE_REF exists in target repo, use it
+# 4. if the next major branch of BASE_REF exists in target repo, use it
+# 5. use fallback
+
+# to get the next minor from a patch branch replace last part with x
+# to get the next major from a patch branch replace last two parts with x
+
+
+echo "Step 1: Checking if REF '${REF}' exists in target repo '${REPO}'"
+remote_ref=$(git ls-remote --heads "${REPO}" "${REF}" | cut -f 2)
if [[ -n "${remote_ref}" ]]; then
version="${remote_ref#"refs/heads/"}"
+ echo "✓ Found matching REF: ${version}"
else
- remote_ref=$(git ls-remote --heads "${REPO}" "refs/heads/${BASE_REF}" | cut -f 2)
+ echo "✗ REF not found, checking BASE_REF '${BASE_REF}'"
+ # Check if BASE_REF exists in target repo
+ remote_ref=$(git ls-remote --heads "${REPO}" "${BASE_REF}" | cut -f 2)
if [[ -n "${remote_ref}" ]]; then
version="${remote_ref#"refs/heads/"}"
+ echo "✓ Found matching BASE_REF: ${version}"
+ else
+ echo "✗ BASE_REF not found, checking next minor branch"
+ # Check next minor branch (replace last digit with x)
+ next_minor=$(echo "${BASE_REF}" | sed -E 's/[0-9]+$/x/')
+ echo " Checking next minor: ${next_minor}"
+ remote_ref=$(git ls-remote --heads "${REPO}" "${next_minor}" | cut -f 2)
+ if [[ -n "${remote_ref}" ]]; then
+ version="${remote_ref#"refs/heads/"}"
+ echo "✓ Found matching next minor: ${version}"
+ else
+ echo "✗ Next minor not found, checking next major branch"
+ # Check next major branch (replace last two digits with x)
+ next_major=$(echo "${BASE_REF}" | sed -E 's/[0-9]+\.[0-9]+$/x/')
+ echo " Checking next major: ${next_major}"
+ remote_ref=$(git ls-remote --heads "${REPO}" "${next_major}" | cut -f 2)
+
+ if [[ -n "${remote_ref}" ]]; then
+ version="${remote_ref#"refs/heads/"}"
+ echo "✓ Found matching next major: ${version}"
+ else
+ echo "✗ No matching branch found, using fallback: ${FALLBACK}"
+ # Use fallback
+ version="${FALLBACK}"
+ fi
+ fi
fi
fi
if [[ -z "$version" ]]; then
- echo "$ref not found in ${REPO}, using fallback "
+ echo "$REF not found in ${REPO}, using fallback "
version="${FALLBACK}"
fi
From f5ba0ad8741d84eb61a20234e8537fb445a956e6 Mon Sep 17 00:00:00 2001
From: Patrick Weyck
Date: Wed, 10 Sep 2025 16:48:41 +0200
Subject: [PATCH 02/17] tmp: test
---
.github/workflows/test.yml | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 0bbdc16..512c415 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -3,7 +3,7 @@ on:
pull_request:
jobs:
- shopware-version:
+ shopware-version-fallback:
runs-on: ubuntu-latest
steps:
- name: Checkout code
@@ -20,7 +20,20 @@ jobs:
echo 'shopware-version should not be empty'
exit 1
fi
-
-
+ shopware-version:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+ - name: Test shopware-version
+ env:
+ REF: "${{ github.ref }}"
+ BASE_REF: "${{ github.base_ref }}"
+ HEAD_REF: "${{ github.head_ref }}"
+ REPO: "${{ inputs.repo || 'shopware/shopware' }}"
+ CURRENT_REPO: "${{ github.repository }}"
+ FALLBACK: "${{ inputs.fallback || 'trunk' }}"
+ run: |
+ env
From 3d82f985a4899bad53874ff0e7fa35aef4bed6c6 Mon Sep 17 00:00:00 2001
From: Patrick Weyck
Date: Wed, 10 Sep 2025 16:51:32 +0200
Subject: [PATCH 03/17] fix: normalize ref and base ref
---
shopware-version/shopware-version.bash | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/shopware-version/shopware-version.bash b/shopware-version/shopware-version.bash
index 9e9ec25..8b94b89 100755
--- a/shopware-version/shopware-version.bash
+++ b/shopware-version/shopware-version.bash
@@ -22,7 +22,7 @@ get_ref() {
if [[ -n "${HEAD_REF}" ]]; then
echo "refs/heads/${HEAD_REF}"
else
- echo "${REF}"
+ echo "refs/heads/${REF#"refs/heads/"}"
fi
}
@@ -33,7 +33,7 @@ get_base_ref() {
fi
if [[ -n "${BASE_REF}" ]]; then
- echo "${BASE_REF}"
+ echo "refs/heads/${BASE_REF#"refs/heads/"}"
fi
}
From 82684d7ef8ed48744dd4870cc8f0689342849867 Mon Sep 17 00:00:00 2001
From: Patrick Weyck
Date: Wed, 10 Sep 2025 16:58:20 +0200
Subject: [PATCH 04/17] test: add test cases for shopware-version
---
.github/workflows/test.yml | 34 ++++++++++++++++++++++++----------
shopware-version/action.yml | 18 +++++++++++++++---
2 files changed, 39 insertions(+), 13 deletions(-)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 512c415..559f547 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -22,18 +22,32 @@ jobs:
fi
shopware-version:
runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ test-case:
+ - base-ref: "6.7.3.99"
+ expected-version: "6.7.3.x"
+ - base-ref: "6.6.99.99"
+ expected-version: "6.6.x"
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Test shopware-version
- env:
- REF: "${{ github.ref }}"
- BASE_REF: "${{ github.base_ref }}"
- HEAD_REF: "${{ github.head_ref }}"
- REPO: "${{ inputs.repo || 'shopware/shopware' }}"
- CURRENT_REPO: "${{ github.repository }}"
- FALLBACK: "${{ inputs.fallback || 'trunk' }}"
+ id: version
+ uses: ./shopware-version
+ with:
+ ref: test-branch
+ base-ref: ${{ matrix.test-case.base-ref }}
+ head-ref: test-branch
+ repo: shopware/shopware
+ fallback: 'not-found'
+ - name: Check shopware-version matches expected version
run: |
- env
-
-
+ SHOPWARE_VERSION="${{ steps.version.outputs.shopware-version }}"
+ EXPECTED_VERSION="${{ matrix.test-case.expected-version }}"
+ echo "shopware-version: '${SHOPWARE_VERSION}'"
+ echo "expected-version: '${EXPECTED_VERSION}'"
+ if [[ "${SHOPWARE_VERSION}" != "${EXPECTED_VERSION}" ]]; then
+ echo "shopware-version should be '${EXPECTED_VERSION}' but got '${SHOPWARE_VERSION}'"
+ exit 1
+ fi
\ No newline at end of file
diff --git a/shopware-version/action.yml b/shopware-version/action.yml
index 01d0d4b..03943d0 100644
--- a/shopware-version/action.yml
+++ b/shopware-version/action.yml
@@ -14,6 +14,18 @@ inputs:
description: The repo where to look for matching refs
default: shopware/shopware
required: false
+ ref:
+ description: The git reference to match (defaults to github.ref)
+ required: false
+ default: ""
+ base-ref:
+ description: The base reference for pull requests (defaults to github.base_ref)
+ required: false
+ default: ""
+ head-ref:
+ description: The head reference for pull requests (defaults to github.head_ref)
+ required: false
+ default: ""
shopware-github-token:
description: Token used for checking out the shopware repository
required: false
@@ -36,9 +48,9 @@ runs:
id: get-version
shell: bash
env:
- REF: "${{ github.ref }}"
- BASE_REF: "${{ github.base_ref }}"
- HEAD_REF: "${{ github.head_ref }}"
+ REF: "${{ inputs.ref || github.ref }}"
+ BASE_REF: "${{ inputs.base-ref || github.base_ref }}"
+ HEAD_REF: "${{ inputs.head-ref || github.head_ref }}"
REPO: "${{ inputs.repo || 'shopware/shopware' }}"
CURRENT_REPO: "${{ github.repository }}"
FALLBACK: "${{ inputs.fallback || 'trunk' }}"
From e3e1b1632d7a84428bf266fa5d90d4d8fa2e0f88 Mon Sep 17 00:00:00 2001
From: Patrick Weyck
Date: Wed, 10 Sep 2025 17:03:12 +0200
Subject: [PATCH 05/17] test: add more test cases
---
.github/workflows/test.yml | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 559f547..f81a560 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -25,10 +25,25 @@ jobs:
strategy:
matrix:
test-case:
- - base-ref: "6.7.3.99"
+ - ref: this-branch-does-not-exist
+ base-ref: "6.7.3.99"
expected-version: "6.7.3.x"
- - base-ref: "6.6.99.99"
+ - ref: this-branch-does-not-exist
+ base-ref: "6.6.99.99"
expected-version: "6.6.x"
+ - ref: trunk
+ base-ref: "6.7.3.99"
+ expected-version: "trunk"
+ # refs/heads form
+ - ref: refs/heads/this-branch-does-not-exist
+ base-ref: "refs/heads/6.7.3.99"
+ expected-version: "6.7.3.x"
+ - ref: refs/heads/this-branch-does-not-exist
+ base-ref: "refs/heads/6.6.99.99"
+ expected-version: "6.6.x"
+ - ref: refs/heads/trunk
+ base-ref: "refs/heads/6.7.3.99"
+ expected-version: "trunk"
steps:
- name: Checkout code
uses: actions/checkout@v4
@@ -36,7 +51,7 @@ jobs:
id: version
uses: ./shopware-version
with:
- ref: test-branch
+ ref: ${{ matrix.test-case.ref }}
base-ref: ${{ matrix.test-case.base-ref }}
head-ref: test-branch
repo: shopware/shopware
From 01dde99bec34411c71c70d3dce8ef1900d4b5853 Mon Sep 17 00:00:00 2001
From: Patrick Weyck
Date: Wed, 10 Sep 2025 17:13:03 +0200
Subject: [PATCH 06/17] fix test case
---
.github/workflows/test.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index f81a560..27c54e6 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -32,7 +32,7 @@ jobs:
base-ref: "6.6.99.99"
expected-version: "6.6.x"
- ref: trunk
- base-ref: "6.7.3.99"
+ base-ref: "6.7.99.99"
expected-version: "trunk"
# refs/heads form
- ref: refs/heads/this-branch-does-not-exist
@@ -42,7 +42,7 @@ jobs:
base-ref: "refs/heads/6.6.99.99"
expected-version: "6.6.x"
- ref: refs/heads/trunk
- base-ref: "refs/heads/6.7.3.99"
+ base-ref: "refs/heads/6.7.99.99"
expected-version: "trunk"
steps:
- name: Checkout code
From bbc1cd447e0319f712c8e2881780a06a5c51ed35 Mon Sep 17 00:00:00 2001
From: Patrick Weyck
Date: Thu, 11 Sep 2025 14:29:49 +0200
Subject: [PATCH 07/17] test: simplify
---
.github/workflows/test.yml | 31 ++++++++++++++++++++-----------
1 file changed, 20 insertions(+), 11 deletions(-)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 27c54e6..f85e6b1 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -34,16 +34,6 @@ jobs:
- ref: trunk
base-ref: "6.7.99.99"
expected-version: "trunk"
- # refs/heads form
- - ref: refs/heads/this-branch-does-not-exist
- base-ref: "refs/heads/6.7.3.99"
- expected-version: "6.7.3.x"
- - ref: refs/heads/this-branch-does-not-exist
- base-ref: "refs/heads/6.6.99.99"
- expected-version: "6.6.x"
- - ref: refs/heads/trunk
- base-ref: "refs/heads/6.7.99.99"
- expected-version: "trunk"
steps:
- name: Checkout code
uses: actions/checkout@v4
@@ -53,7 +43,7 @@ jobs:
with:
ref: ${{ matrix.test-case.ref }}
base-ref: ${{ matrix.test-case.base-ref }}
- head-ref: test-branch
+ head-ref: ${{ matrix.test-case.ref }}
repo: shopware/shopware
fallback: 'not-found'
- name: Check shopware-version matches expected version
@@ -62,6 +52,25 @@ jobs:
EXPECTED_VERSION="${{ matrix.test-case.expected-version }}"
echo "shopware-version: '${SHOPWARE_VERSION}'"
echo "expected-version: '${EXPECTED_VERSION}'"
+ if [[ "${SHOPWARE_VERSION}" != "${EXPECTED_VERSION}" ]]; then
+ echo "shopware-version should be '${EXPECTED_VERSION}' but got '${SHOPWARE_VERSION}'"
+ exit 1
+ fi
+ - name: Test shopware-version with refs/heads/
+ id: version-heads
+ uses: ./shopware-version
+ with:
+ ref: refs/heads/${{ matrix.test-case.ref }}
+ base-ref: refs/heads/${{ matrix.test-case.base-ref }}
+ head-ref: refs/heads/${{ matrix.test-case.ref }}
+ repo: shopware/shopware
+ fallback: 'not-found'
+ - name: Check shopware-version matches expected version
+ run: |
+ SHOPWARE_VERSION="${{ steps.version-heads.outputs.shopware-version }}"
+ EXPECTED_VERSION="${{ matrix.test-case.expected-version }}"
+ echo "shopware-version: '${SHOPWARE_VERSION}'"
+ echo "expected-version: '${EXPECTED_VERSION}'"
if [[ "${SHOPWARE_VERSION}" != "${EXPECTED_VERSION}" ]]; then
echo "shopware-version should be '${EXPECTED_VERSION}' but got '${SHOPWARE_VERSION}'"
exit 1
From f9e3fda2a19042308f08a60f5482d47bde77d777 Mon Sep 17 00:00:00 2001
From: Patrick Weyck
Date: Thu, 11 Sep 2025 14:32:40 +0200
Subject: [PATCH 08/17] fix tests
---
.github/workflows/test.yml | 6 +++++-
shopware-version/shopware-version.bash | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index f85e6b1..188ec9c 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -34,6 +34,10 @@ jobs:
- ref: trunk
base-ref: "6.7.99.99"
expected-version: "trunk"
+ - ref: does-not-exist
+ head-ref: trunk
+ base-ref: "6.7.99.99"
+ expected-version: "trunk"
steps:
- name: Checkout code
uses: actions/checkout@v4
@@ -43,7 +47,7 @@ jobs:
with:
ref: ${{ matrix.test-case.ref }}
base-ref: ${{ matrix.test-case.base-ref }}
- head-ref: ${{ matrix.test-case.ref }}
+ head-ref: ${{ matrix.test-case.haad-ref || '' }}
repo: shopware/shopware
fallback: 'not-found'
- name: Check shopware-version matches expected version
diff --git a/shopware-version/shopware-version.bash b/shopware-version/shopware-version.bash
index 8b94b89..a1ea4be 100755
--- a/shopware-version/shopware-version.bash
+++ b/shopware-version/shopware-version.bash
@@ -20,7 +20,7 @@ get_ref() {
fi
if [[ -n "${HEAD_REF}" ]]; then
- echo "refs/heads/${HEAD_REF}"
+ echo "refs/heads/${HEAD_REF#"refs/heads/"}"
else
echo "refs/heads/${REF#"refs/heads/"}"
fi
From ffeddb5c965a3121aa04a4bd4831236a19ee3b77 Mon Sep 17 00:00:00 2001
From: Patrick Weyck
Date: Thu, 11 Sep 2025 14:34:54 +0200
Subject: [PATCH 09/17] fix tests second try
---
.github/workflows/test.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 188ec9c..8fdf75f 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -47,7 +47,7 @@ jobs:
with:
ref: ${{ matrix.test-case.ref }}
base-ref: ${{ matrix.test-case.base-ref }}
- head-ref: ${{ matrix.test-case.haad-ref || '' }}
+ head-ref: ${{ matrix.test-case.head-ref || matrix.test-case.ref }}
repo: shopware/shopware
fallback: 'not-found'
- name: Check shopware-version matches expected version
From 5bbc9274e899d7b77e54c9d4582d5ded44f59433 Mon Sep 17 00:00:00 2001
From: Patrick Weyck
Date: Thu, 11 Sep 2025 15:05:41 +0200
Subject: [PATCH 10/17] test
---
.github/workflows/test.yml | 38 ++++++++++++++++++-------------------
shopware-version/action.yml | 2 +-
2 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 8fdf75f..36e63ec 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -60,22 +60,22 @@ jobs:
echo "shopware-version should be '${EXPECTED_VERSION}' but got '${SHOPWARE_VERSION}'"
exit 1
fi
- - name: Test shopware-version with refs/heads/
- id: version-heads
- uses: ./shopware-version
- with:
- ref: refs/heads/${{ matrix.test-case.ref }}
- base-ref: refs/heads/${{ matrix.test-case.base-ref }}
- head-ref: refs/heads/${{ matrix.test-case.ref }}
- repo: shopware/shopware
- fallback: 'not-found'
- - name: Check shopware-version matches expected version
- run: |
- SHOPWARE_VERSION="${{ steps.version-heads.outputs.shopware-version }}"
- EXPECTED_VERSION="${{ matrix.test-case.expected-version }}"
- echo "shopware-version: '${SHOPWARE_VERSION}'"
- echo "expected-version: '${EXPECTED_VERSION}'"
- if [[ "${SHOPWARE_VERSION}" != "${EXPECTED_VERSION}" ]]; then
- echo "shopware-version should be '${EXPECTED_VERSION}' but got '${SHOPWARE_VERSION}'"
- exit 1
- fi
\ No newline at end of file
+ # - name: Test shopware-version with refs/heads/
+ # id: version-heads
+ # uses: ./shopware-version
+ # with:
+ # ref: refs/heads/${{ matrix.test-case.ref }}
+ # base-ref: refs/heads/${{ matrix.test-case.base-ref }}
+ # head-ref: refs/heads/${{ matrix.test-case.ref }}
+ # repo: shopware/shopware
+ # fallback: 'not-found'
+ # - name: Check shopware-version matches expected version
+ # run: |
+ # SHOPWARE_VERSION="${{ steps.version-heads.outputs.shopware-version }}"
+ # EXPECTED_VERSION="${{ matrix.test-case.expected-version }}"
+ # echo "shopware-version: '${SHOPWARE_VERSION}'"
+ # echo "expected-version: '${EXPECTED_VERSION}'"
+ # if [[ "${SHOPWARE_VERSION}" != "${EXPECTED_VERSION}" ]]; then
+ # echo "shopware-version should be '${EXPECTED_VERSION}' but got '${SHOPWARE_VERSION}'"
+ # exit 1
+ # fi
\ No newline at end of file
diff --git a/shopware-version/action.yml b/shopware-version/action.yml
index 03943d0..9c59db1 100644
--- a/shopware-version/action.yml
+++ b/shopware-version/action.yml
@@ -49,8 +49,8 @@ runs:
shell: bash
env:
REF: "${{ inputs.ref || github.ref }}"
- BASE_REF: "${{ inputs.base-ref || github.base_ref }}"
HEAD_REF: "${{ inputs.head-ref || github.head_ref }}"
+ BASE_REF: "${{ inputs.base-ref || github.base_ref }}"
REPO: "${{ inputs.repo || 'shopware/shopware' }}"
CURRENT_REPO: "${{ github.repository }}"
FALLBACK: "${{ inputs.fallback || 'trunk' }}"
From d0b650cb054a2d419d93476a687a3edf1e029983 Mon Sep 17 00:00:00 2001
From: Patrick Weyck
Date: Thu, 11 Sep 2025 15:08:37 +0200
Subject: [PATCH 11/17] fix refs/heads/ cases
---
.github/workflows/test.yml | 38 +++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 36e63ec..f1f63c9 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -60,22 +60,22 @@ jobs:
echo "shopware-version should be '${EXPECTED_VERSION}' but got '${SHOPWARE_VERSION}'"
exit 1
fi
- # - name: Test shopware-version with refs/heads/
- # id: version-heads
- # uses: ./shopware-version
- # with:
- # ref: refs/heads/${{ matrix.test-case.ref }}
- # base-ref: refs/heads/${{ matrix.test-case.base-ref }}
- # head-ref: refs/heads/${{ matrix.test-case.ref }}
- # repo: shopware/shopware
- # fallback: 'not-found'
- # - name: Check shopware-version matches expected version
- # run: |
- # SHOPWARE_VERSION="${{ steps.version-heads.outputs.shopware-version }}"
- # EXPECTED_VERSION="${{ matrix.test-case.expected-version }}"
- # echo "shopware-version: '${SHOPWARE_VERSION}'"
- # echo "expected-version: '${EXPECTED_VERSION}'"
- # if [[ "${SHOPWARE_VERSION}" != "${EXPECTED_VERSION}" ]]; then
- # echo "shopware-version should be '${EXPECTED_VERSION}' but got '${SHOPWARE_VERSION}'"
- # exit 1
- # fi
\ No newline at end of file
+ - name: Test shopware-version with refs/heads/
+ id: version-heads
+ uses: ./shopware-version
+ with:
+ ref: refs/heads/${{ matrix.test-case.ref }}
+ base-ref: refs/heads/${{ matrix.test-case.base-ref }}
+ head-ref: refs/heads/${{ matrix.test-case.head-ref || matrix.test-case.ref }}
+ repo: shopware/shopware
+ fallback: 'not-found'
+ - name: Check shopware-version matches expected version
+ run: |
+ SHOPWARE_VERSION="${{ steps.version-heads.outputs.shopware-version }}"
+ EXPECTED_VERSION="${{ matrix.test-case.expected-version }}"
+ echo "shopware-version: '${SHOPWARE_VERSION}'"
+ echo "expected-version: '${EXPECTED_VERSION}'"
+ if [[ "${SHOPWARE_VERSION}" != "${EXPECTED_VERSION}" ]]; then
+ echo "shopware-version should be '${EXPECTED_VERSION}' but got '${SHOPWARE_VERSION}'"
+ exit 1
+ fi
\ No newline at end of file
From 307e7347ec0223912d86c788d28302aceff92508 Mon Sep 17 00:00:00 2001
From: Patrick Weyck
Date: Thu, 11 Sep 2025 15:21:00 +0200
Subject: [PATCH 12/17] tmp: test
---
downstream/action.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/downstream/action.yml b/downstream/action.yml
index ee5eb1d..afe7f19 100644
--- a/downstream/action.yml
+++ b/downstream/action.yml
@@ -74,7 +74,7 @@ runs:
run: |
git config "http.https://github.com/".extraheader "AUTHORIZATION: basic $(echo -n "x-access-token:${{ inputs.token || steps.sts.outputs.token }}" | base64 -w0)"
- - uses: shopware/github-actions/shopware-version@main
+ - uses: shopware/github-actions/shopware-version@feat-use-better-matching-algo
env:
GH_TOKEN: ${{ inputs.token || steps.sts.outputs.token }}
with:
From d36bcbf58cee694f4b4e23eab24cc17e9410e637 Mon Sep 17 00:00:00 2001
From: Patrick Weyck
Date: Thu, 11 Sep 2025 15:51:58 +0200
Subject: [PATCH 13/17] if BASE_REF is not set use REF for minor and major
branch matching
---
shopware-version/shopware-version.bash | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/shopware-version/shopware-version.bash b/shopware-version/shopware-version.bash
index a1ea4be..f933035 100755
--- a/shopware-version/shopware-version.bash
+++ b/shopware-version/shopware-version.bash
@@ -19,9 +19,13 @@ get_ref() {
echo "refs/heads/$(gh pr view --repo "${CURRENT_REPO}" "${PR_NR}" --jq '.headRefName' --json headRefName)"
fi
+ #remove whitespace from HEAD_REF with bash substitution
+ HEAD_REF=${HEAD_REF// /}
if [[ -n "${HEAD_REF}" ]]; then
echo "refs/heads/${HEAD_REF#"refs/heads/"}"
else
+ #remove whitespace from REF with bash substitution
+ REF=${REF// /}
echo "refs/heads/${REF#"refs/heads/"}"
fi
}
@@ -32,6 +36,8 @@ get_base_ref() {
echo "$(gh pr view --repo "${CURRENT_REPO}" "${PR_NR}" --jq '.baseRefName' --json baseRefName)"
fi
+ #remove whitespace from BASE_REF with bash substitution
+ BASE_REF=${BASE_REF// /}
if [[ -n "${BASE_REF}" ]]; then
echo "refs/heads/${BASE_REF#"refs/heads/"}"
fi
@@ -64,6 +70,12 @@ if [[ -n "${remote_ref}" ]]; then
version="${remote_ref#"refs/heads/"}"
echo "✓ Found matching REF: ${version}"
else
+ BASE_REF=${BASE_REF// /}
+ if [[ -z "${BASE_REF}" ]]; then
+ echo "✗ BASE_REF not set, using REF '${REF}'"
+ BASE_REF="${REF}"
+ fi
+
echo "✗ REF not found, checking BASE_REF '${BASE_REF}'"
# Check if BASE_REF exists in target repo
remote_ref=$(git ls-remote --heads "${REPO}" "${BASE_REF}" | cut -f 2)
From 4908251e9f42c25cca24c36cea5c98f9d0dadd77 Mon Sep 17 00:00:00 2001
From: Patrick Weyck
Date: Thu, 11 Sep 2025 16:06:30 +0200
Subject: [PATCH 14/17] add new test case
---
.github/workflows/test.yml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index f1f63c9..548dfa1 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -38,6 +38,10 @@ jobs:
head-ref: trunk
base-ref: "6.7.99.99"
expected-version: "trunk"
+ # for non pr events, base-ref can be empty
+ - ref: 6.7.2.99
+ base-ref: " "
+ expected-version: "6.7.2.x"
steps:
- name: Checkout code
uses: actions/checkout@v4
From abed42849130e4278cf056dee6e52c9e0987e8bf Mon Sep 17 00:00:00 2001
From: Patrick Weyck
Date: Thu, 11 Sep 2025 16:12:37 +0200
Subject: [PATCH 15/17] fix refs/heads case
---
.github/workflows/test.yml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 548dfa1..3772e16 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -67,6 +67,7 @@ jobs:
- name: Test shopware-version with refs/heads/
id: version-heads
uses: ./shopware-version
+ if: ${{ matrix.test-case.base-ref != ' ' }}
with:
ref: refs/heads/${{ matrix.test-case.ref }}
base-ref: refs/heads/${{ matrix.test-case.base-ref }}
@@ -74,6 +75,7 @@ jobs:
repo: shopware/shopware
fallback: 'not-found'
- name: Check shopware-version matches expected version
+ if: ${{ matrix.test-case.base-ref != ' ' }}
run: |
SHOPWARE_VERSION="${{ steps.version-heads.outputs.shopware-version }}"
EXPECTED_VERSION="${{ matrix.test-case.expected-version }}"
From 4ab172f462b5d6e248255db69df0a6655fedf90f Mon Sep 17 00:00:00 2001
From: Patrick Weyck
Date: Thu, 11 Sep 2025 17:21:47 +0200
Subject: [PATCH 16/17] test setup-extension
---
setup-extension/action.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/setup-extension/action.yml b/setup-extension/action.yml
index fb63e6b..c31e865 100644
--- a/setup-extension/action.yml
+++ b/setup-extension/action.yml
@@ -105,7 +105,7 @@ inputs:
runs:
using: "composite"
steps:
- - uses: shopware/github-actions/shopware-version@main
+ - uses: shopware/github-actions/shopware-version@feat-use-better-matching-algo
with:
fallback: ${{ inputs.shopwareVersionFallback }}
repo: ${{ inputs.shopware-repository }}
@@ -190,7 +190,7 @@ runs:
if: inputs.dependencies
env:
DEPS: ${{ inputs.dependencies }}
- REF: ${{ inputs.shopwareVersion}}
+ REF: ${{ inputs.shopwareVersion }}
FALLBACK: ${{ inputs.shopwareVersionFallback }}
run: |
for dep in $(echo "$DEPS" | envsubst | jq -c '.[]'); do
From 1fb9830bc82c4e182619d29bb3f17424f099a15f Mon Sep 17 00:00:00 2001
From: Patrick Weyck
Date: Fri, 12 Sep 2025 11:36:28 +0200
Subject: [PATCH 17/17] remove testing code
---
downstream/action.yml | 2 +-
setup-extension/action.yml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/downstream/action.yml b/downstream/action.yml
index afe7f19..ee5eb1d 100644
--- a/downstream/action.yml
+++ b/downstream/action.yml
@@ -74,7 +74,7 @@ runs:
run: |
git config "http.https://github.com/".extraheader "AUTHORIZATION: basic $(echo -n "x-access-token:${{ inputs.token || steps.sts.outputs.token }}" | base64 -w0)"
- - uses: shopware/github-actions/shopware-version@feat-use-better-matching-algo
+ - uses: shopware/github-actions/shopware-version@main
env:
GH_TOKEN: ${{ inputs.token || steps.sts.outputs.token }}
with:
diff --git a/setup-extension/action.yml b/setup-extension/action.yml
index c31e865..713ca47 100644
--- a/setup-extension/action.yml
+++ b/setup-extension/action.yml
@@ -105,7 +105,7 @@ inputs:
runs:
using: "composite"
steps:
- - uses: shopware/github-actions/shopware-version@feat-use-better-matching-algo
+ - uses: shopware/github-actions/shopware-version@main
with:
fallback: ${{ inputs.shopwareVersionFallback }}
repo: ${{ inputs.shopware-repository }}