Skip to content

Commit 734da1a

Browse files
committed
node publish with github action
1 parent 830a46c commit 734da1a

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

src/SDK/Language/Node.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,8 @@ public function getFiles(): array
234234
],
235235
[
236236
'scope' => 'default',
237-
'destination' => '.travis.yml',
238-
'template' => 'node/.travis.yml.twig',
237+
'destination' => '.github/workflows/publish.yml',
238+
'template' => 'node/.github/workflows/publish.yml.twig',
239239
],
240240
[
241241
'scope' => 'enum',
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Publish to NPM
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
# Setup Node.js environment
16+
- name: Use Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: '20.x'
20+
registry-url: 'https://registry.npmjs.org'
21+
22+
# Determine release tag based on the tag name
23+
- name: Determine release tag
24+
id: release_tag
25+
run: |
26+
if [[ "${{ '{{' }} github.ref {{ '}}' }}" == *"-rc"* ]] || [[ "${{ '{{' }} github.ref {{ '}}' }}" == *"-RC"* ]]; then
27+
echo "tag=next" >> "$GITHUB_OUTPUT"
28+
else
29+
echo "tag=latest" >> "$GITHUB_OUTPUT"
30+
fi
31+
32+
# Install dependencies (if any) and build your project (if necessary)
33+
- name: Install dependencies and build
34+
run: |
35+
npm install
36+
npm run build
37+
38+
# Publish to NPM with the appropriate tag
39+
- name: Publish
40+
run: npm publish --tag ${{ '{{' }} steps.release_tag.outputs.tag {{ '}}' }}
41+
env:
42+
NODE_AUTH_TOKEN: ${{ '{{' }} secrets.NPM_TOKEN {{ '}}' }}

0 commit comments

Comments
 (0)