Skip to content

Publish blocks to a private registry

guidesdk-publish-to-private-registry

This guide is for developers who publish private blocks to their organization’s private block registry. The registry is a bucket in Google Cloud Storage or Amazon S3. Your administrator sets it up by following the administrator guide for Google Cloud or AWS. Where the steps differ between the clouds, this page shows a tab for each.

When you publish a block:

  1. the build pushes the container images of the block’s software to your organization’s image registry: Artifact Registry or ECR
  2. block-tools publish uploads the block to the registry’s bucket
  3. users see it in the Desktop App, which reads the registry over HTTP(S), and the Platforma backend on Kubernetes runs it from those images.

Private blocks never go to Platforma’s public registries or to npmjs.com.

What you need

From your administrator (the handover section of the administrator guide):

Value Used as
Project ID, project number, region $PROJECT, $PROJECT_NUMBER, $REGION
Registry bucket $BUCKET
Registry URL, as users add it in the Desktop App $REGISTRY_URL
Image repository name $IMAGES_REPO
Publisher service account $PUBLISHER, usually registry-publisher@$PROJECT.iam.gserviceaccount.com
Branch or tags allowed to publish from CI usually main

Set these two addresses. The commands below use them:

Terminal window
IMAGE_ADDRESS=$REGION-docker.pkg.dev/$PROJECT/$IMAGES_REPO/pl-containers
REGISTRY_ADDRESS=gs://$BUCKET/

Your block repository is built from the Platforma block template: it has the parts model, workflow, ui, kind, software and block.

You also need:

  • @platforma-sdk/block-tools 2.18.0 or later for a Google Cloud registry. Older versions fail with Unknown protocol: gs:. Check the version in the catalog section of pnpm-workspace.yaml. To update it, run pnpm update-sdk, which updates all SDK packages, or raise only @platforma-sdk/block-tools there and run pnpm install.
  • Docker, and the gcloud CLI or the AWS CLI for publishing from a workstation.

Step 1: prepare the block repository

Disable the template’s CI workflows. The template has .github/workflows/build.yaml and mark-stable.yaml. They call Platforma’s reusable workflow, which needs Platforma’s runners and secrets and publishes to npmjs.com. block-tools structure refresh (which pnpm update-sdk and pnpm upgrade-sdk run) writes these files again, so disable them in GitHub instead of deleting them. GitHub keeps a disabled workflow disabled when its file changes:

Terminal window
gh workflow disable build.yaml
gh workflow disable mark-stable.yaml

