-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (55 loc) · 1.61 KB
/
publish.yml
File metadata and controls
65 lines (55 loc) · 1.61 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
53
54
55
56
57
58
59
60
61
62
63
64
65
name: Publish to NPM
on:
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: 'NPM dist-tag to publish to (latest, beta, alpha)'
required: true
default: 'beta'
type: choice
options:
- beta
- latest
- alpha
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm run test || echo "No tests configured yet"
- name: Build package
run: npm run build
- name: Verify package contents
run: |
npm pack --dry-run
ls -la dist/
- name: Determine NPM tag
id: npm-tag
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "tag=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
elif [[ "${{ github.ref_name }}" == *"beta"* ]]; then
echo "tag=beta" >> $GITHUB_OUTPUT
elif [[ "${{ github.ref_name }}" == *"alpha"* ]]; then
echo "tag=alpha" >> $GITHUB_OUTPUT
else
echo "tag=latest" >> $GITHUB_OUTPUT
fi
- name: Publish to NPM
run: npm publish --access public --tag ${{ steps.npm-tag.outputs.tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}