docman 0.0.92 → 0.0.93

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 777f7078a84844efa58f0ff3acb3901b3edc5d7f
4
- data.tar.gz: e1641e86ec4af29ae6ec3054c5e9272c2b9c11b2
3
+ metadata.gz: 31ef7f70bc197d88a105f021b6a46dd5d23a8b53
4
+ data.tar.gz: 6e4bd481345897e5f3202cbdb211768026b79fb9
5
5
  SHA512:
6
- metadata.gz: 657472c22a37269eb1d977f2d1a6b017e36d3c544f093e94bba2ee5f9ee35f57cb2d5b80540621ae8ebfd8a365c44e91f683a33c2d870a852bc30f5aa42bcb1c
7
- data.tar.gz: 9612a4fb22de868ea4d547bce3108d5c68961aa8bff89a29a08ba1d2a25e3e0b870268946e89ab6c6f717dc4010cb75a9406fb46433961de2a7877b6c773fa15
6
+ metadata.gz: 55698165ee3cea7616f7a3dc95a3173512a4e0a5431efb7c0a56fb492581146f249e842595f4add7f9d5670cc4e12dc2ae969cea3f33a9a7dfe8e7cb1d249be9
7
+ data.tar.gz: feba77323338001c1fefccf296df0cead3d4bdff705035ee778e2d77eca8a4b423fccffa8adf553cc1fb4919326faa8b906e9b1326be2199755ad90779d0ef3c
@@ -1,41 +1,116 @@
1
1
  #!/bin/bash
2
-
2
+
3
3
  # works with a file called VERSION in the current directory,
4
4
  # the contents of which should be a semantic version number
5
5
  # such as "1.2.3"
6
-
6
+
7
7
  # this script will display the current version, automatically
8
8
  # suggest a "minor" version update, and ask for input to use
9
9
  # the suggestion, or a newly entered value.
10
-
10
+
11
11
  # once the new version number is determined, the script will
12
12
  # pull a list of changes from git history, prepend this to
13
13
  # a file called CHANGES (under the title of the new version
14
14
  # number) and create a GIT tag.
15
15
 
16
- git checkout master
17
- git pull origin master
16
+ POSITIONAL=()
17
+ BRANCH="master"
18
+ NEXT=0
19
+ SKIP=0
20
+
21
+ if [[ $# == 0 ]]; then
22
+ POSITIONAL+=("-h")
23
+ set -- "${POSITIONAL[@]}" # restore positional parameters
24
+ fi
25
+
26
+ while [[ $# -gt 0 ]]; do
27
+ key="$1"
28
+ case $key in
29
+ -b|--branch*)
30
+ if [[ $key == "-b" ]] || [[ $key == "--branch" ]]; then
31
+ BRANCH="$2"
32
+ shift # past argument
33
+ shift # past value
34
+ else
35
+ BRANCH="${1#*=}"
36
+ shift # past argument=value
37
+ fi
38
+ ;;
39
+ -n|--next)
40
+ NEXT=1
41
+ shift # past argument
42
+ ;;
43
+ -s|--skip)
44
+ SKIP=1
45
+ shift # past argument
46
+ ;;
47
+ -h|--help)
48
+ echo "Usage: -[hbns] [state] [next] [skip]"
49
+ echo -e "\t-h, --help\n\t\tShow this help message."
50
+ echo -e "\t-b [branch], --branch [branch], --branch=[branch]\n\t\tTag specific branch."
51
+ echo -e "\t-n, --next\n\t\tSet next release without prompt."
52
+ echo -e "\t-s, --skip\n\t\tSkip CI trigger with commit message."
53
+ exit 0
54
+ ;;
55
+ *) # unknown option
56
+ POSITIONAL+=("$1") # save it in an array for later
57
+ shift # past argument
58
+ ;;
59
+ esac
60
+ done
61
+
62
+ set -- "${POSITIONAL[@]}" # restore positional parameters
63
+
64
+ if [[ $NEXT == 0 ]] && [ -n "$2" ] && [ "$2" == "next" ]; then
65
+ NEXT=1
66
+ fi
67
+
68
+ if [[ $SKIP == 0 ]] && [ -n "$3" ] && [ "$3" == "skip" ]; then
69
+ SKIP=1
70
+ fi
71
+
18
72
  git fetch
