Skip to content

Publish Cluster UI Pre-release #1

Publish Cluster UI Pre-release

Publish Cluster UI Pre-release #1

name: Publish Cluster UI Pre-release
on:
workflow_dispatch:
push:
branches:
- master
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: 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 prerelease version
if: steps.version-check.outputs.published == 'no'
run: npm publish --access public --tag next --ignore-scripts