@@ -241,18 +241,14 @@ if [ -n "${GITHUB_TOKEN:-}" ]; then
241241fi
242242git push -u origin " ${BRANCH_NAME} " || git push origin " ${BRANCH_NAME} "
243243
244- # Create pull request
244+ # Create pull request using GitHub REST API (works without gh CLI)
245245if [ " ${SKIP_PR} " != true ]; then
246246 echo " Creating pull request..."
247- # Authenticate gh CLI if GITHUB_TOKEN is available (for CI)
248- if [ -n " ${GITHUB_TOKEN:- } " ]; then
249- echo " ${GITHUB_TOKEN} " | gh auth login --with-token 2> /dev/null || true
250- fi
251247
252- PR_URL= $( gh pr create \
253- --repo " ${CONAN_INDEX_UPSTREAM} " \
254- --title " Add influxdb-cpp-rest/ ${VERSION} " \
255- --body " This PR adds the influxdb-cpp-rest package version ${VERSION} to Conan Center.
248+ if [ -n " ${GITHUB_TOKEN :- } " ] ; then
249+ # Use GitHub REST API to create PR
250+ PR_BODY= $( cat << EOF
251+ This PR adds the influxdb-cpp-rest package version ${VERSION} to Conan Center.
256252
257253## Package Details
258254- **Name**: influxdb-cpp-rest
@@ -277,22 +273,54 @@ if [ "${SKIP_PR}" != true ]; then
277273- C++20 or later
278274- GCC 11+, Clang 14+, MSVC 2019+
279275
280- Automatically created by GitHub Actions workflow on tag push." \
281- 2>&1 ) || {
282- echo " Warning: Failed to create PR. You may need to create it manually."
283- echo " Branch pushed to: ${CONAN_INDEX_FORK} :${BRANCH_NAME} "
284- exit 1
285- }
286-
287- echo " "
288- echo " ✅ Pull request created: ${PR_URL} "
289- echo " "
290- echo " Next steps:"
291- echo " 1. Monitor the PR for CI results"
292- echo " 2. Address any review comments or CI failures"
293- echo " 3. Once merged, the package will be available on Conan Center"
276+ Automatically created by GitHub Actions workflow on tag push.
277+ EOF
278+ )
279+
280+ # Extract owner and repo from CONAN_INDEX_UPSTREAM (format: owner/repo)
281+ # Format PR body as JSON (escape newlines and quotes)
282+ ESCAPED_BODY=$( echo " ${PR_BODY} " | sed ' :a;N;$!ba;s/\n/\\n/g' | sed ' s/"/\\"/g' )
283+
284+ # Extract fork owner from CONAN_INDEX_FORK (format: owner/repo)
285+ FORK_OWNER=" ${CONAN_INDEX_FORK%%/* } "
286+
287+ PR_RESPONSE=$( curl -s -w " \n%{http_code}" \
288+ -X POST \
289+ -H " Accept: application/vnd.github.v3+json" \
290+ -H " Authorization: token ${GITHUB_TOKEN} " \
291+ " https://api.github.com/repos/${CONAN_INDEX_UPSTREAM} /pulls" \
292+ -d " {
293+ \" title\" : \" Add influxdb-cpp-rest/${VERSION} \" ,
294+ \" body\" : \" ${ESCAPED_BODY} \" ,
295+ \" head\" : \" ${FORK_OWNER} :${BRANCH_NAME} \" ,
296+ \" base\" : \" master\"
297+ }" )
298+
299+ HTTP_CODE=$( echo " ${PR_RESPONSE} " | tail -1)
300+ PR_JSON=$( echo " ${PR_RESPONSE} " | head -n -1)
301+
302+ if [ " ${HTTP_CODE} " = " 201" ] || [ " ${HTTP_CODE} " = " 200" ]; then
303+ PR_URL=$( echo " ${PR_JSON} " | grep -o ' "html_url":[^,]*' | cut -d' "' -f4 || echo " " )
304+ echo " "
305+ echo " ✅ Pull request created: ${PR_URL} "
306+ echo " "
307+ echo " Next steps:"
308+ echo " 1. Monitor the PR for CI results"
309+ echo " 2. Address any review comments or CI failures"
310+ echo " 3. Once merged, the package will be available on Conan Center"
311+ else
312+ echo " Warning: Failed to create PR (HTTP ${HTTP_CODE} )"
313+ echo " Response: ${PR_JSON} "
314+ echo " Branch pushed to: ${CONAN_INDEX_FORK} :${BRANCH_NAME} "
315+ echo " Create PR manually at: https://github.com/${CONAN_INDEX_UPSTREAM} /compare/master...${CONAN_INDEX_FORK#*/ } :${BRANCH_NAME} "
316+ exit 1
317+ fi
318+ else
319+ echo " ✅ Branch pushed. Create PR manually:"
320+ echo " https://github.com/${CONAN_INDEX_UPSTREAM} /compare/master...${CONAN_INDEX_FORK#*/ } :${BRANCH_NAME} "
321+ fi
294322else
295323 echo " ✅ Branch pushed. Create PR manually:"
296- echo " gh pr create --repo ${CONAN_INDEX_UPSTREAM} --title \" Add influxdb-cpp-rest/ ${VERSION} \" "
324+ echo " https://github.com/ ${CONAN_INDEX_UPSTREAM} /compare/master... ${CONAN_INDEX_FORK #*/ } : ${BRANCH_NAME} "
297325fi
298326
0 commit comments