73
+ git checkout $BRANCH
74
+ git pull origin $BRANCH 2>/dev/null || echo "Branch not found on origin."
19
75
 
20
76
  if [ -f VERSION ]; then
21
77
  BASE_STRING=`cat VERSION`
22
- BASE_LIST=(`echo $BASE_STRING | tr '.' ' '`)
23
- V_MAJOR=${BASE_LIST[0]}
24
- V_MINOR=${BASE_LIST[1]}
25
- V_PATCH=${BASE_LIST[2]}
26
- echo "Current version : $BASE_STRING"
27
- #V_MINOR=$((V_MINOR + 1))
28
- V_PATCH=$((V_PATCH + 1))
29
- #V_PATCH=0
30
- SUGGESTED_VERSION="$V_MAJOR.$V_MINOR.$V_PATCH"
31
-
32
- if [ -n "$2" ] && [ "$2" == "next" ]; then
33
- INPUT_STRING=$SUGGESTED_VERSION
78
+ if [[ $BASE_STRING =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)([\.\-][0-9a-zA_Z_\-]+)?$ ]]; then
79
+ V_MAJOR=${BASH_REMATCH[1]}
80
+ V_MINOR=${BASH_REMATCH[2]}
81
+ V_PATCH=${BASH_REMATCH[3]}
82
+ V_SUFFIX=${BASH_REMATCH[4]}
83
+ echo "Current version : $BASE_STRING"
84
+ V_PATCH=$((V_PATCH + 1))
85
+ SUGGESTED_VERSION="${V_PREFIX}${V_MAJOR}.${V_MINOR}.${V_PATCH}${V_SUFFIX}"
34
86
  else
35
- read -p "Enter a version number [$SUGGESTED_VERSION]: " INPUT_STRING
36
- if [ "$INPUT_STRING" = "" ]; then
87
+ if [[ $BASE_STRING =~ ^([0-9a-zA_Z_\-]+[\-])([0-9]+)\.([0-9]+)\.([0-9]+)([\.\-][0-9a-zA_Z_\-]+)?$ ]]; then
88
+ V_PREFIX=${BASH_REMATCH[1]}
89
+ V_MAJOR=${BASH_REMATCH[2]}
90
+ V_MINOR=${BASH_REMATCH[3]}
91
+ V_PATCH=${BASH_REMATCH[4]}
92
+ V_SUFFIX=${BASH_REMATCH[5]}
93
+ echo "Current version : $BASE_STRING"
94
+ V_PATCH=$((V_PATCH + 1))
95
+ SUGGESTED_VERSION="${V_PREFIX}${V_MAJOR}.${V_MINOR}.${V_PATCH}${V_SUFFIX}"
96
+ fi
97
+ fi
98
+
99
+ if [ -n "$SUGGESTED_VERSION" ]; then
100
+ if [[ $NEXT == 1 ]]; then
37
101
  INPUT_STRING=$SUGGESTED_VERSION
38
- fi
102
+ else
103
+ read -p "Enter a version number [$SUGGESTED_VERSION]: " INPUT_STRING
104
+ if [ "$INPUT_STRING" = "" ]; then
105
+ INPUT_STRING=$SUGGESTED_VERSION
106
+ fi
107
+ fi
108
+ else
109
+ read -p "Enter a version number: " INPUT_STRING
110
+ if [ "$INPUT_STRING" = "" ]; then
111
+ echo "Version number should not be empty to continue."
112
+ exit 1
113
+ fi
39
114
  fi
40
115
 
41
116
  echo "Will set new version to be $INPUT_STRING"
@@ -51,7 +126,7 @@ if [ -f VERSION ]; then
51
126
  git commit -m "[skip] [ci-skip] [ci skip] Version bump to $INPUT_STRING"
