From 1f507ddce28eb1855ca981cf0e76eadade3fe1b2 Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Thu, 22 Jan 2026 02:33:56 +0000 Subject: [PATCH 1/3] fix(action): Fix detection of existing publish issues The jq filter for matching issue titles was using shell variable interpolation inside the -q flag, which can cause escaping issues with special characters like @ in version strings. Fix by piping to external jq with --arg to safely pass the title variable, avoiding any escaping or interpolation issues. --- action.yml | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/action.yml b/action.yml index 981107f6..17072937 100644 --- a/action.yml +++ b/action.yml @@ -1,5 +1,5 @@ -name: "Craft Prepare Release" -description: "Prepare a new release using Craft" +name: 'Craft Prepare Release' +description: 'Prepare a new release using Craft' inputs: version: @@ -13,11 +13,11 @@ inputs: force: description: Force a release even when there are release-blockers required: false - default: "false" + default: 'false' blocker_label: description: Label that blocks releases required: false - default: "release-blocker" + default: 'release-blocker' publish_repo: description: Repository for publish issues (owner/repo format) required: false @@ -30,17 +30,17 @@ inputs: path: description: The path that Craft will run inside required: false - default: "." + default: '.' craft_config_from_merge_target: description: Use the craft config from the merge target branch required: false - default: "false" + default: 'false' craft_version: description: > Version of Craft to install (tag or "latest"). Defaults to the action ref (e.g., "v2") if not specified. required: false - default: "" + default: '' outputs: version: @@ -63,7 +63,7 @@ outputs: value: ${{ steps.request-publish.outputs.issue_url }} runs: - using: "composite" + using: 'composite' steps: - id: killswitch name: Check release blockers @@ -205,9 +205,10 @@ runs: title="publish: ${GITHUB_REPOSITORY}${SUBDIRECTORY}@${RESOLVED_VERSION}" # Check if issue already exists - # GitHub only allows search with the "in" operator and this issue search can - # return non-exact matches. We extract the titles and check with grep -xF - existing_issue_url=$(gh -R "$PUBLISH_REPO" issue list -S "'$title' in:title" --json title,url -q ".[] | select(.title == \"$title\") | .url") + # GitHub search requires double quotes for exact phrase matching. The search can + # still return non-exact matches, so we filter with jq to match the exact title. + # We use --arg to safely pass the title to jq, avoiding escaping issues with @ and other special chars. + existing_issue_url=$(gh -R "$PUBLISH_REPO" issue list -S "\"$title\" in:title" --json title,url | jq -r --arg t "$title" '.[] | select(.title == $t) | .url') if [[ -n "$existing_issue_url" ]]; then echo "There's already an open publish request, skipped issue creation." echo "::notice::Existing publish request: ${existing_issue_url}" From 1759485734a6229e9edd833edbd106f3180f707d Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Thu, 22 Jan 2026 02:49:59 +0000 Subject: [PATCH 2/3] test: Add workflow to verify issue detection fix --- .github/workflows/test-issue-detection.yml | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/test-issue-detection.yml diff --git a/.github/workflows/test-issue-detection.yml b/.github/workflows/test-issue-detection.yml new file mode 100644 index 00000000..f5893230 --- /dev/null +++ b/.github/workflows/test-issue-detection.yml @@ -0,0 +1,46 @@ +name: Test Issue Detection + +on: + push: + branches: + - fix/existing-publish-issue-detection + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Test issue detection + env: + GH_TOKEN: ${{ github.token }} + run: | + set -x + + test_title="publish: getsentry/craft@0.0.1-test" + PUBLISH_REPO="getsentry/craft" + + echo "=== Raw search results ===" + gh -R "$PUBLISH_REPO" issue list -S "'$test_title' in:title" --json title,url + + echo "" + echo "=== Testing ORIGINAL code (single quotes + -q flag) ===" + original_result=$(gh -R "$PUBLISH_REPO" issue list -S "'$test_title' in:title" --json title,url -q ".[] | select(.title == \"$test_title\") | .url") + echo "Original result: |$original_result|" + + echo "" + echo "=== Testing FIXED code (double quotes + jq --arg) ===" + fixed_result=$(gh -R "$PUBLISH_REPO" issue list -S "\"$test_title\" in:title" --json title,url | jq -r --arg t "$test_title" '.[] | select(.title == $t) | .url') + echo "Fixed result: |$fixed_result|" + + echo "" + echo "=== Summary ===" + if [[ -z "$original_result" ]]; then + echo "❌ ORIGINAL: FAILED to find issue" + else + echo "✅ ORIGINAL: Found issue" + fi + + if [[ -z "$fixed_result" ]]; then + echo "❌ FIXED: FAILED to find issue" + else + echo "✅ FIXED: Found issue" + fi From b7c9f5ad3047f193658ca6f6e5f7776422d02dd4 Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Thu, 22 Jan 2026 02:51:40 +0000 Subject: [PATCH 3/3] fix(action): Fix detection of existing publish issues Replace GitHub search API with listing all open issues and filtering by exact title match using jq. This avoids: - Search indexing delays that could cause duplicate issues - Query syntax edge cases with special characters like @ --- .github/workflows/test-issue-detection.yml | 46 ---------------------- action.yml | 8 ++-- 2 files changed, 3 insertions(+), 51 deletions(-) delete mode 100644 .github/workflows/test-issue-detection.yml diff --git a/.github/workflows/test-issue-detection.yml b/.github/workflows/test-issue-detection.yml deleted file mode 100644 index f5893230..00000000 --- a/.github/workflows/test-issue-detection.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Test Issue Detection - -on: - push: - branches: - - fix/existing-publish-issue-detection - -jobs: - test: - runs-on: ubuntu-latest - steps: - - name: Test issue detection - env: - GH_TOKEN: ${{ github.token }} - run: | - set -x - - test_title="publish: getsentry/craft@0.0.1-test" - PUBLISH_REPO="getsentry/craft" - - echo "=== Raw search results ===" - gh -R "$PUBLISH_REPO" issue list -S "'$test_title' in:title" --json title,url - - echo "" - echo "=== Testing ORIGINAL code (single quotes + -q flag) ===" - original_result=$(gh -R "$PUBLISH_REPO" issue list -S "'$test_title' in:title" --json title,url -q ".[] | select(.title == \"$test_title\") | .url") - echo "Original result: |$original_result|" - - echo "" - echo "=== Testing FIXED code (double quotes + jq --arg) ===" - fixed_result=$(gh -R "$PUBLISH_REPO" issue list -S "\"$test_title\" in:title" --json title,url | jq -r --arg t "$test_title" '.[] | select(.title == $t) | .url') - echo "Fixed result: |$fixed_result|" - - echo "" - echo "=== Summary ===" - if [[ -z "$original_result" ]]; then - echo "❌ ORIGINAL: FAILED to find issue" - else - echo "✅ ORIGINAL: Found issue" - fi - - if [[ -z "$fixed_result" ]]; then - echo "❌ FIXED: FAILED to find issue" - else - echo "✅ FIXED: Found issue" - fi diff --git a/action.yml b/action.yml index 17072937..0fd4d68d 100644 --- a/action.yml +++ b/action.yml @@ -204,11 +204,9 @@ runs: title="publish: ${GITHUB_REPOSITORY}${SUBDIRECTORY}@${RESOLVED_VERSION}" - # Check if issue already exists - # GitHub search requires double quotes for exact phrase matching. The search can - # still return non-exact matches, so we filter with jq to match the exact title. - # We use --arg to safely pass the title to jq, avoiding escaping issues with @ and other special chars. - existing_issue_url=$(gh -R "$PUBLISH_REPO" issue list -S "\"$title\" in:title" --json title,url | jq -r --arg t "$title" '.[] | select(.title == $t) | .url') + # Check if issue already exists by listing all open issues and filtering by exact title match. + # We avoid GitHub search API to bypass indexing delays and query syntax edge cases. + existing_issue_url=$(gh -R "$PUBLISH_REPO" issue list --json title,url | jq -r --arg t "$title" '.[] | select(.title == $t) | .url') if [[ -n "$existing_issue_url" ]]; then echo "There's already an open publish request, skipped issue creation." echo "::notice::Existing publish request: ${existing_issue_url}"