Skip to content

Commit

Permalink
change release script to bump versions
Browse files Browse the repository at this point in the history
  • Loading branch information
toy committed Mar 24, 2020
1 parent 3d066e5 commit 35c287f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ make test
To release new version:

```sh
./release X.X.X # where X.X.X is version
./release major|minor|patch
```

## Copyright
Expand Down
20 changes: 16 additions & 4 deletions release
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,21 @@
require 'pathname'
require 'date'

abort "Expected new version as the only argument" unless ARGV.length == 1
MAIN_FILE = 'blueutil.m'
DEFINE_VERSION_REGEXP = /(?<=#define VERSION ")\d+(?:\.\d+)+(?=")/

new_version = ARGV.first
version_parts = File.read(MAIN_FILE)[DEFINE_VERSION_REGEXP].split('.').map(&:to_i)

new_version = case ARGV
when %w[major]
"#{version_parts[0] + 1}.0.0"
when %w[minor]
"#{version_parts[0]}.#{version_parts[1] + 1}.0"
when %w[patch]
"#{version_parts[0]}.#{version_parts[1]}.#{version_parts[2] + 1}"
else
abort 'Expected major, minor or patch as the only argument'
end

def clean_workind_directory?
`git status --porcelain`.empty?
Expand All @@ -28,8 +40,8 @@ paths = Pathname.glob('*').select do |path|
end

case path.to_s
when 'blueutil.m'
changed = changed.sub(/(?<=#define VERSION ")\d+(?:\.\d+)+(?=")/, new_version)
when MAIN_FILE
changed = changed.sub(DEFINE_VERSION_REGEXP, new_version)
when 'CHANGELOG.md'
lines = changed.lines
{
Expand Down

0 comments on commit 35c287f

Please sign in to comment.