|
1
|
name: Release SDK npm |
|
2
|
|
|
3
|
on: |
|
4
|
push: |
|
5
|
tags: |
|
6
|
- "[0-9]+.[0-9]+.[0-9]+" |
|
7
|
workflow_dispatch: |
|
8
|
|
|
9
|
permissions: |
|
10
|
contents: read |
|
11
|
|
|
12
|
jobs: |
|
13
|
# Cheap ubuntu gate: version agreement, crates.io publishability, tag match. |
|
14
|
# Blocks the expensive job below so a metadata fault never costs runner time. |
|
15
|
preflight: |
|
16
|
uses: ./.github/workflows/release-preflight.yml |
|
17
|
with: |
|
18
|
tag: ${{ github.ref_type == 'tag' && github.ref_name || '' }} |
|
19
|
|
|
20
|
# ── Validate (every run) ────────────────────────────────────────────────── |
|
21
|
validate: |
|
22
|
needs: preflight |
|
23
|
name: Validate |
|
24
|
runs-on: ubuntu-latest |
|
25
|
|
|
26
|
outputs: |
|
27
|
version: ${{ steps.meta.outputs.version }} |
|
28
|
|
|
29
|
env: |
|
30
|
GRESIQ_API_KEY_DEV: ${{ secrets.GRESIQ_API_KEY_DEV }} |
|
31
|
GRESIQ_API_SECRET_DEV: ${{ secrets.GRESIQ_API_SECRET_DEV }} |
|
32
|
GRESIQ_API_KEY_PRODUCTION: ${{ secrets.GRESIQ_API_KEY_PRODUCTION }} |
|
33
|
GRESIQ_API_SECRET_PRODUCTION: ${{ secrets.GRESIQ_API_SECRET_PRODUCTION }} |
|
34
|
HF_TOKEN: ${{ secrets.HF_TOKEN }} |
|
35
|
steps: |
|
36
|
- name: Checkout |
|
37
|
uses: actions/checkout@v6 |
|
38
|
|
|
39
|
- name: Install node |
|
40
|
uses: actions/setup-node@v4 |
|
41
|
with: |
|
42
|
node-version: 22 |
|
43
|
registry-url: "https://registry.npmjs.org" |
|
44
|
|
|
45
|
# ── Read version ─────────────────────────────────────────────────────── |
|
46
|
|
|
47
|
- name: Read version from package.json |
|
48
|
id: meta |
|
49
|
working-directory: sdk/react-native |
|
50
|
run: | |
|
51
|
VERSION=$(node -p "require('./package.json').version") |
|
52
|
echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
|
53
|
echo "npm SDK version: $VERSION" |
|
54
|
|
|
55
|
# ── Validate tag = package.json version (tag push only) ──────────────── |
|
56
|
|
|
57
|
- name: Validate tag matches package.json version |
|
58
|
if: startsWith(github.ref, 'refs/tags/') |
|
59
|
env: |
|
60
|
PKG_VERSION: ${{ steps.meta.outputs.version }} |
|
61
|
TAG: ${{ github.ref_name }} |
|
62
|
run: | |
|
63
|
if [ "$TAG" != "$PKG_VERSION" ]; then |
|
64
|
echo "::error::Tag '$TAG' does not match package.json version '$PKG_VERSION'. Update package.json or re-tag." |
|
65
|
exit 1 |
|
66
|
fi |
|
67
|
echo "Version check passed: $PKG_VERSION" |
|
68
|
|
|
69
|
# ── Build & dry-run ──────────────────────────────────────────────────── |
|
70
|
|
|
71
|
- name: Install dependencies |
|
72
|
working-directory: sdk/react-native |
|
73
|
run: npm install |
|
74
|
|
|
75
|
- name: Build TypeScript |
|
76
|
working-directory: sdk/react-native |
|
77
|
run: npm run build |
|
78
|
|
|
79
|
- name: Dry-run package |
|
80
|
working-directory: sdk/react-native |
|
81
|
run: npm pack --dry-run |
|
82
|
|
|
83
|
# ── Publish to npm (tag push only) ──────────────────────────────────────── |
|
84
|
# |
|
85
|
# Publishing uses npm trusted publishing (OIDC), not a long-lived token. |
|
86
|
# The npm side is configured at |
|
87
|
# npmjs.com/package/@ondeinference/react-native/access |
|
88
|
# with the trusted publisher: repo ondeinference/onde, workflow |
|
89
|
# release-sdk-npm.yml, no environment. Those must keep matching what this |
|
90
|
# job declares below, or npm answers the publish with a 404 on PUT. In |
|
91
|
# particular, do not add an `environment:` here without also setting the |
|
92
|
# Environment name field on that npm page. |
|
93
|
publish: |
|
94
|
name: Publish to npm |
|
95
|
needs: validate |
|
96
|
runs-on: ubuntu-latest |
|
97
|
if: startsWith(github.ref, 'refs/tags/') |
|
98
|
|
|
99
|
permissions: |
|
100
|
contents: read |
|
101
|
id-token: write |
|
102
|
|
|
103
|
env: |
|
104
|
GRESIQ_API_KEY_DEV: ${{ secrets.GRESIQ_API_KEY_DEV }} |
|
105
|
GRESIQ_API_SECRET_DEV: ${{ secrets.GRESIQ_API_SECRET_DEV }} |
|
106
|
GRESIQ_API_KEY_PRODUCTION: ${{ secrets.GRESIQ_API_KEY_PRODUCTION }} |
|
107
|
GRESIQ_API_SECRET_PRODUCTION: ${{ secrets.GRESIQ_API_SECRET_PRODUCTION }} |
|
108
|
HF_TOKEN: ${{ secrets.HF_TOKEN }} |
|
109
|
steps: |
|
110
|
- name: Checkout |
|
111
|
uses: actions/checkout@v6 |
|
112
|
|
|
113
|
- name: Install node |
|
114
|
uses: actions/setup-node@v4 |
|
115
|
with: |
|
116
|
node-version: 22 |
|
117
|
registry-url: "https://registry.npmjs.org" |
|
118
|
|
|
119
|
# Node 22 ships npm 10, which predates OIDC publishing. Trusted |
|
120
|
# publishing needs npm 11.5.1 or newer. |
|
121
|
- name: Upgrade npm for trusted publishing |
|
122
|
run: | |
|
123
|
npm install -g npm@latest |
|
124
|
npm --version |
|
125
|
|
|
126
|
- name: Install dependencies |
|
127
|
working-directory: sdk/react-native |
|
128
|
run: npm install |
|
129
|
|
|
130
|
- name: Build TypeScript |
|
131
|
working-directory: sdk/react-native |
|
132
|
run: npm run build |
|
133
|
|
|
134
|
- name: Publish @ondeinference/react-native to npm |
|
135
|
working-directory: sdk/react-native |
|
136
|
run: | |
|
137
|
npm_package_name=$(node -p "require('./package.json').name") |
|
138
|
npm_package_version=$(node -p "require('./package.json').version") |
|
139
|
|
|
140
|
if npm view "${npm_package_name}@${npm_package_version}" version >/dev/null 2>&1; then |
|
141
|
echo "${npm_package_name}@${npm_package_version} already exists on npm, skipping publish" |
|
142
|
exit 0 |
|
143
|
fi |
|
144
|
|
|
145
|
npm publish --access public |