please-release-me 2.1.6 → 3.1.0

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.
Files changed (3) hide show
  1. package/README.md +13 -21
  2. package/package.json +1 -1
  3. package/release.sh +103 -61
package/README.md CHANGED
@@ -15,7 +15,7 @@
15
15
  ## What is it?
16
16
 
17
17
  An automated release script
18
- for npm, Rust and Python,
18
+ for npm, Go, Rust and Python,
19
19
  built to work with
20
20
  the conventions
21
21
  used by my packages.
@@ -75,43 +75,35 @@ in order:
75
75
  * Otherwise,
76
76
  increment the patch number.
77
77
 
78
- 7. If `bower.json` exists,
79
- write the freshly bumped version string
80
- to `bower.json`.
81
-
82
- 8. If `component.json` exists,
83
- write the freshly bumped version string
84
- to `component.json`.
85
-
86
- 9. If `package.json` exists,
78
+ 7. If `package.json` exists,
87
79
  write the freshly bumped version string
88
80
  to `package.json`.
89
81
 
90
- 10. If `package-lock.json` exists,
82
+ 8. If `package-lock.json` exists,
91
83
  run `npm i`.
92
84
 
93
- 11. If `npm-shrinkwrap.json` exists,
85
+ 9. If `npm-shrinkwrap.json` exists,
94
86
  run `npm shrinkwrap`.
95
87
 
96
- 12. If `pnpm-lock.yaml` exists,
88
+ 10. If `pnpm-lock.yaml` exists,
97
89
  run `pnpm i`.
98
90
 
99
- 13. If `yarn.lock` exists,
91
+ 11. If `yarn.lock` exists,
100
92
  run `yarn`.
101
93
 
102
- 14. If `setup.py` exists,
94
+ 12. If `setup.py` exists,
103
95
  write the freshly bumped version string
104
96
  to `setup.py`.
105
97
 
106
- 15. If `Cargo.toml` exists,
98
+ 13. If `Cargo.toml` exists,
107
99
  write the freshly bumped version string
108
100
  to `Cargo.toml`.
109
101
 
110
- 16. If `Cargo.lock` exists,
102
+ 14. If `go.mod` exists,
111
103
  write the freshly bumped version string
112
- to `Cargo.lock`.
104
+ to `go.mod`.
113
105
 
114
- 17. If a change log is detected,
106
+ 15. If a change log is detected,
115
107
  write a summary of the changes
116
108
  to the change log.
117
109
  It will recognise any of the following file names:
@@ -134,7 +126,7 @@ in order:
134
126
 
135
127
  * `HISTORY`
136
128
 
137
- 18. Commit all changes
129
+ 16. Commit all changes
138
130
  made by the preceding steps.
139
131
 
140
132
  17. If `Cargo.toml` exists,
@@ -142,7 +134,7 @@ in order:
142
134
  If it fails,
143
135
  the release is aborted.
144
136
 
145
- 18. Tag the release
137
+ 18. Tag the repo
146
138
  with the freshly bumped version string.
147
139
 
148
140
  ## What doesn't it do?
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "please-release-me",
3
- "version": "2.1.6",
3
+ "version": "3.1.0",
4
4
  "description": "Let me go!",
5
5
  "author": "Phil Booth <pmbooth@gmail.com> (https://philbooth.me/)",
6
6
  "license": "MIT",
package/release.sh CHANGED
@@ -1,49 +1,83 @@
1
1
  #!/bin/sh
2
2
 
3
- LAST_TAG=`git describe --tags --abbrev=0`
4
- COMMITS=`git log $LAST_TAG..HEAD --pretty=oneline`
3
+ LAST_TAG=$(git describe --tags --abbrev=0)
4
+ COMMITS=$(git log "$LAST_TAG..HEAD" --pretty=oneline)
5
5
 
6
- if [ "$COMMITS" = "" ]; then
7
- echo "Release aborted: I see no work."
6
+ if [ "$1" = "--notest" ]; then
7
+ TEST=false
8
+ else
9
+ TEST=true
10
+ fi
11
+
12
+ if [ -f go.mod ]; then
13
+ IS_GO=true
14
+ fi
15
+
16
+ if [ -f package.json ]; then
17
+ IS_NODE=true
18
+ fi
19
+
20
+ if [ -f setup.py ]; then
21
+ IS_PYTHON=true
22
+ fi
23
+
24
+ if [ -f Cargo.toml ]; then
25
+ IS_RUST=true
26
+ fi
27
+
28
+ abort() {
29
+ echo "Release aborted: $1"
8
30
  exit 1
31
+ }
32
+
33
+ if [ "$COMMITS" = "" ]; then
34
+ abort "I see no work"
9
35
  fi
10
36
 
11
- grep '^\s*"lint":' package.json > /dev/null 2>&1
12
- if [ $? -eq 0 ]; then
13
- npm run lint
14
- if [ $? -ne 0 ]; then
15
- echo "Release aborted: Lint failed."
16
- exit 1
37
+ if [ "$IS_GO" ]; then
38
+ if ! go vet ./...; then
39
+ abort "go vet failed"
17
40
  fi
