-
Notifications
You must be signed in to change notification settings - Fork 17
65 lines (65 loc) · 2.28 KB
/
publish-packages.yml
File metadata and controls
65 lines (65 loc) · 2.28 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 JS Packages
on:
workflow_dispatch:
inputs:
preid:
description: 'Preid used to publish package. Must be unique per branch. Leave empty for stable release.'
required: false
default: ''
package:
description: 'Package name to publish (e.g., @deephaven/js-plugin-ui, @deephaven/js-plugin-pivot). Leave empty to publish all packages.'
required: false
default: ''
ref:
description: 'Commit to deploy from. Defaults to branch used for workflow_dispatch action.'
required: false
default: ''
release:
types: [created]
jobs:
publish-packages:
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build packages
run: npm run build
- name: Publish stable packages
if: ${{ !github.event.inputs.preid }}
run: |
PACKAGE="${{ github.event.inputs.package }}"
if [ -n "$PACKAGE" ]; then
npm publish --workspace="$PACKAGE"
else
./node_modules/.bin/lerna publish from-package --yes
fi
- name: Publish canary packages
if: ${{ github.event.inputs.preid }}
run: |
PACKAGE="${{ github.event.inputs.package }}"
PREID="${{ github.event.inputs.preid }}.$(git rev-parse --short HEAD)"
if [ -n "$PACKAGE" ]; then
BASE_VERSION=$(npm pkg get version --workspace="$PACKAGE" | jq -r --arg pkg "$PACKAGE" '.[$pkg]' | cut -d'-' -f1)
if [ "$BASE_VERSION" = "null" ]; then
echo "Error: Package $PACKAGE not found"
exit 1
fi
npm version "${BASE_VERSION}-${PREID}" --no-git-tag-version --workspace="$PACKAGE"
npm publish --tag canary --workspace="$PACKAGE"
else
./node_modules/.bin/lerna publish --canary --preid "$PREID" --dist-tag canary --yes
fi