hugo-sandstorm/bin/upgrade_hugo

51 lines
1.1 KiB
Plaintext
Raw Permalink Normal View History

2020-04-26 20:51:55 +00:00
#!/usr/bin/env ruby
require 'httparty'
require 'time'
version = ARGV[0]
unless version
2022-06-01 03:10:16 +00:00
puts "Usage: #{$0} <version>"
2020-04-26 20:51:55 +00:00
exit 1
end
2022-10-04 11:13:41 +00:00
verify_url = "https://github.com/gohugoio/hugo/releases/download/v#{version}/hugo_extended_#{version}_linux-amd64.deb"
2020-04-26 20:51:55 +00:00
response = HTTParty.get(verify_url)
unless response.code >= 200 && response.code < 300
2022-06-01 03:07:07 +00:00
puts 'Error verifying release exists!'
2020-04-26 20:51:55 +00:00
puts " URL checked: #{verify_url}"
puts " Response code: #{response.code}"
exit 1
end
puts "#{version} exists, updating files"
today = Time.now.strftime('%Y-%m-%d')
File.open('hugo-version', 'w') { |fh| fh.puts version }
File.open('.sandstorm/app-marketing-version', 'w') { |fh| fh.puts "#{version}~#{today}" }
lines = File.readlines('.sandstorm/sandstorm-pkgdef.capnp')
lines = lines.map do |line|
next line unless line['appVersion']
2022-06-01 03:07:07 +00:00
line.gsub(/= ([0-9]+),/) { |_m| "= #{Regexp.last_match(1).to_i + 1}," }
2020-04-26 20:51:55 +00:00
end
File.open('.sandstorm/sandstorm-pkgdef.capnp', 'w') { |fh| fh.print lines.join }
2022-06-01 03:10:16 +00:00
puts <<~TXT
2020-04-26 20:51:55 +00:00
2022-06-01 03:10:16 +00:00
Now do this:
2020-04-26 20:51:55 +00:00
2022-06-01 03:10:16 +00:00
* bin/test_hugo
* Test fresh install
* bin/pack_hugo
* Test upgrade install
TXT