mirror of
https://github.com/YunoHost-Apps/glitchsoc_ynh.git
synced 2024-09-03 19:15:59 +02:00
bump package version
This commit is contained in:
parent
a2690c5401
commit
8db3f3f51d
3 changed files with 5 additions and 73 deletions
|
@ -1,72 +0,0 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
# [For package maintainers]
|
||||
# Edit the conf/app.src files with the latest commit
|
||||
#
|
||||
# Usage:
|
||||
# ./bump-version.rb
|
||||
|
||||
require 'digest'
|
||||
require 'json'
|
||||
require 'open-uri'
|
||||
|
||||
module Yunohost
|
||||
class AppSrcFile
|
||||
def initialize(path = 'conf/app.src')
|
||||
@path = path
|
||||
end
|
||||
|
||||
def update(url, sum)
|
||||
src = File.read(@path)
|
||||
replace_src_setting!(src, 'SOURCE_URL', url)
|
||||
replace_src_setting!(src, 'SOURCE_SUM', sum)
|
||||
replace_src_setting!(src, 'SOURCE_FILENAME', File.basename(URI.parse(url).path))
|
||||
File.write(@path, src)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def replace_src_setting!(str, setting, value)
|
||||
str.gsub!(/^#{setting}=.*$/, "#{setting}=#{value}")
|
||||
end
|
||||
end
|
||||
|
||||
class ManifestFile
|
||||
def initialize(path = 'manifest.json')
|
||||
@path = path
|
||||
end
|
||||
|
||||
def update_with_version(version)
|
||||
manifest_file = File.read(@path)
|
||||
manifest = JSON.parse(manifest_file)
|
||||
|
||||
if manifest['version'].start_with? version
|
||||
i = manifest['version'].scan(/~ynh(\d)/).flatten.first.to_i + 1
|
||||
manifest['version'] = "#{version}~ynh#{i}"
|
||||
else
|
||||
manifest['version'] = "#{version}~ynh1"
|
||||
end
|
||||
|
||||
manifest_file = JSON.pretty_generate(manifest, indent: ' ') + "\n"
|
||||
File.write(@path, manifest_file)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
github = JSON.parse(URI.parse('https://api.github.com/repos/glitch-soc/mastodon/branches/main').read)
|
||||
last_commit = github["commit"]["sha"]
|
||||
version = Date.parse(github["commit"]["commit"]["author"]["date"]).to_s.gsub '-', '.'
|
||||
|
||||
url = "https://github.com/glitch-soc/mastodon/archive/#{last_commit}.tar.gz"
|
||||
|
||||
puts "Downloading last commit at #{url}"
|
||||
release_file = URI.parse(url).read
|
||||
sum = Digest::SHA256.hexdigest(release_file)
|
||||
|
||||
# Update source file
|
||||
Yunohost::AppSrcFile.new().update(url, sum)
|
||||
|
||||
# Update manifest file
|
||||
Yunohost::ManifestFile.new().update_with_version(version)
|
||||
|
||||
puts "Done!"
|
|
@ -12,9 +12,13 @@
|
|||
setup_private=1
|
||||
setup_public=1
|
||||
upgrade=1
|
||||
# 2022.01.10~ynh1
|
||||
upgrade=1 from_commit=9fb00be10143ee57685d4c84b21029921b33e159
|
||||
backup_restore=1
|
||||
multi_instance=0
|
||||
port_already_use=0
|
||||
change_url=0
|
||||
;;; Options
|
||||
;;; Upgrade options
|
||||
; commit=efbdbb05350b820c6e59a7bbbf70f57cf679fff8
|
||||
name=2022.01.10~ynh1
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"en": "Libre and federated social network, fork of Mastodon",
|
||||
"fr": "Réseau social libre et fédéré, scission de Mastodon"
|
||||
},
|
||||
"version": "2022.01.10~ynh1",
|
||||
"version": "2022.01.10~ynh2",
|
||||
"url": "https://github.com/glitch-soc/mastodon",
|
||||
"upstream": {
|
||||
"license": "free",
|
||||
|
|
Loading…
Add table
Reference in a new issue