Never publish to npmjs.com. Blocks never need npm to be installed or to run. The Desktop App installs a block from the block registry, and the backend pulls the images from your image registry.

  • Do not run npm publish, pnpm publish or changeset publish in a block repository. An upload to npmjs.com can make your block’s code public.
  • prepublishOnly in block/package.json points at Platforma’s registry, which you cannot write to. Do not change that script to point at your registry, because block-tools structure refresh restores it. Run block-tools publish directly, as shown below.
  • You need no npmjs.com token. The template’s .npmrc refers to ${NPMJS_TOKEN}, which only Platforma’s CI uses for uploads. Without it, pnpm prints a warning and continues. Delete the two //registry.npmjs.org/ lines to silence it.
  • Dependencies still come from npmjs.com: pnpm install downloads the Platforma SDK (@platforma-sdk/*, @milaboratories/*), shared software and run environments (@platforma-open/*), read-only and without an account. If your organization runs a private npm registry, see step 5.

Step 2: understand how a block is published

Publishing takes two steps: build, then publish.

Build, including the software images

The build compiles every part. For each software entrypoint it also builds a container image, pushes it, and writes the image address into the block’s software descriptors (*.sw.json). The backend’s Kubernetes Jobs pull that address when the block runs.

Build private blocks with these settings:

Setting Value Meaning
PL_BUILD_CHANNEL release A release build
PL_BUILD_VARIANT docker Build container images only
PL_BUILD_LOCATION remote Push the images
PL_RELEASE_DOCKER_PUSH_URL $IMAGE_ADDRESS Where the images are pushed
PL_RELEASE_DOCKER_PULL_URL the same address Where the cluster pulls them from. It is written into the descriptors.

Then run pnpm exec turbo run build in the repository root.

Do not use pnpm build:release for private blocks. That script is Platforma’s release build. It builds every artifact kind (PL_BUILD_VARIANT=all), so it also uploads binary archives to Platforma’s software storage. Without the two PL_RELEASE_DOCKER_* addresses, it also pushes images to Platforma’s public registry, containers.pl-open.science. You cannot write to either, so the build fails. Your private blocks’ images belong only in your organization’s image registry.

Use these variable names, not PL_DOCKER_REGISTRY. The block template’s turbo.json passes only the PL_RELEASE_* variables to the build, and block-tools structure refresh rewrites turbo.json.

A Docker-only build means the blocks run on Kubernetes, which is Platforma’s default setup. They do not run on a backend that runs jobs as local processes without containers.

Image tags are <package-name>.<content-hash>, so an unchanged software package keeps its tag across releases. Software from Platforma’s public packages that your block uses keeps its public image address on containers.pl-open.science.

Build the images on linux/amd64 machines (GitHub-hosted runners are) unless your cluster nodes use another architecture.

Publish the block to the registry

From the block folder, run:

Terminal window
npx block-tools publish --registry "$REGISTRY_ADDRESS" --registry-serve-url $REGISTRY_URL

--registry-serve-url is required. Set it to the address your users add in the Desktop App. publish writes it into block-pack/published.json.

publish uploads the block and its kind, then refreshes the registry overviews. The output ends with Refresh finished. Each version goes to the stable channel unless you pass --unstable. Users see the new version in the Desktop App within about 40 seconds.

publish does not check whether the version is already in the registry. It overwrites the version. Bump the block version for every release, and publish each version once.

Step 3: publish from a workstation

Use this for a first test or when CI is not ready. Your administrator must allow your account to act as the publisher.

Log in as the publisher, let Docker push to Artifact Registry, then build and publish. You need two logins. block-tools uses the application default credentials. Docker uses the gcloud CLI, and the environment variable switches it to the publisher in this shell only:

Terminal window
gcloud auth application-default login --impersonate-service-account $PUBLISHER
export CLOUDSDK_AUTH_IMPERSONATE_SERVICE_ACCOUNT=$PUBLISHER
gcloud auth configure-docker $REGION-docker.pkg.dev
export PL_BUILD_CHANNEL=release PL_BUILD_VARIANT=docker PL_BUILD_LOCATION=remote
export PL_RELEASE_DOCKER_PUSH_URL=$IMAGE_ADDRESS PL_RELEASE_DOCKER_PULL_URL=$IMAGE_ADDRESS
pnpm exec turbo run build
cd block && npx block-tools publish --registry "$REGISTRY_ADDRESS" --registry-serve-url $REGISTRY_URL

When you are done, run unset CLOUDSDK_AUTH_IMPERSONATE_SERVICE_ACCOUNT and gcloud auth application-default login without the flag to switch back to your own credentials.

Step 4: publish from CI

Platforma builds and releases its own blocks with open GitHub Actions workflows. Read them as a reference:

Use our pipeline as a reference, not as a template. It is built for Platforma’s public release process. It uses our runners, our secrets, our public npm packages and our public block registry. Do not call our reusable workflow from your repositories, and do not copy it as a whole. Take the parts you need, as described below, and use the example workflow at the end of this step as your starting point.

How Platforma’s pipeline works

  1. Every pull request carries a changeset that bumps the block package. CI builds and tests the pull request.
  2. After the merge, CI on main runs changeset version, which bumps versions and commits them.
  3. On that commit, CI runs pnpm build:release, which builds and pushes the software images. Before publishing, CI checks that every image the block’s descriptors reference exists in the registry.
  4. CI packs every package that is not yet on npm: block and software. The other parts are marked "private": true and are never published. Packing runs the block package’s prepublishOnly script, block-tools publish -r <registry address>, which uploads the block to Platforma’s registry. Then CI uploads the packages to the public npm registry, npmjs.com, and creates a release tag.
  5. A pull request labelled mark-unstable publishes without the stable channel. A separate workflow runs block-tools mark-stable to promote it later.

What to reuse and what to change

Part of our pipeline What it does for us What to do for a private registry
Reusable workflow node-simple-pnpm.yaml@v4 Runs build, test, versioning and release in one call Do not call it. It runs on our self-hosted runners (hz-ubuntu-dind) and expects our secrets. Write your own job (example below).
build.yaml and mark-stable.yaml from the block template Call our reusable workflow Disable them (Step 1).
Runner label hz-ubuntu-dind Our runners with Docker Change to ubuntu-latest or your own runners. They need Docker to build images.
Changesets and the bump checks (actions/changeset/require-package-bump, check-coverage) Force a version bump on every pull request Reuse if you want versioned releases. Run pnpm changeset status in your pull-request checks, or call the public actions pinned to a commit SHA instead of @v4.
changeset version committed to main by our GitHub App (GH_ZEN_APP_*) Bumps versions after the merge Change. Use your own GitHub App or token, or changesets/action, which opens a “Version Packages” pull request.
Image push to Platforma’s registry (QUAY_* secrets, pl-docker-registry-push-to) Publishes public images Change to your image registry: PL_RELEASE_DOCKER_PUSH_URL and PL_RELEASE_DOCKER_PULL_URL, plus a keyless cloud login.
Image check before publish Stops a release whose images are missing Reuse the idea. The Docker-only build fails when an image cannot be pushed.
prepublishOnly (block-tools publish -r s3://…) Uploads the block to our registry during npm packing Do not use. Call block-tools publish --registry … --registry-serve-url … as a separate step.
npm packing and upload (pack-unpublished, publish-tarballs, NPMJS_TOKEN) Publishes our public npm packages Drop. Publish shared packages only to your private npm registry, if you have one.
mark-unstable label, PL_PUBLISH_UNSTABLE Publishes without the stable channel Reuse if you need it. Set PL_PUBLISH_UNSTABLE=true or pass --unstable. Promote later with block-tools mark-stable --registry ….
Tests (PL_LICENSE, PL_CI_TEST_USER, PL_CI_TEST_PASSWORD) Run block tests against a Platforma backend Change to your own license and test backend, or run only the tests that need no backend.
Turbo remote cache (AWS_CI_TURBOREPO_*, HZ_CI_TURBO_*) Speeds up our builds Drop, or point Turbo at your own cache.
Slack notifications (SLACK_*) Report release status Drop, or use your own channel.
Release tag (create-tag) Tags each released version Optional.

Example workflow

This is a starting point, not a finished pipeline. Lines marked # CHANGE are the ones you must adapt. It publishes from main and skips a version that is already in the registry. So it fits a changesets flow, in which a “Version Packages” pull request bumps the versions.

The workflow logs in to your cloud with no stored key. Your administrator must allow this repository first, and only the allowed branch or tags can log in.

Save it as .github/workflows/publish.yaml in the block repository. Set the repository variables listed in the tab from the values your administrator gave you.

Repository variables: GCP_PROJECT, GCP_PROJECT_NUMBER, GCP_REGION, REGISTRY_BUCKET, REGISTRY_URL and IMAGES_REPO.

name: Build and publish block
on:
push:
branches: [main] # CHANGE: or tags/releases, to match your release flow
workflow_dispatch: {}
permissions:
contents: read
id-token: write # for Workload Identity Federation
jobs:
publish:
if: github.ref == 'refs/heads/main' # CHANGE: match your release branch or tags
runs-on: ubuntu-latest # CHANGE: your runners; they need Docker
env:
# A release build of container images only, pushed to and pulled from your Artifact Registry.
PL_BUILD_CHANNEL: release
PL_BUILD_VARIANT: docker
PL_BUILD_LOCATION: remote
PL_RELEASE_DOCKER_PUSH_URL: ${{ vars.GCP_REGION }}-docker.pkg.dev/${{ vars.GCP_PROJECT }}/${{ vars.IMAGES_REPO }}/pl-containers
PL_RELEASE_DOCKER_PULL_URL: ${{ vars.GCP_REGION }}-docker.pkg.dev/${{ vars.GCP_PROJECT }}/${{ vars.IMAGES_REPO }}/pl-containers
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 24
cache: pnpm
# Install before logging in to the cloud, so dependency install scripts never see the credentials.
# CHANGE: with a private npm registry, log in to it before this step (see step 5 of the guide).
- run: pnpm install --frozen-lockfile
- uses: google-github-actions/auth@v2
with:
workload_identity_provider: projects/${{ vars.GCP_PROJECT_NUMBER }}/locations/global/workloadIdentityPools/github/providers/github
service_account: registry-publisher@${{ vars.GCP_PROJECT }}.iam.gserviceaccount.com
- uses: google-github-actions/setup-gcloud@v2
- run: gcloud auth configure-docker ${{ vars.GCP_REGION }}-docker.pkg.dev --quiet
# Images of private blocks must go to your Artifact Registry, never to the public default.
- name: Check the image registry
run: |
for addr in "$PL_RELEASE_DOCKER_PUSH_URL" "$PL_RELEASE_DOCKER_PULL_URL"; do
case "$addr" in
?*-docker.pkg.dev/?*/?*/pl-containers) ;;
*) echo "::error::Not an Artifact Registry address: '$addr'. Set the repository variables."; exit 1 ;;
esac
done
echo "Images go to $PL_RELEASE_DOCKER_PUSH_URL"
# Builds every part and pushes the software images. Do not use `pnpm build:release`:
# it also uploads binary archives to Platforma's software storage.
- run: pnpm exec turbo run build
# publish overwrites an existing version, so publish each version only once.
- name: Check whether this version is already published
id: version
working-directory: block
run: |
id=$(jq -r '.description.id | "\(.organization)/\(.name)/\(.version)"' block-pack/manifest.json)
if gcloud storage objects describe "gs://${{ vars.REGISTRY_BUCKET }}/v2/$id/manifest.json" >/dev/null 2>&1; then
echo "$id is already published"; echo "publish=false" >> "$GITHUB_OUTPUT"
else
echo "publish=true" >> "$GITHUB_OUTPUT"
fi
- name: Publish to the private registry
if: steps.version.outputs.publish == 'true'
working-directory: block
# CHANGE: add --unstable to keep a version out of the stable channel.
run: npx block-tools publish --registry gs://${{ vars.REGISTRY_BUCKET }}/ --registry-serve-url ${{ vars.REGISTRY_URL }}

