-
Notifications
You must be signed in to change notification settings - Fork 37
75 lines (66 loc) · 2.17 KB
/
Copy pathcli-publish.yml
File metadata and controls
75 lines (66 loc) · 2.17 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
74
75
name: Publish CLI
on:
# Trigger after native build completes successfully
workflow_run:
workflows: ["Build Native Modules"]
types:
- completed
# Allow manual trigger
workflow_dispatch:
inputs:
version:
description: 'Version to publish (e.g., 0.1.0)'
required: false
type: string
jobs:
publish:
name: Publish CLI to npm
runs-on: ubuntu-latest
# Only run if native build succeeded (when triggered by workflow_run)
if: |
github.event_name == 'workflow_dispatch' ||
github.event.workflow_run.conclusion == 'success'
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_branch || github.ref }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build UI
run: npm run ui:build
- name: Get version
id: version
run: |
if [ "${{ github.event.inputs.version }}" != "" ]; then
VERSION="${{ github.event.inputs.version }}"
elif [ "${{ github.event.workflow_run.head_branch }}" != "" ]; then
# Get version from the tag that triggered native build
BRANCH="${{ github.event.workflow_run.head_branch }}"
if [[ "$BRANCH" == v* ]]; then
VERSION="${BRANCH#v}"
else
VERSION="0.0.0-dev"
fi
elif [[ "${{ github.ref }}" == refs/tags/v* ]]; then
VERSION="${{ github.ref_name }}"
VERSION="${VERSION#v}"
else
VERSION="0.0.0-dev"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
shell: bash
- name: Update version
run: |
npm version ${{ steps.version.outputs.version }} --no-git-tag-version --allow-same-version
shell: bash
- name: Publish to npm
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}