Skip to content

Commit

Permalink
Add status messages to updater script
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Snowhill <[email protected]>
  • Loading branch information
kode54 committed Jul 21, 2023
1 parent 2d7a748 commit 8ad84c3
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Scripts/update_feed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
site_dir = "#{Dir.home}/Source/Repos/kode54-net/cog"

appcast = open("#{site_dir}/#{feed}_builds/#{feed}.xml")
puts "Reading feed..."

appcastdoc = Nokogiri::XML(appcast)

Expand Down Expand Up @@ -82,6 +83,7 @@
filenamedesc = "Cog-#{revision_code}.html"
deltamask = "Cog#{revision_number}-"
temp_path = "/tmp";
puts "Generating zip file for Cog..."
%x[rm -rf '#{temp_path}/Cog.app' '#{temp_path}/Cog.zip']

#Copy the replacement build
Expand All @@ -105,31 +107,39 @@
%x[rm '#{descriptiondoc.path}']

#Update appcast
puts "Generating appcast..."
%x[generate_appcast '#{site_dir}/#{feed}_builds']

#List out the deltas
deltas = Dir.entries("#{site_dir}/#{feed}_builds").select { |f| f =~ /\A#{Regexp.escape(deltamask)}.+\.delta\z/ }

#Upload them to R2
puts "Uploading full build to R2..."
%x[rclone copy '#{site_dir}/#{feed}_builds/#{filename}' r2:cog/ --progress]
deltas.each do |f|
puts "Uploading delta #{f} to R2..."
%x[rclone copy '#{site_dir}/#{feed}_builds/#{f}' r2:cog/ --progress]
end

#Upload the changelog that Sparkle will display
puts "Uploading changelog to R2..."
%x[rclone copy '#{site_dir}/#{feed}_builds/#{filenamedesc}' r2:cog/ --progress]

#Clean up
%x[rm -rf '#{temp_path}/Cog.app']

#Convert to JSON
puts "Converting to JSON..."
%x[pushd '#{site_dir}/#{feed}_builds' && '#{__dir__}/sparkleToJSON' '#{site_dir}/#{feed}_builds/#{feed}.xml' && popd]

#Upload to R2
puts "Uploading XML feed to R2..."
%x[rclone copy '#{site_dir}/#{feed}_builds/#{feed}.xml' r2:cog/ --progress]
puts "Uploading JSON feed to R2..."
%x[rclone copy '#{site_dir}/#{feed}_builds/#{feed}.json' r2:cog/ --progress]

#Send web hook to update site
puts "Sending web hook to update site..."
update_uri = %x[security find-generic-password -w -a #{ENV['LOGNAME']} -s cogupdateurl].chop
update_parameter = URI.escape(latest_revision)
%x[curl -X POST '#{update_uri}?trigger_title=#{update_parameter}']
Expand Down

0 comments on commit 8ad84c3

Please sign in to comment.