What this example leaves out, and you may want to add: tests, a pull-request build that does not publish, and the changeset checks.

Step 5: use a private npm registry (if you have one)

Skip this step if your organization has no private npm registry. Organizations run one to share their own packages between blocks, or to mirror npmjs.com. Your administrator tells you its address and how to log in. The registry can be Artifact Registry, CodeArtifact, GitHub Packages, Artifactory, Nexus, Verdaccio or another npm-compatible registry. The settings in the block repository are the same for all of them.

If the registry mirrors npmjs.com, point the whole repository at it. Replace the scope lines in the template’s .npmrc. They send @platforma-sdk, @milaboratories and @platforma-open straight to npmjs.com, which would bypass the mirror:

registry=<npm-registry-address>

If it holds only your shared packages, keep the template’s lines and send only your scope there:

@<your-scope>:registry=<npm-registry-address>

Publish shared packages only there. Use the package scope your administrator agreed on, and set the registry in the package’s own package.json:

"publishConfig": { "registry": "<npm-registry-address-for-publishing>" }

Log in the way your registry’s documentation describes. Keep the token out of the repository: write it into your user ~/.npmrc, not the project’s .npmrc. In CI, log in before pnpm install. Cloud registries accept a short-lived token from the cloud login, so CI needs no stored npm token:

  • Artifact Registry: gcloud auth print-access-token, valid for one hour
  • CodeArtifact: aws codeartifact login --tool npm, valid for up to 12 hours.

