Commit 0ade9f2 1 parent bd8a4f4 commit 0ade9f2 Copy full SHA for 0ade9f2
File tree 1 file changed +53
-0
lines changed
1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Release CI
2
+ on :
3
+ push :
4
+ tags :
5
+ # This looks like a regex, but it's actually a filter pattern
6
+ # see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
7
+ - ' v*.*.*'
8
+ - ' v*.*.*-*'
9
+
10
+ jobs :
11
+ release :
12
+ runs-on : ubuntu-latest
13
+
14
+ steps :
15
+ - name : " Checkout code"
16
+ uses : actions/checkout@v4
17
+
18
+ - name : Validate SemVer tag
19
+ run : |
20
+ TAG="${GITHUB_REF_NAME#refs/tags/}"
21
+ if [[ ! "$TAG" =~ ^v[0-9]+(\.[0-9]+){2}(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$ ]]; then
22
+ echo "::error::Invalid tag: $TAG. Must follow SemVer syntax (e.g., v1.2.3, v1.2.3-alpha)."
23
+ exit 1
24
+ fi
25
+ shell : bash
26
+
27
+ - name : Set up Node.js
28
+ uses : actions/setup-node@v4
29
+ with :
30
+ node-version : ' lts/*'
31
+ registry-url : ' https://registry.npmjs.org'
32
+
33
+ - name : Extract prerelease tag if present
34
+ id : extract-tag
35
+ run : |
36
+ TAG="${GITHUB_REF_NAME#v}" # Remove the "v" prefix
37
+ if [[ "$TAG" == *-* ]]; then
38
+ PRERELEASE=${TAG#*-} # Remove everything before the dash
39
+ PRERELEASE=${PRERELEASE%%.*} # Remove everything after the first period
40
+ else
41
+ PRERELEASE="latest"
42
+ fi
43
+ echo "DIST_TAG=$PRERELEASE" >> $GITHUB_ENV
44
+
45
+ - name : Install npm dependencies
46
+ run : npm install
47
+
48
+ - name : Publish to npmjs.org
49
+ env :
50
+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
51
+ run : |
52
+ echo "Publishing to npmjs.org using dist-tag: $DIST_TAG"
53
+ npm publish --workspaces --access=public --tag "$DIST_TAG"
You can’t perform that action at this time.
0 commit comments