18
41
  fi
19
42
 
20
- grep '^\s*"test":' package.json > /dev/null 2>&1
21
- if [ $? -eq 0 ]; then
22
- npm t
23
- if [ $? -ne 0 ]; then
24
- echo "Release aborted: Tests failed."
25
- exit 1
43
+ if grep '^\s*"lint":' package.json > /dev/null 2>&1; then
44
+ if ! npm run lint; then
45
+ abort "npm run lint failed"
26
46
  fi
27
47
  fi
28
48
 
29
- grep '^\s*"minify":' package.json > /dev/null 2>&1
30
- if [ $? -eq 0 ]; then
31
- npm run minify
32
- if [ $? -ne 0 ]; then
33
- echo "Release aborted: Minification failed."
34
- exit 1
49
+ if [ "$TEST" = "true" ]; then
50
+ if [ "$IS_GO" ]; then
51
+ if ! go test ./...; then
52
+ abort "go test failed"
53
+ fi
35
54
  fi
55
+
56
+ if grep '^\s*"minify":' package.json > /dev/null 2>&1; then
57
+ if ! npm t; then
58
+ abort "npm test failed"
59
+ fi
60
+ fi
61
+
62
+ if [ "$IS_RUST" ]; then
63
+ if ! cargo t; then
64
+ abort "cargo test failed"
65
+ fi
66
+ fi
67
+
36
68
  fi
37
69
 
38
- if [ -f Cargo.toml ]; then
39
- cargo t
70
+ if grep '^\s*"minify":' package.json > /dev/null 2>&1; then
71
+ if ! npm run minify; then
72
+ abort "npm run minify failed"
73
+ fi
40
74
  fi
41
75
 
42
76
  while read -r COMMIT; do
43
- HASH=`echo "$COMMIT" | cut -d ' ' -f 1`
44
- MESSAGE=`echo "$COMMIT" | cut -d ':' -f 2- | awk '{$1=$1};1'`
45
- TYPE=`echo "$COMMIT" | cut -d ' ' -f 2 | awk '{$1=$1};1' | cut -d ':' -f 1 | cut -d '(' -f 1 | awk '{$1=$1};1'`
46
- AREA=`echo "$COMMIT" | cut -d '(' -f 2 | cut -d ')' -f 1 | awk '{$1=$1};1'`
77
+ HASH=$(echo "$COMMIT" | cut -d ' ' -f 1)
78
+ MESSAGE=$(echo "$COMMIT" | cut -d ':' -f 2- | awk '{$1=$1};1')
79
+ TYPE=$(echo "$COMMIT" | cut -d ' ' -f 2 | awk '{$1=$1};1' | cut -d ':' -f 1 | cut -d '(' -f 1 | awk '{$1=$1};1')
80
+ AREA=$(echo "$COMMIT" | cut -d '(' -f 2 | cut -d ')' -f 1 | awk '{$1=$1};1')
47
81
 
48
82
  if [ "$AREA" = "$COMMIT" ]; then
49
83
  AREA=""
@@ -95,9 +129,11 @@ while read -r COMMIT; do
95
129
  OTHER_SUMMARY="$OTHER_SUMMARY\n* $AREA$MESSAGE ($HASH)"
96
130
  ;;
97
131
  esac
98
- done <<< "$COMMITS"
132
+ done << EOF
133
+ $COMMITS
134
+ EOF
99
135
 
100
- if [ "$BUILD_TYPE" != "Major" -a "$BUILD_TYPE" != "Minor" ]; then
136
+ if [ "$BUILD_TYPE" != "Major" ] && [ "$BUILD_TYPE" != "Minor" ]; then
101
137
  BUILD_TYPE="Patch"
102
138
  fi
103
139
 
@@ -127,64 +163,67 @@ fi
127
163
 
128
164
  SUMMARY="$BREAK_SUMMARY$FEAT_SUMMARY$FIX_SUMMARY$PERF_SUMMARY$REFACTOR_SUMMARY$OTHER_SUMMARY"
129
165
 
130
- MAJOR=`echo "$LAST_TAG" | cut -d '.' -f 1`
131
- MINOR=`echo "$LAST_TAG" | cut -d '.' -f 2`
132
- PATCH=`echo "$LAST_TAG" | cut -d '.' -f 3`
166
+ MAJOR=$(echo "$LAST_TAG" | cut -d '.' -f 1)
167
+ MINOR=$(echo "$LAST_TAG" | cut -d '.' -f 2)
168
+ PATCH=$(echo "$LAST_TAG" | cut -d '.' -f 3)
133
169
 
134
170
  SED_FRIENDLY_LAST_TAG="$MAJOR\\.$MINOR\\.$PATCH"
135
171
 
136
172
  case $BUILD_TYPE in
137
173
  "Major")
138
- MAJOR=`expr $MAJOR + 1`
174
+ MAJOR=$((MAJOR + 1))
139
175
  MINOR=0
140
176
  PATCH=0
141
177
  ;;
142
178
  "Minor")
143
- MINOR=`expr $MINOR + 1`
179
+ MINOR=$((MINOR + 1))
144
180
  PATCH=0