Maintaining the registry

These commands need the publisher identity, from CI or a workstation (Step 3):

Command Purpose
block-tools refresh-registry --registry "$REGISTRY_ADDRESS" Rebuild the overviews, for example after someone deleted a version by hand
block-tools mark-stable --registry "$REGISTRY_ADDRESS" Add the block version in the current folder to stable (--unmark reverses this)
block-tools list-overview-snapshots / restore-overview-from-snapshot Roll the overview back to an earlier state

Troubleshooting

Symptom Cause
error: Unknown protocol: gs: block-tools is older than 2.18.0. Update it (what you need).
error: required option '--registry-serve-url <url>' not specified Pass --registry-serve-url with the registry URL your users add in the Desktop App.
Build fails pushing to containers.pl-open.science, or uploading binary archives The build ran without the Step 2 settings, for example through pnpm build:release. Set them and run pnpm exec turbo run build.
denied: Permission "artifactregistry.repositories.uploadArtifacts" during the build Google Cloud: you are not logged in as the publisher, or gcloud auth configure-docker did not run for that region.
no basic auth credentials or denied from *.dkr.ecr.* during the build AWS: the Docker login to ECR is missing or older than 12 hours. Run it again (Step 3).
credentials do not have access to GCS bucket ... Google Cloud: you are not logged in as the publisher. The message names the missing permission.
Could not load the default credentials Google Cloud: Application Default Credentials are not set. Run the login from Step 3, or check the google-github-actions/auth step in CI.
AccessDenied from S3 during publish AWS: AWS_PROFILE is not the publisher profile, or the role lacks access to the bucket.
CI fails at the cloud login step The workflow ran outside the allowed branch or tags, or your administrator has not allowed this repository yet.
Block jobs fail with ImagePullBackOff or ErrImagePull Check that PL_RELEASE_DOCKER_PULL_URL was your image registry address when the block was built. If it was, ask your administrator to check the cluster’s pull access.
Block jobs fail with comes from an untrusted registry The backend does not trust your image registry yet. Ask your administrator to add it with --trusted-docker-registry.
Desktop App does not show the new version Wait about 40 s, then reopen Add Block. Check that publish ended with Refresh finished.
[ERR_PNPM_FETCH_401] from your npm registry The npm token is missing or expired. Log in again (Step 5).
MaxListenersExceededWarning during publish Comes from the Google Cloud Storage client library during parallel uploads. It is harmless.