Skip to content
31 changes: 27 additions & 4 deletions .github/actions/prepare/action.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,38 @@
name: build
description: Check that all packages build successfully
name: Prepare
description: Install dependencies and build the platform
inputs:
build:
description: Build the production bundle of the platform
required: false
default: 'true'
registry:
description: NPM registry to set up for auth
required: false
default: 'https://registry.npmjs.org'

runs:
using: composite
steps:
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
run_install: false

- name: Install Node.js
uses: actions/setup-node@v4
- name: Setup pnpm
uses: pnpm/[email protected]
with:
node-version-file: package.json
registry-url: ${{ inputs.registry }}
cache: pnpm

- name: Update npm
shell: bash
run: npm install -g npm@latest

- name: Install dependencies
shell: bash
run: pnpm install

- name: Build
if: inputs.build == 'true'
shell: bash
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Publish

on:
push:
branches:
- main

permissions:
id-token: write
contents: read

jobs:
publish:
name: Publish Packages
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Prepare
uses: ./.github/actions/prepare

- name: Check if packages exist on NPM
run: |
missing_packages=""
for package in packages/*; do
if [ -f "$package/package.json" ]; then
name=$(jq -r .name "$package/package.json")
private=$(jq -r .private "$package/package.json")

if [ "$private" != "true" ]; then
echo "Checking if $name exists on NPM..."
if ! npm view "$name" > /dev/null 2>&1; then
echo "Error: Package $name does not exist on NPM."
missing_packages="$missing_packages $name"
else
echo "Package $name exists."
fi
fi
fi
done

if [ -n "$missing_packages" ]; then
echo "Error: The following packages do not exist on NPM:"
for package in $missing_packages; do
echo " - $package"
done
echo "Please create these packages on NPM and configure Trusted Publishing before publishing."
exit 1
fi

- name: Publish packages to NPM
env:
NPM_CONFIG_PROVENANCE: true
run: |
pnpm --filter "./packages/*" --recursive publish \
--access=public \
--no-git-checks
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "MIT",
"homepage": "https://github.com/directus-labs/extensions",
"engines": {
"node": ">=18.18.0",
"node": "22",
"pnpm": "~9"
},
"directus:meta": {
Expand Down
Loading