diff --git a/.github/workflows/core_release.yml b/.github/workflows/core_release.yml new file mode 100644 index 0000000..4c464d2 --- /dev/null +++ b/.github/workflows/core_release.yml @@ -0,0 +1,38 @@ +name: Core Release +run-name: Update helm chart for core release ${{ inputs.tag }} by @${{ github.actor }} + +on: + workflow_dispatch: + inputs: + tag: + description: "Core tag" + required: true + default: dev + type: string + +permissions: + contents: write + pull-requests: write + +jobs: + release: + name: Changeset and Release + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.3' + + - name: Configure Git + run: | + git config user.name openprojectci + git config user.email operations+openprojectci@openproject.com + + - name: Bump release + run: ruby bin/update_from_core_release "${{ inputs.tag }}" diff --git a/.ruby-version b/.ruby-version index 619b537..a0891f5 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.3.3 +3.3.4 diff --git a/bin/update_from_core_release b/bin/update_from_core_release new file mode 100755 index 0000000..a4bcb41 --- /dev/null +++ b/bin/update_from_core_release @@ -0,0 +1,44 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require 'yaml' + +def version_bump(v1, v2) + if v1.segments[0] < v2.segments[0] + :major + elsif v1.segments[1] < v2.segments[1] + :minor + elsif v1.segments[2] < v2.segments[2] + :patch + end +end + + +next_version = Gem::Version.new(ARGV.pop) + +# Find current version +chart_file = File.expand_path('../charts/openproject/Chart.yaml', __dir__) +chart = YAML.load_file(chart_file) +current_version = Gem::Version.new(chart.fetch('appVersion')) + +if next_version == current_version + echo "Version #{next_version} is already the current version" + exit 1 +end + +# Get the bump type (major, minor, patch) +bump_type = version_bump(current_version, next_version) +raise ArgumentError.new("Failed to find version bump") if bump_type.nil? + +puts "Bumping version from #{current_version} to #{next_version} (#{bump_type})" + +changeset_name = "#{next_version.to_s.gsub('.', '-')}_#{bump_type}.md" +File.open(File.expand_path("../.changeset/#{changeset_name}", __dir__), 'w') do |f| + f.write <<~CHANGE + --- + "@openproject/helm-charts": #{bump_type} + --- + + Upgrade OpenProject core version to #{next_version} (#{bump_type} update) + CHANGE +end