From a72a6e3b4f8debe619d70155da127be37f76b369 Mon Sep 17 00:00:00 2001 From: David Sterry Date: Sat, 4 Dec 2021 14:42:54 -0800 Subject: [PATCH] Add bump-version script and dot-separated date-based version (#17) * add bump_version.rb from ecko_ynh and bump the version * change date-based version separator to dot * Auto-update README Co-authored-by: Yunohost-Bot <> --- README.md | 2 +- README_fr.md | 2 +- bump-version.rb | 72 +++++++++++++++++++++++++++++++++++++++++++++++++ conf/app.src | 8 +++--- manifest.json | 9 ++++--- 5 files changed, 84 insertions(+), 9 deletions(-) create mode 100755 bump-version.rb diff --git a/README.md b/README.md index 5f191db..982093c 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Some long and extensive description of what the app is and does, lorem ipsum dol - Excepteur sint occaecat cupidatat non proident, sunt in culpa." -**Shipped version:** 1.0~ynh1 +**Shipped version:** 2021.12.02~ynh1 diff --git a/README_fr.md b/README_fr.md index b703d6d..d88be2c 100644 --- a/README_fr.md +++ b/README_fr.md @@ -22,7 +22,7 @@ Some long and extensive description of what the app is and does, lorem ipsum dol - Excepteur sint occaecat cupidatat non proident, sunt in culpa." -**Version incluse :** 1.0~ynh1 +**Version incluse :** 2021.12.02~ynh1 diff --git a/bump-version.rb b/bump-version.rb new file mode 100755 index 0000000..b2a5c65 --- /dev/null +++ b/bump-version.rb @@ -0,0 +1,72 @@ +#!/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/magicstone-dev/acropolis/branches/main').read) +last_commit = github["commit"]["sha"] +version = Date.parse(github["commit"]["commit"]["author"]["date"]).to_s.gsub '-', '.' + +url = "https://github.com/magicstone-dev/acropolis/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!" diff --git a/conf/app.src b/conf/app.src index 5d91071..42744a5 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,7 +1,7 @@ -SOURCE_URL=https://github.com/magicstone-dev/acropolis/archive/refs/tags/v0.7.15.0.tar.gz -SOURCE_SUM=0cfc5f10ec8859280c95cb5db95846381621da0306cd4100f12691f18efa36be +SOURCE_URL=https://github.com/magicstone-dev/acropolis/archive/2b1c78ae680abcf42aa6a859139009defda61c1c.tar.gz +SOURCE_SUM=552c3564085fbb6acb8a330477bdda5ab43535969651b5076f92e4036499dcbf SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= -SOURCE_EXTRACT=true +SOURCE_FILENAME=2b1c78ae680abcf42aa6a859139009defda61c1c.tar.gz +SOURCE_EXTRACT=true \ No newline at end of file diff --git a/manifest.json b/manifest.json index d36c7b8..62a8cec 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Dynamic fork of diaspora*'s federated social network, est. Aug 2021.", "fr": "Fourche dynamique du réseau social fédéré de diaspora*, créé en août 2021." }, - "version": "1.0~ynh1", + "version": "2021.12.02~ynh1", "url": "https://github.com/magicstone-dev/acropolis", "upstream": { "license": "free", @@ -25,7 +25,7 @@ "nginx" ], "arguments": { - "install" : [ + "install": [ { "name": "domain", "type": "domain" @@ -52,7 +52,10 @@ "en": "Choose the application language", "fr": "Choisissez la langue de l'application" }, - "choices": ["fr", "en"], + "choices": [ + "fr", + "en" + ], "default": "fr" }, {