diff --git a/README.md b/README.md index 88c3150..178c648 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,9 @@ “Dobby is free.” -A Github action which provides chat-ops functionality. You can comment on Pull request to perform various operations. -Currently it supports bumping version for a gem. +A Github action which provides chat-ops functionality. You can comment on a pull request to perform various operations. +Currently it supports bumping version files in Ruby, Python and Javascript. The version file (see below) must specify the version +as a key-value pair separated by either ":" or "=", e.g. `VERSION: '1.2.3'` or `version = 1.2.3` ## Bump version @@ -14,8 +15,8 @@ Dobby requires a Github App to be installed either on an individual repository o - Set GitHub App name. - Set Homepage URL to your github repository. - Uncheck Active under Webhook. You do not need to enter a Webhook URL. - - Under Repository permissions: Contents select Access: Read & write. - - Under Repository permissions: Pull requests select Access: Read & write. + - Under Permissions & Events > Repository permissions > Contents select Access: Read & write. + - Under Permissions & Events > Repository permissions > Pull requests select Access: Read & write. 2. Create a Private key from the App settings page and store it securely. diff --git a/lib/command.rb b/lib/command.rb index 8c50aab..3dbff2f 100644 --- a/lib/command.rb +++ b/lib/command.rb @@ -11,8 +11,8 @@ class Command def initialize(config) @config = config comment = config.payload['comment']['body'].strip.downcase - error_msg = "Comment must be start with #{COMMAND_PREFIX}" - puts "::error title=Arguement Error::#{error_msg}" + error_msg = "Comment must start with #{COMMAND_PREFIX}" + puts "::error title=Argument Error::#{error_msg}" raise ArgumentError, error_msg unless comment.start_with?(COMMAND_PREFIX) cmd = comment.delete_prefix(COMMAND_PREFIX) diff --git a/lib/utils/bump.rb b/lib/utils/bump.rb index d1b104c..08b1e0e 100644 --- a/lib/utils/bump.rb +++ b/lib/utils/bump.rb @@ -4,9 +4,10 @@ require_relative 'commit' class Bump - SEMVER_VERSION = - /["'](0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?["']/ # rubocop:disable Layout/LineLength - GEMSPEC_VERSION = Regexp.new(/\.version\s*=\s*/.to_s + SEMVER_VERSION.to_s).freeze + SEMVER = /["']*(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?["']*/ # rubocop:disable Layout/LineLength + SEPARATOR = /\s*[:=]\s*/ + VERSION_KEY = /(^|\.|\s)version/ + VERSION_SETTING = Regexp.new(VERSION_KEY.source + SEPARATOR.source + SEMVER.source, Regexp::IGNORECASE).freeze def initialize(config, level) @config = config @@ -56,8 +57,8 @@ def assign_pr_attributes!(pr_number) end def fetch_version(content) - version = content.content.match(GEMSPEC_VERSION) || content.content.match(SEMVER_VERSION) - Semantic::Version.new(version[0].split('=').last.gsub(/\s/, '').gsub(/'|"/, '')) + version = content.content.match(VERSION_SETTING) + Semantic::Version.new(version[0].split(SEPARATOR).last.gsub(/\s/, '').gsub(/'|"/, '')) end def bump_version(version, level)