Skip to content

Commit 2ece006

Browse files
committed
detect npm tag from version
1 parent 7994ba6 commit 2ece006

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

.github/workflows/npm-publish.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ on:
44
branches:
55
- main
66

7-
env:
8-
NPM_TAG: latest
9-
107
concurrency:
118
group: npm-publish
129
cancel-in-progress: false
@@ -39,6 +36,14 @@ jobs:
3936
echo "TerriaJS $LOCAL_VERSION is not published yet, proceeding with publish"
4037
echo "version=$LOCAL_VERSION" >> "$GITHUB_OUTPUT"
4138
echo "should_publish=true" >> "$GITHUB_OUTPUT"
39+
40+
if [[ "$LOCAL_VERSION" == *"-"* ]]; then
41+
NPM_TAG=$(echo "$LOCAL_VERSION" | sed 's/[^-]*-\([^.]*\).*/\1/')
42+
else
43+
NPM_TAG="latest"
44+
fi
45+
echo "NPM tag to use: $NPM_TAG"
46+
echo "npm_tag=$NPM_TAG" >> "$GITHUB_OUTPUT"
4247
fi
4348
4449
- name: Set up Node.js for NPM
@@ -78,7 +83,7 @@ jobs:
7883

7984
- name: Publish package to NPM
8085
if: steps.detect.outputs.should_publish == 'true'
81-
run: npm publish --tag ${NPM_TAG}
86+
run: npm publish --tag ${{ steps.detect.outputs.npm_tag }}
8287
env:
8388
NODE_OPTIONS: "--max_old_space_size=8192"
8489
NODE_AUTH_TOKEN: ""

0 commit comments

Comments
 (0)