Skip to content

Commit ac231c8

Browse files
authored
Improve npm publish version parsing (#2638)
1 parent a22c462 commit ac231c8

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

.github/workflows/npm-publish.yml

+27-8
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,38 @@ jobs:
2323
- run: npm install -g npm
2424
- run: npm install
2525
- run: npm test
26-
- run: npm publish --provenance --access public --tag alpha
26+
- name: npm publish
27+
run: |
28+
version=$(jq -r .version package.json)
29+
tag_meta=$(echo "$version" | cut -s -d '-' -f2)
30+
if [[ -z "$tag_meta" ]]; then
31+
npm publish --provenance --access public
32+
else
33+
tag=$(echo "$tag_meta" | cut -d '.' -f1)
34+
npm publish --provenance --access public --tag "$tag"
35+
fi
2736
env:
2837
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
2938
- name: Publish version on GitHub
3039
run: |
3140
version=$(jq -r .version package.json)
32-
gh release create \
33-
-n "This is a 9.0.0 pre-release alpha. Changes may not be stable." \
34-
--latest=false \
35-
--prerelease \
36-
--target "$BRANCH_NAME" \
37-
--title "v$version" \
38-
"v$version"
41+
tag_meta=$(echo "$version" | cut -s -d '-' -f2)
42+
if [[ -z "$tag_meta" ]]; then
43+
gh release create \
44+
-n "[Changelog](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/$BRANCH_NAME/changelog-client.html)"
45+
--target "$BRANCH_NAME" \
46+
--title "v$version" \
47+
"v$version"
48+
else
49+
tag_main=$(echo "$version" | cut -d '-' -f1)
50+
gh release create \
51+
-n "This is a $tag_main pre-release. Changes may not be stable." \
52+
--latest=false \
53+
--prerelease \
54+
--target "$BRANCH_NAME" \
55+
--title "v$version" \
56+
"v$version"
57+
fi
3958
env:
4059
BRANCH_NAME: ${{ github.event.inputs.branch }}
4160
GH_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)