145
181
  ;;
146
182
  "Patch")
147
- PATCH=`expr $PATCH + 1`
183
+ PATCH=$((PATCH + 1))
148
184
  ;;
149
185
  esac
150
186
 
151
187
  NEW_TAG="$MAJOR.$MINOR.$PATCH"
152
188
 
153
- if [ -f bower.json ]; then
154
- sed -i.release.bak -e "s/\"version\": \"$LAST_TAG\"/\"version\": \"$NEW_TAG\"/" bower.json
155
- rm bower.json.release.bak
189
+ if [ -f version.go ]; then
190
+ sed -i.release.bak -e "s/$SED_FRIENDLY_LAST_TAG/$NEW_TAG/g" version.go
191
+ rm version.go.release.bak
192
+ MODIFIED_FILES="$MODIFIED_FILES version.go"
156
193
  fi
157
194
 
158
- if [ -f component.json ]; then
159
- sed -i.release.bak -e "s/\"version\": \"$LAST_TAG\"/\"version\": \"$NEW_TAG\"/" component.json
160
- rm component.json.release.bak
161
- fi
162
-
163
- if [ -f package.json ]; then
195
+ if [ "$IS_NODE" = "true" ]; then
164
196
  sed -i.release.bak -e "s/\"version\": \"$LAST_TAG\"/\"version\": \"$NEW_TAG\"/" package.json
165
197
  rm package.json.release.bak
166
- fi
167
-
168
- if [ -f package-lock.json ]; then
169
- npm i
170
-
171
- if [ -f npm-shrinkwrap.json ]; then
172
- npm shrinkwrap
198
+ MODIFIED_FILES="$MODIFIED_FILES package.json"
199
+
200
+ if [ -f package-lock.json ]; then
201
+ npm i
202
+ MODIFIED_FILES="$MODIFIED_FILES package-lock.json"
203
+
204
+ if [ -f npm-shrinkwrap.json ]; then
205
+ npm shrinkwrap
206
+ MODIFIED_FILES="$MODIFIED_FILES npm-shrinkwrap.json"
207
+ fi
208
+ elif [ -f pnpm-lock.yaml ]; then
209
+ pnpm i
210
+ MODIFIED_FILES="$MODIFIED_FILES pnpm-lock.yaml"
211
+ elif [ -f yarn.lock ]; then
212
+ yarn
213
+ MODIFIED_FILES="$MODIFIED_FILES yarn.lock"
173
214
  fi
174
- elif [ -f pnpm-lock.yaml ]; then
175
- pnpm i
176
- elif [ -f yarn.lock ]; then
177
- yarn
178
215
  fi
179
216
 
180
- if [ -f setup.py ]; then
217
+ if [ "$IS_PYTHON" = "true" ]; then
181
218
  sed -i.release.bak -e "s/$SED_FRIENDLY_LAST_TAG/$NEW_TAG/g" setup.py
182
219
  rm setup.py.release.bak
220
+ MODIFIED_FILES="$MODIFIED_FILES setup.py"
183
221
  fi
184
222
 
185
- if [ -f Cargo.toml ]; then
223
+ if [ "$IS_RUST" = "true" ]; then
186
224
  sed -i.release.bak -e "s/$SED_FRIENDLY_LAST_TAG/$NEW_TAG/g" Cargo.toml
187
225
  rm Cargo.toml.release.bak
226
+ MODIFIED_FILES="$MODIFIED_FILES Cargo.toml"
188
227
  fi
189
228
 
190
229
  if [ -f CHANGELOG.md ]; then
@@ -211,15 +250,18 @@ if [ "$LOG" != "" ]; then
211
250
  TEMP="__please_release_me_$LOG.$NEW_TAG.tmp"
212
251
  awk "{ gsub(/^## $LAST_TAG$/, \"## $NEW_TAG\n\n$SUMMARY## $LAST_TAG\") }; { print }" "$LOG" > "$TEMP"
213
252
  mv "$TEMP" "$LOG"
253
+ MODIFIED_FILES="$MODIFIED_FILES $LOG"
214
254
  fi
215
255
 
216
- GIT_FRIENDLY_SUMMARY=`echo "$SUMMARY" | sed "s/#//g" | sed "s/^ //"`
256
+ GIT_FRIENDLY_SUMMARY=$(echo "$SUMMARY" | sed "s/#//g" | sed "s/^ //")
217
257
 
218
- git commit -a -m "release: $NEW_TAG"
258
+ # shellcheck disable=SC2086
259
+ git add $MODIFIED_FILES
260
+ git commit -m "release: $NEW_TAG"
219
261
 
220
262
  if [ -f Cargo.toml ]; then
221
263
  cargo package
222
264
  fi
223
265
 
224
- git tag -a "$NEW_TAG" -m "`echo \"$BUILD_TYPE release $NEW_TAG\\n\\n$GIT_FRIENDLY_SUMMARY\"`"
266
+ git tag -a "$NEW_TAG" -m "$BUILD_TYPE release $NEW_TAG\n\n$GIT_FRIENDLY_SUMMARY"
225
267