diff options
author | Achilleas Pipinellis <axil@gitlab.com> | 2020-05-20 19:30:02 +0300 |
---|---|---|
committer | Achilleas Pipinellis <axil@gitlab.com> | 2020-05-20 19:30:02 +0300 |
commit | 2d372d7c29600bcd5037f617f4c5e2ceb3fa63c2 (patch) | |
tree | 2cd8d451c83edb7b183350627ed15327950ba95f | |
parent | 61b910f4fd80efe3f6bc02c65892d8a743b9e324 (diff) |
Check charts versions and replace branch variables
This is needed for the release:single raketask. It adds one
failsafe in case the charts version is not charts_versions.yaml.
It also replaces the branch variables in .gitlab-ci.yml with the
respective stable ones.
-rw-r--r-- | Rakefile | 19 | ||||
-rw-r--r-- | lib/task_helpers.rb | 5 |
2 files changed, 24 insertions, 0 deletions
@@ -107,6 +107,12 @@ namespace :release do raise 'You need to specify a version, like 10.1' unless version =~ /\A\d+\.\d+\z/ + # Check if the chart version has been defined + unless chart_version_added?(version) + abort('Rake aborted! The chart version does not exist. Make sure `content/_data/charts_versions.yaml` is updated. + https://docs.gitlab.com/ee/development/documentation/site_architecture/release_process.html#1-add-the-chart-version') + end + # Stash modified and untracked files so we have "clean" environment # without accidentally deleting data puts "Stashing changes" @@ -119,6 +125,7 @@ namespace :release do # Create branch `git checkout -b #{version}` + # Replace the branches variables in Dockerfile.X.Y dockerfile = "#{source_dir}/Dockerfile.#{version}" if File.exist?(dockerfile) @@ -134,6 +141,18 @@ namespace :release do post.puts content end + # Replace the branches variables in .gitlab-ci.yml + ci_yaml = "#{source_dir}/.gitlab-ci.yml" + ci_yaml_content = File.read(ci_yaml) + ci_yaml_content.gsub!("BRANCH_EE: 'master'", "BRANCH_EE: '"+version.tr('.', '-')+"-stable-ee'") + ci_yaml_content.gsub!("BRANCH_OMNIBUS: 'master'", "BRANCH_OMNIBUS: '"+version.tr('.', '-')+"-stable'") + ci_yaml_content.gsub!("BRANCH_RUNNER: 'master'", "BRANCH_RUNNER: '"+version.tr('.', '-')+"-stable'") + ci_yaml_content.gsub!("BRANCH_CHARTS: 'master'", "BRANCH_CHARTS: '"+chart_version(version).tr('.', '-')+"-stable'") + + open(ci_yaml, 'w') do |post| + post.puts ci_yaml_content + end + # Add and commit `git add Dockerfile.#{version}` `git commit -m 'Add #{version} Dockerfile'` diff --git a/lib/task_helpers.rb b/lib/task_helpers.rb index 0cd13591e..b3be00105 100644 --- a/lib/task_helpers.rb +++ b/lib/task_helpers.rb @@ -51,6 +51,11 @@ def git_workdir_dirty? !status.empty? end +def chart_version_added?(gitlab_version) + config = YAML.load_file('./content/_data/chart_versions.yaml') + config.key?(gitlab_version) +end + def chart_version(gitlab_version) config = YAML.load_file('./content/_data/chart_versions.yaml') |