File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 27
27
run : |
28
28
version=$(jq -r .version package.json)
29
29
tag_meta=$(echo "$version" | cut -s -d '-' -f2)
30
+ # if no meta info on the version (e.g. a '-alpha.1' prefix), publish as a stable release
30
31
if [[ -z "$tag_meta" ]]; then
31
- npm publish --provenance --access public
32
+ # get latest version on npm
33
+ latest=$(npm view @elastic/elasticsearch --json | jq -r '.["dist-tags"].latest')
34
+
35
+ # if $version is higher than the most recently published version, publish as-is
36
+ if [[ $(yes | npx semver "$version" "$latest" | tail -n1) == "$version" ]]; then
37
+ npm publish --provenance --access public
38
+ else
39
+ # otherwise, publish with "previous" tag
40
+ npm publish --provenance --access public --tag "previous"
41
+ fi
32
42
else
43
+ # publish as a non-stable release using the meta name (e.g. 'alpha') as the tag
33
44
tag=$(echo "$tag_meta" | cut -d '.' -f1)
34
45
npm publish --provenance --access public --tag "$tag"
35
46
fi
You can’t perform that action at this time.
0 commit comments