diff --git a/tools/publish-auto-update.pl b/tools/publish-auto-update.pl index 9e6b885be..ed473acb6 100755 --- a/tools/publish-auto-update.pl +++ b/tools/publish-auto-update.pl @@ -69,7 +69,8 @@ () chomp $sha256; # long-form commit hash of HEAD on auto-update branch -my $update_hash = `git rev-parse refs/heads/auto-update-${commit_hash}`; +#my $update_hash = `git rev-parse refs/heads/auto-update-${commit_hash}`; +my $update_hash = `git rev-parse origin/auto-update-${commit_hash}`; die("Can't find commit hash for HEAD on auto-update-${commit_hash} branch\n") if ! defined $update_hash; chomp $update_hash; @@ -132,11 +133,57 @@ () die("Can't sign raw transaction:\n$signed_tx\n") unless $signed_tx =~ m/^\w{390,410}$/; # +90ish longer than $raw_tx printf "\nSigned transaction:\n%s\n", $signed_tx; -# Check we can actually fetch update +# Get the origin URL - So that we will be able to TEST the obtaining of the qortal.update... my $origin = `git remote get-url origin`; -die("Unable to get github url for 'origin'?\n") unless $origin && $origin =~ m/:(.*)\.git$/; -my $repo = $1; +chomp $origin; # Remove any trailing newlines +die("Unable to get github url for 'origin'?\n") unless $origin; + +# Debug: Print the origin URL +print "Full Origin URL: $origin\n"; + +# Extract the repository path (e.g., Qortal/qortal) NOTE - github is case-sensitive with repo names +my $repo; +if ($origin =~ m/[:\/]([\w\-]+\/[\w\-]+)\.git$/) { + $repo = $1; + print "Extracted direct repository path: $repo\n"; + if ($repo =~ m/^qortal\//i) { + $repo =~ s/^qortal\//Qortal\//; + print "Corrected repository path capitalization: $repo\n"; + } + print "Please verify the direct repository path. Current: '$repo'\n"; + print "If incorrect, input the correct direct repository path (e.g., 'Qortal/qortal' or 'bob/qortal').NOTE - github is CASE SENSITIVE for repository urls... Press Enter to keep the extracted version: "; + my $input = ; + if ($input =~ m/^qortal\//i) { + $input =~ s/^qortal\//Qortal\//; + print "Corrected repository path capitalization: $repo\n"; + } + chomp $input; + $repo = $input if $input; # Update repo if user provides input + +} else { + # Default to qortal/qortal if extraction fails + $repo = "Qortal/qortal"; + print "Failed to extract repository path from origin URL. Using default: $repo\n"; + + # Prompt the user for confirmation or input + print "Please verify the repository path. Current: '$repo'\n"; + print "If incorrect, input the correct repository path (e.g., 'Qortal/qortal' or 'BobsCodeburgers/qortal'). NOTE - GitHub is CASE SENSITIVE for repository urls... Press Enter to keep the default: "; + my $input = ; + if ($input =~ m/^qortal\//i) { + $input =~ s/^qortal\//Qortal\//; + print "Corrected repository path capitalization: $repo\n"; + } + chomp $input; + $repo = $input if $input; # Update repo if user provides input +} + +# Debug: Print the final repository path +print "Final direct repository path: $repo\n"; + +# Construct the update URL my $update_url = "https://github.com/${repo}/raw/${update_hash}/${project}.update"; +print "Final update URL: $update_url\n"; + my $fetch_result = `curl --silent -o /dev/null --location --range 0-1 --head --write-out '%{http_code}' --url ${update_url}`; die("\nUnable to fetch update from ${update_url}\n") if $fetch_result ne '200';