-
Notifications
You must be signed in to change notification settings - Fork 1
95 lines (84 loc) · 3.14 KB
/
cluster-ui-release.yml
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
name: Publish Cluster UI Release
on:
workflow_dispatch:
push:
branches:
- 'release-*'
paths:
- 'pkg/ui/workspaces/cluster-ui/**/*.tsx?'
- 'pkg/ui/workspaces/cluster-ui/package.json'
jobs:
publish_cluster_ui:
if: github.repository == 'cockroachdb/cockroach'
runs-on: ubuntu-latest
defaults:
run:
working-directory: pkg/ui/workspaces/cluster-ui
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Bazel Cache
uses: actions/cache@v3
with:
path: ~/.cache/bazel
key: ${{ runner.os }}-bazel-cache
- uses: pnpm/action-setup@v2
with:
version: "8.6.10"
- name: Setup NodeJS
uses: actions/setup-node@v3
with:
node-version: 16
registry-url: 'https://registry.npmjs.org'
always-auth: true
cache: 'pnpm'
cache-dependency-path: "${{ github.workspace }}/pkg/ui/pnpm-lock.yaml"
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# Always install node dependencies. It seems silly to do if we're not
# going to actually use them, but setup-node's post-run action attempts
# to save dependencies to a cache shared between GitHub actions. If the
# pnpm store directory doesn't exist (e.g. during a cache miss), that
# cache-saving step will fail and the entire job will be marked "failed"
# as a result. Installing dependencies is the canonical way to seed the
# pnpm store from-scratch.
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Check if version is published
id: version-check
shell: bash
run: |
PACKAGE_VERSION=$(cat ./package.json | jq -r ".version");
VERSIONS=$(npm view @cockroachlabs/cluster-ui versions)
if [[ $VERSIONS == *"$PACKAGE_VERSION"* ]]; then
echo "published=yes" >> $GITHUB_OUTPUT
echo
echo "🛑 Cluster UI package version $PACKAGE_VERSION is already published"
echo "to npm. Publishing step should be skipped. 🛑"
else
echo "published=no" >> $GITHUB_OUTPUT
echo
echo "✅ Cluster UI package version $PACKAGE_VERSION should be published. ✅"
fi
- name: Get Branch name
shell: bash
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
id: branch-name
- name: Build Cluster UI
if: steps.version-check.outputs.published == 'no'
run: |
bazel build //pkg/ui/workspaces/db-console/src/js:crdb-protobuf-client
cp ../../../../_bazel/bin/pkg/ui/workspaces/db-console/src/js/protos.* ../db-console/src/js/
pnpm build
- name: Create version tag and push
if: steps.version-check.outputs.published == 'no'
run: |
TAGNAME="@cockroachlabs/cluster-ui@$(jq -r '.version' ./package.json)"
if ! [ $(git tag -l "$TAGNAME") ]; then
git tag $TAGNAME
git push origin $TAGNAME
fi
- name: Publish patch version
if: steps.version-check.outputs.published == 'no'
run: npm publish --access public --tag ${{ steps.branch-name.outputs.branch }} --ignore-scripts