1+ name : Publish NPM
2+
3+ on :
4+ workflow_dispatch :
5+ inputs :
6+ tag :
7+ description : NPM dist tag (alpha, beta, latest)
8+ required : true
9+ default : ' alpha'
10+ type : choice
11+ options :
12+ - alpha
13+ - beta
14+ - latest
15+
16+ release :
17+ types : [published]
18+
19+ jobs :
20+ publish :
21+ name : publish
22+ runs-on : ubuntu-latest
23+ permissions :
24+ contents : read
25+ id-token : write
26+
27+ steps :
28+ - name : Checkout code
29+ uses : actions/checkout@v6
30+ with :
31+ fetch-depth : 0
32+
33+ - name : Enable Corepack
34+ run : corepack enable
35+
36+ - name : Set up Node.js
37+ uses : actions/setup-node@v4
38+ with :
39+ node-version : ' 20'
40+ registry-url : ' https://registry.npmjs.org'
41+ cache : ' yarn'
42+
43+ - name : Install dependencies
44+ run : |
45+ yarn install --immutable
46+
47+ - name : Build packages
48+ run : |
49+ yarn build
50+
51+ - name : Determine NPM tag
52+ id : npm-tag
53+ run : |
54+ if [ -n "${{ github.event.inputs.tag }}" ]; then
55+ NPM_TAG="${{ github.event.inputs.tag }}"
56+ elif [ "${{ github.event_name }}" == "release" ]; then
57+ # For releases, use 'latest' tag unless version contains alpha/beta
58+ RELEASE_TAG="${{ github.event.release.tag_name }}"
59+ if [[ "$RELEASE_TAG" == *"alpha"* ]] || [[ "$RELEASE_TAG" == *"-alpha"* ]]; then
60+ NPM_TAG="alpha"
61+ elif [[ "$RELEASE_TAG" == *"beta"* ]] || [[ "$RELEASE_TAG" == *"-beta"* ]]; then
62+ NPM_TAG="beta"
63+ else
64+ NPM_TAG="latest"
65+ fi
66+ else
67+ NPM_TAG="alpha"
68+ fi
69+
70+ echo "tag=$NPM_TAG" >> $GITHUB_OUTPUT
71+
72+ - name : Publish to NPM
73+ run : |
74+ cd packages/video-player
75+
76+ # Publish with the specified tag
77+ npm publish --tag ${{ steps.npm-tag.outputs.tag }} --access public
78+ env :
79+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
80+
81+ - name : Output published version
82+ run : |
83+ cd packages/video-player
84+ PUBLISHED_VERSION=$(node -p "require('./package.json').version")
85+ echo "✅ Published @imagekit/video-player@${PUBLISHED_VERSION} with tag: ${{ steps.npm-tag.outputs.tag }}"
0 commit comments