# frozen_string_literal: true module Makit VERSION = "0.0.51" class Version # given an array of version strings, return the highest version def self.get_highest_version(versions) versions.sort { |a, b| Gem::Version.new(a) <=> Gem::Version.new(b) }.last end # example content from .gitlab-ci.yml #variables: # VERSION: "0.0.26" # Define the version here def self.get_version_from_file(path) if (!File.exist?(path)) raise "file #{path}does not exist" end extension = File.extname(path) #switch = extension.downcase #case switch #if extension == ".csproj" switch = extension.downcase case switch when ".csproj" Makit::Version.detect_from_file(path, /([-\w\d.]+)([-\w\d.]+)#{version}<") if filename.include?(".csproj") new_text = text.gsub(/([-\w\d.]+)#{version}<") if filename.include?(".nuspec") new_text = text.gsub(/ Version="([\d\.]+)"/, " Version=\"#{version}\"") if filename.include?(".wxs") new_text = text.gsub(/version\s+=\s+['"]([\w.]+)['"]/, "version=\"#{version}\"") if filename.include?(".toml") File.open(filename, "w") { |f| f.write(new_text) } if new_text != text end end end