Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic release of helm chart on core release trigger #141

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/core_release.yml
Original file line number Diff line number Diff line change
@@ -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 [email protected]

- name: Bump release
run: ruby bin/update_from_core_release "${{ inputs.tag }}"
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.3.3
3.3.4
44 changes: 44 additions & 0 deletions bin/update_from_core_release
Original file line number Diff line number Diff line change
@@ -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
Loading