52
127
  git tag -a -m "[skip] [ci-skip] [ci skip] Tagging version $INPUT_STRING" "$INPUT_STRING"
53
128
  git push origin ${INPUT_STRING}
54
- git push origin master
129
+ git push origin $BRANCH
55
130
  else
56
131
  echo "Could not find a VERSION file"
57
132
  read -p "Do you want to create a version file and start from scratch? [y]" RESPONSE
@@ -70,33 +145,34 @@ else
70
145
  git commit -m "[skip] [ci-skip] [ci skip] Added VERSION and CHANGES files, Version bump to 0.1.0"
71
146
  git tag -a -m "[skip] [ci-skip] [ci skip] Tagging version 0.1.0" "0.1.0"
72
147
  git push origin --tags
73
- git push origin master
148
+ git push origin $BRANCH
74
149
  fi
75
150
  TAG="0.1.0"
76
151
  fi
77
152
 
78
153
  if [ -n "$1" ]; then
79
154
  git fetch
80
- BRANCH="state_$1"
155
+ STATE_BRANCH="state_$1"
81
156
  #git show-ref --verify --quiet "refs/heads/${BRANCH}"
82
157
  git ls-remote --exit-code . origin/state_stable &> /dev/null
83
158
  if [ $? == 0 ]; then
84
- git checkout ${BRANCH}
85
- git pull origin ${BRANCH}
159
+ git checkout ${STATE_BRANCH}
160
+ git pull origin ${STATE_BRANCH}
86
161
  else
87
- git checkout --orphan ${BRANCH}
162
+ git checkout --orphan ${STATE_BRANCH}
88
163
  git rm --cached -r .
89
164
  git clean -f -d
90
165
  fi
91
166
  echo "type: tag" > info.yaml
92
167
  echo "version: $TAG" >> info.yaml
93
168
  git add info.yaml
94
- if [ -n "$3" ] && [ "$3" == "skip" ]; then
95
- git commit -m "[skip] [ci-skip] [ci skip] Changed tag to: $TAG" & git push -u origin ${BRANCH}
169
+ if [[ $SKIP == 1 ]]; then
170
+ git commit -m "[skip] [ci-skip] [ci skip] Changed tag to: $TAG"
171
+ git push -u origin ${STATE_BRANCH}
96
172
  else
97
173
  git commit -m "Changed tag to: $TAG"
98
- git push -u origin ${BRANCH}
174
+ git push -u origin ${STATE_BRANCH}
99
175
  fi
100
- git checkout master
176
+ git checkout $BRANCH
101
177
  echo ${TAG}
102
178
  fi
@@ -72,12 +72,16 @@ module Docman
72
72
 
73
73
  desc 'bump', 'Bump version'
74
74
  method_option :next, :aliases => '-n', :desc => 'Automatically use next version number'
75
+ method_option :branch, :aliases => '-b', :desc => 'Bump release on specific branch'
76
+ method_option :skip, :aliases => '-s', :desc => 'Skip CI with commit message'
75
77
  #option :state
76
78
  #option :skip
77
- def bump(state = nil, skip = nil)
78
- version_number = options[:next] ? 'next' : 'ask'
79
-
80
- Exec.do "#{Application::bin}/bump-version.sh #{state} #{version_number} #{skip}"
79
+ def bump(state = nil)
80
+ bump_params = []
81
+ bump_params.push("--branch=#{options[:branch]}") if options[:branch]
82
+ bump_params.push('--next') if options[:next]
83
+ bump_params.push('--skip') if options[:skip]
84
+ Exec.do "#{Application::bin}/bump-version.sh #{bump_params.join(' ')} #{state}"
81
85
  say('Complete!', :green)
82
86
  end
83
87
 
@@ -1,3 +1,3 @@
1
1
  module Docman
2
- VERSION = "0.0.92"
2
+ VERSION = "0.0.93"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.92
4
+ version: 0.0.93
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Tolstikov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-15 00:00:00.000000000 Z
11
+ date: 2018-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler