@audius/sdk 0.0.24 → 0.0.27

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.
package/package.json CHANGED
@@ -1,6 +1,9 @@
1
1
  {
2
2
  "name": "@audius/sdk",
3
- "version": "0.0.24",
3
+ "version": "0.0.27",
4
+ "audius": {
5
+ "releaseSHA": "40f9da613540c1874c0e8c73be49b9941c0e2b84"
6
+ },
4
7
  "description": "",
5
8
  "main": "dist/index.cjs.js",
6
9
  "module": "dist/index.esm.js",
@@ -16,12 +16,9 @@ fi
16
16
 
17
17
  set -ex
18
18
 
19
- # Finds the lastest commit that looks like a version commit,
20
- # and gets the list of commits after that
19
+ # Generate change log between last released sha and HEAD
21
20
  function git-changelog () {
22
- # Find the latest release commit by using the last time the first `version` key changed
23
- version_line_number=$(grep -m 1 -n version package.json | cut -d: -f 1)
24
- release_commit=$(git blame -L ${version_line_number},+1 --porcelain -- package.json | awk 'NR==1{ print $1 }')
21
+ release_commit=${1}
25
22
 
26
23
  # Print the log as "- <commmiter short date> [<commit short hash>] <commit message> <author name>"
27
24
  git log --pretty=format:"- %cd [%h] %s [%an]" --date=short $release_commit..HEAD
@@ -60,10 +57,14 @@ function bump-npm () {
60
57
  git reset --hard ${GIT_TAG}
61
58
 
62
59
  # grab change log early, before the version bump
63
- CHANGE_LOG=$(git-changelog)
60
+ LAST_RELEASED_SHA=$(jq -r '.audius.releaseSHA' package.json)
61
+ CHANGE_LOG=$(git-changelog ${LAST_RELEASED_SHA})
64
62
 
65
63
  # Patch the version
66
64
  VERSION=$(npm version patch)
65
+ tmp=$(mktemp)
66
+ jq ". += {audius: {releaseSHA: \"${GIT_TAG}\"}}" package.json > "$tmp" \
67
+ && mv "$tmp" package.json
67
68
 
68
69
  # Build project
69
70
  npm i
@@ -72,30 +73,40 @@ function bump-npm () {
72
73
  # Publishing dry run, prior to pushing a branch
73
74
  npm publish . --access public --dry-run
74
75
 
75
- # Commit to a new branch, and tag
76
+ # Commit to a new branch
76
77
  git checkout -b ${STUB}-${VERSION}
77
78
  git add .
78
79
  git commit -m "$(commit-message)"
79
- git tag -a @audius/${STUB}@${VERSION} -m "$(commit-message)"
80
80
 
81
- # Push branch and tags to remote
81
+ # Push branch to remote
82
82
  git push -u origin ${STUB}-${VERSION}
83
- git push origin --tags
84
83
  }
85
84
 
86
85
  # Merge the created branch into master, then delete the branch
87
86
  function merge-bump () {
88
- git checkout master -f
87
+ (
88
+ # exit the function/subshell early on error
89
+ # https://stackoverflow.com/a/58964551
90
+ # http://mywiki.wooledge.org/BashFAQ/105
91
+ set -e
89
92
 
90
- # pull in any additional commits that may have trickled in
91
- git pull
93
+ git checkout master -f
94
+
95
+ # pull in any additional commits that may have trickled in
96
+ git pull
92
97
 
93
- git merge ${STUB}-${VERSION} -m "$(commit-message)"
98
+ # squash branch commit
99
+ git merge --squash ${STUB}-${VERSION} || exit 1
100
+ git commit -m "$(commit-message)" || exit 1
94
101
 
95
- # if pushing fails, ensure we cleanup()
96
- git push -u origin master \
97
- && git push origin :${STUB}-${VERSION} \
98
- || $(exit 1)
102
+ # tag release
103
+ git tag -a @audius/${STUB}@${VERSION} -m "$(commit-message)" || exit 1
104
+ git push origin --tags || exit 1
105
+
106
+ # if pushing fails, ensure we cleanup()
107
+ git push -u origin master || exit 1
108
+ git push origin :${STUB}-${VERSION}
109
+ )
99
110
  }
100
111
 
101
112
  # publish to npm
@@ -103,6 +114,14 @@ function publish () {
103
114
  npm publish . --access public
104
115
  }
105
116
 
117
+ # informative links
118
+ function info () {
119
+ echo "Released to:
120
+ * https://github.com/AudiusProject/audius-protocol/commits/master
121
+ * https://github.com/AudiusProject/audius-protocol/tags
122
+ * https://www.npmjs.com/package/@audius/sdk?activeTab=versions"
123
+ }
124
+
106
125
  # cleanup when merging step fails
107
126
  function cleanup () {
108
127
  git push origin :${STUB}-${VERSION} || true
@@ -116,4 +135,4 @@ cd ${PROTOCOL_DIR}/libs
116
135
 
117
136
  # perform release
118
137
  bump-npm
119
- merge-bump && publish || cleanup
138
+ merge-bump && publish && info || cleanup