-
Notifications
You must be signed in to change notification settings - Fork 56
149 lines (137 loc) · 5.29 KB
/
Copy pathrelease-with-tag.yml
File metadata and controls
149 lines (137 loc) · 5.29 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
name: Release Package
on:
push:
tags:
- "*"
jobs:
Test:
runs-on: ubuntu-latest # Firefox in it
strategy:
matrix:
node-version: [22.14.0]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
registry-url: "https://registry.npmjs.org"
- run: node --version
- name: Enable Yarn (Corepack)
run: |
corepack enable
corepack prepare yarn@1.22.22 --activate
yarn --version
- name: Upgrade npm for trusted publishing compatibility
run: |
npm i -g npm@^11.5.1
npm --version
- run: yarn install
- run: DEBUG=eslint:cli-engine npm run lint:all
- run: npm run build
- run: npm run test:browser
- run: npm run test:coverage
Release:
needs: Test
runs-on: ubuntu-latest # Firefox in it
strategy:
matrix:
node-version: [22.14.0]
permissions:
contents: write # for release
id-token: write # for npm trusted publishing (OIDC)
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
registry-url: "https://registry.npmjs.org"
- run: node --version
- name: Enable Yarn (Corepack)
run: |
corepack enable
corepack prepare yarn@1.22.22 --activate
yarn --version
- name: Upgrade npm for trusted publishing compatibility
run: |
npm i -g npm@^11.5.1
npm --version
- run: yarn install
- run: npm run build
- run: echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Publish packages to npm (OIDC)
if: ${{ env.TAG != '' && !contains(env.TAG, '/') && github.repository == 'ringcentral/ringcentral-js' }}
env:
# Prevent any repo/org secret from forcing token-based publishing.
NODE_AUTH_TOKEN: ""
NPM_CONFIG_PROVENANCE: "true"
run: |
set -euo pipefail
VERSION="${TAG#v}"
export VERSION
echo "Publishing version: ${VERSION}"
unset NODE_AUTH_TOKEN
node - <<'NODE'
const fs = require('fs');
const path = require('path');
const { spawnSync } = require('child_process');
const version = process.env.VERSION;
if (!version || version.trim() === '') {
console.error('Missing VERSION');
process.exit(1);
}
const publishTag = version.includes('-') ? 'next' : 'latest';
console.log(`npm dist-tag: ${publishTag}`);
const rootPkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
const workspaces = rootPkg.workspaces || [];
function run(cmd, args, cwd) {
const res = spawnSync(cmd, args, { cwd, stdio: 'inherit' });
if (res.status) process.exit(res.status);
}
const publishTargets = [];
for (const ws of workspaces) {
const pkgJsonPath = path.join(ws, 'package.json');
if (!fs.existsSync(pkgJsonPath)) continue;
const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'));
if (pkg.private) continue;
if (!pkg.name) continue;
publishTargets.push({ dir: ws, name: pkg.name });
}
if (publishTargets.length === 0) {
console.log('No public workspaces found to publish.');
process.exit(0);
}
console.log('Publish targets:');
for (const t of publishTargets) console.log(`- ${t.name} (${t.dir})`);
// Ensure versions are set consistently before publishing.
for (const t of publishTargets) {
run('npm', ['version', version, '--no-git-tag-version'], t.dir);
}
// Publish each package using npm OIDC trusted publishing.
for (const t of publishTargets) {
run('npm', ['publish', '--provenance', '--access', 'public', '--tag', publishTag], t.dir);
}
NODE
- name: Release
if: ${{ env.TAG != '' && !contains(env.TAG, '/') && github.repository == 'ringcentral/ringcentral-js' }}
uses: softprops/action-gh-release@v1
with:
files: |
sdk/dist/ringcentral.js
sdk/dist/ringcentral.js.map
sdk/dist/ringcentral.min.js
sdk/dist/ringcentral.min.js.map
subscriptions/dist/ringcentral-subscriptions.js
subscriptions/dist/ringcentral-subscriptions.js.map
subscriptions/dist/ringcentral-subscriptions.min.js
subscriptions/dist/ringcentral-subscriptions.min.js.map
subscriptions-deprecated/dist/ringcentral-subscriptions-deprecated.js
subscriptions-deprecated/dist/ringcentral-subscriptions-deprecated.js.map
subscriptions-deprecated/dist/ringcentral-subscriptions-deprecated.min.js
subscriptions-deprecated/dist/ringcentral-subscriptions-deprecated.min.js.map
env:
GITHUB_REPOSITORY: ringcentral/ringcentral-js
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}