-
Notifications
You must be signed in to change notification settings - Fork 5
52 lines (41 loc) · 1.28 KB
/
_publish-code.yml
File metadata and controls
52 lines (41 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
name: Publish Code
on:
workflow_call:
workflow_dispatch:
jobs:
publish:
name: Publish release to NPM
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout@v4
- name: Install Dependencies
run: sudo apt-get install pcregrep
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: 24
cache: "npm"
- name: Install Node.js dependencies
run: npm ci
- name: Build
run: npm run build-for-dist
- name: Publish
run: |
# sort pre-releases after main version
git config versionsort.suffix "-"
cd ./dist
#
# Alpha, Beta, RC versions are published in their own tag.
# Normal versions are published to the 'latest' tag.
#
git_tag=$(git tag --sort=-v:refname | head -n 1)
tag=$(echo "${git_tag}" | pcregrep -e '-(alpha|beta|rc)[0-9]?$' -o1 || true)
if [ -n "${tag}" ]; then
npm_tag="${tag}"
else
npm_tag='latest'
fi
echo "Publishing to npm tag: ${npm_tag}"
npm set "//registry.npmjs.org/:_authToken" ${{ secrets.NPM_PUBLISH_TOKEN }}
npm publish --tag="${npm_tag}"