-
-
Notifications
You must be signed in to change notification settings - Fork 221
73 lines (64 loc) · 2.07 KB
/
publish.yml
File metadata and controls
73 lines (64 loc) · 2.07 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
66
67
68
69
70
71
72
73
name: Publish NPM Packages
on:
push:
tags:
- 'v*' # Triggers on version tags like v3.0.1, v3.0.1-pre.0, etc.
workflow_dispatch:
inputs:
dist_tag:
description: 'npm dist-tag to publish under (latest, pre, next, canary, beta, alpha)'
required: false
default: 'latest'
type: choice
options:
- latest
- pre
- next
- canary
- beta
- alpha
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm ci
- name: Build packages
run: npm run build
- name: Determine dist-tag
id: dist-tag
run: |
# If triggered manually, use the input value
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "tag=${{ inputs.dist_tag }}" >> $GITHUB_OUTPUT
echo "Using manual dist-tag: ${{ inputs.dist_tag }}"
exit 0
fi
TAG_NAME=${GITHUB_REF#refs/tags/}
echo "Publishing tag: $TAG_NAME"
if [[ "$TAG_NAME" == *"-pre"* ]]; then
echo "tag=pre" >> $GITHUB_OUTPUT
elif [[ "$TAG_NAME" == *"-next"* ]]; then
echo "tag=next" >> $GITHUB_OUTPUT
elif [[ "$TAG_NAME" == *"-canary"* ]]; then
echo "tag=canary" >> $GITHUB_OUTPUT
elif [[ "$TAG_NAME" == *"-beta"* ]]; then
echo "tag=beta" >> $GITHUB_OUTPUT
elif [[ "$TAG_NAME" == *"-alpha"* ]]; then
echo "tag=alpha" >> $GITHUB_OUTPUT
else
echo "tag=latest" >> $GITHUB_OUTPUT
fi
- name: Publish to npm
run: npx lerna publish from-package --yes --no-verify-access --dist-tag ${{ steps.dist-tag.outputs.tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}