1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mattermost_ynh.git synced 2024-09-03 19:36:29 +02:00
mattermost_ynh/bump-mattermost.rb
Éric Gaspar c88d6ea78f
Merge testing into master (migration to PostgreSQL, change arm64 source, Matermost v7.5.2) (#411)
* Upgrade to v7.3.0

* Auto-update README

* Update config.json

* Upgrade auto-updater (#407)

* [autopatch] Upgrade auto-updater

* Auto-update README

---------

Co-authored-by: tituspijean <titus@pijean.ovh>

* Transition to PostgreSQL (#377)

* backup script for PostgreSQL (#376)

Inspired from https://github.com/YunoHost-Apps/moodle_ynh/blob/master/scripts/backup

* Adapt to PostgreSQL (#375)

Question: in https://docs.mattermost.com/install/install-debian.html#install-postgresql-database-server, I see `BindsTo=postgresql.service` while in the original file here I find `Requires=mysql.service`. I don't know which one makes sense, so I keep the orinigal Yunohost version (Requires)

* config.json for PostgreSQL (#374)

Inspired from the original MySQL config.json and from Mattermost documentation https://docs.mattermost.com/install/install-debian.html#install-postgresql-database-server

* Install with PostgreSQL (#373)

I took inspiration from https://github.com/YunoHost-Apps/commento_ynh/blob/master/scripts/install

* install postgresql

* Reordering

* reset config file

* Update _common.sh

* Update config.json

* Fix

* Migration (#382)

* add migration

* Update upgrade

* Update upgrade

* Update upgrade

* Update upgrade

* Update upgrade

* Update upgrade

* Update upgrade

* Update upgrade

* Update upgrade

* Update upgrade

* Update upgrade

* Update upgrade

* Update upgrade

* Fix

* Fix

* Fix

* Update install

* Update upgrade

* Fix

* Update install

* Update upgrade

* Update upgrade

* Update upgrade

* Update upgrade

* Update upgrade

* Update upgrade

* Update upgrade

* Update upgrade

* Update upgrade

* Update upgrade

* Update upgrade

* Update upgrade

* Update upgrade

* Update upgrade

* Update upgrade

* Update install

* Fix

* Fix

* Fix

* Update upgrade

* Cleaning up

* Update upgrade

* Update _common.sh

* Update check_process

* Update _common.sh

* Fix

* Update mysql-to-pg.conf

* Update upgrade

* Update systemd.service

* Cleaning

* Update _common.sh

* Fix

* Update upgrade

* Update _common.sh

* Update upgrade

* Update backup

* Fix

* Fix

* Update upgrade

* Update upgrade

* Update systemd.service

* Update _common.sh

* Revert "Update _common.sh"

This reverts commit d880150af9.

* Cleaning

* Fix

* Update check_process

* Fix

* Update _common.sh

* Fix

* Update _common.sh

* Fix

* Update manifest.json

* Update install

* Update _common.sh

* Update upgrade

* Fix

* Update _common.sh

* Update _common.sh

* Update _common.sh

* Update _common.sh

* Update _common.sh

* Update _common.sh

* Update _common.sh

* Update _common.sh

* Auto-update README

* Update _common.sh

* Upgrade to v7.4.0

* Auto-update README

* Upgrade to v7.5.2

* Auto-update README

* Update config.json

* [fix] mariadb to postgres migration

* Auto-update README

* [fix] Update manifest requirements

* Update manifest.json

* Update config.json

* upgrade config to upstream

* Fix linter

* Update _common.sh

* Fix typo

* Auto-update README

* Update upgrade

* Update scripts/upgrade

Co-authored-by: Pierre de La Morinerie <kemenaran@gmail.com>

* [enh] Indentation

* Apply suggestions from code review

Co-authored-by: Pierre de La Morinerie <kemenaran@gmail.com>

* [enh] COmments

* Increase timeout for table creation

Co-authored-by: Pierre de La Morinerie <kemenaran@gmail.com>

* test upgrade from 7.2.0

* Auto-update README

* fix db_name in case of multi_instance

* Fix 7.3.0 migration

* delete only the problematic value in db_migrations

* Added explanation for migration management from 7.3.0

* mariadb-to-pg: drop stray columns

These should have been removed in a previous migration, but weren't.

See https://github.com/mattermost/mattermost-server/issues/18351#issuecomment-1325648058

* mariadb-to-pg: increase mattermost timeout

On a small VPS the 2 mn timeout is almost reached.
Increase it to 3 mn.

---------

Co-authored-by: biva <biva@users.noreply.github.com>
Co-authored-by: yunohost-bot <yunohost@yunohost.org>
Co-authored-by: yunohost-bot <yunohost-bot@users.noreply.github.com>
Co-authored-by: ljf <ljf+git@grimaud.me>
Co-authored-by: ljf (zamentur) <zamentur@users.noreply.github.com>
Co-authored-by: Pierre de La Morinerie <kemenaran@gmail.com>
Co-authored-by: Kay0u <pierre@kayou.io>

* Change arm64 source (#409)

* add entreprise for arm64, use the official build for arm64

* Auto-update README

* update auto-updater script

---------

Co-authored-by: yunohost-bot <yunohost@yunohost.org>
Co-authored-by: Éric Gaspar <46165813+ericgaspar@users.noreply.github.com>

* delete the psql db if the migration fails

* Drop all Focalbard tables if mattermost is in 7.3.0

---------

Co-authored-by: yunohost-bot <yunohost-bot@users.noreply.github.com>
Co-authored-by: yunohost-bot <yunohost@yunohost.org>
Co-authored-by: Pierre de La Morinerie <kemenaran@gmail.com>
Co-authored-by: tituspijean <titus@pijean.ovh>
Co-authored-by: biva <biva@users.noreply.github.com>
Co-authored-by: ljf <ljf+git@grimaud.me>
Co-authored-by: ljf (zamentur) <zamentur@users.noreply.github.com>
Co-authored-by: Kay0u <pierre@kayou.io>
2023-03-14 11:16:39 +01:00

155 lines
4 KiB
Ruby
Executable file

#!/usr/bin/env ruby
# [For package maintainers]
# Edit the conf/*.src files with the given Mattermost release.
#
# Usage:
# ./bump-mattermost.rb mattermost-release-version
#
# Example:
# ./bump-mattermost.rb 5.33.2
require 'digest'
require 'json'
require 'open-uri'
module Mattermost
# Describe a Mattermost release from its version and variant.
class ReleaseDescription < Struct.new(:version, :variant)
end
# Retrieve a downloadable release's url and checksum from its ReleaseDescription.
class Release
attr_reader :version
attr_reader :variant
attr_reader :url
attr_reader :sum
def initialize(release_desc)
@version = release_desc.version
@variant = release_desc.variant
retrieve_release_data
end
private
def retrieve_release_data
case @variant
when :team_amd64, :team_arm64, :enterprise_amd64, :enterprise_arm64
retrieve_first_party_release_data
when :team_armhf
retrieve_smart_honeybee_release_data
else
raise "Unsupported variant '{#release_desc.variant}'"
end
end
def retrieve_first_party_release_data
edition = {
team_amd64: 'team',
team_arm64: 'team',
enterprise_amd64: 'enterprise',
enterprise_arm64: 'enterprise'
}.fetch(variant)
arch = {
team_amd64: 'amd64',
team_arm64: 'arm64',
enterprise_amd64: 'amd64',
enterprise_arm64: 'arm64'
}.fetch(variant)
@url = "https://releases.mattermost.com/#{version}/mattermost-#{edition}-#{version}-linux-#{arch}.tar.gz"
puts "Downloading release #{version}-#{edition}-#{arch} for computing checksum…"
release_file = URI.parse(@url).read
@sum = Digest::SHA256.hexdigest(release_file)
end
def retrieve_smart_honeybee_release_data
arch = {
team_armhf: 'arm',
}.fetch(variant)
@url = "https://github.com/SmartHoneybee/ubiquitous-memory/releases/download/v#{version}/mattermost-v#{version}-linux-#{arch}.tar.gz"
puts "Downloading release #{version}-#{variant} for computing checksum…"
release_file = URI.parse(@url).read
@sum = Digest::SHA256.hexdigest(release_file)
end
end
end
module Yunohost
class AppSrcFile
def initialize(path)
@path = path
end
def update_with_release(release)
src = File.read(@path)
replace_src_setting!(src, 'SOURCE_URL', release.url)
replace_src_setting!(src, 'SOURCE_SUM', release.sum)
File.write(@path, src)
end
private
def replace_src_setting!(str, setting, value)
str.gsub!(/^#{setting}=.*$/, "#{setting}=#{value}")
end
end
class ReadmeFile
def initialize(path)
@path = path
end
def update_with_version(version)
readme = File.read(@path)
readme.gsub!(/[0-9\.]+~ynh[0-9]+/, "#{version}~ynh1")
File.write(@path, readme)
end
end
class ManifestFile
def initialize(path)
@path = path
end
def update_with_version(version)
manifest_file = File.read(@path)
manifest = JSON.parse(manifest_file)
manifest['version'] = "#{version}~ynh1"
manifest_file = JSON.pretty_generate(manifest, indent: ' ') + "\n"
File.write(@path, manifest_file)
end
end
end
version=ARGV[0]
if version.nil?
abort("ERROR: The Mattermost release version must be provided.\nExample: ./bump-mattermost.sh 5.33.1")
end
VARIANTS = %i[team_amd64 enterprise_amd64 enterprise_arm64 team_arm64 team_armhf]
# Compute releases URLs and sums
releases = VARIANTS
.map { |variant| Mattermost::ReleaseDescription.new(version, variant) }
.map { |description| Mattermost::Release.new(description) }
# Update conf/*.src files
releases.each do |r|
Yunohost::AppSrcFile.new("conf/#{r.variant}.src").update_with_release(r)
end
# Update manifest file
Yunohost::ManifestFile.new('manifest.json').update_with_version(version)
# Update documentation files
Yunohost::ReadmeFile.new('README.md').update_with_version(version)
Yunohost::ReadmeFile.new('README_fr.md').update_with_version(version)