Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 160 additions & 0 deletions .github/workflows/publish-registry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
name: Publish Registry

on:
push:
branches:
- main
- master
workflow_dispatch:

permissions:
contents: write

jobs:
publish:
runs-on: ubuntu-latest
env:
TZ: Europe/Prague
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Set to 'true' to allow the workflow to push updates to the registry branch
PUSH_REGISTRY: "true"
# Set to 'true' to override whole branch with generated content (keeps just one commit history)
OVERRIDE_BRANCH: "false"
# Default registry repo URL; derived from the current repository
REGISTRY_GIT_URL: https://github.com/${{ github.repository }}.git
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 0 # Full history for tags

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "24.x"

- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: latest

- name: Configure command PATH
run: |
echo "PNPM_HOME=$HOME/.local/share/pnpm" >> "$GITHUB_ENV"
mkdir -p "$HOME/.local/share/pnpm/bin"
echo "$HOME/.local/share/pnpm/bin" >> "$GITHUB_PATH"
pnpm config set global-bin-dir "$HOME/.local/share/pnpm/bin"

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT

- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: pnpm install

- name: Checkout Jaculus-tools
run: |
git clone https://github.com/jaculus-org/Jaculus-tools.git --branch master ../Jaculus-tools
cd ../Jaculus-tools
pnpm install
pnpm build
cd packages/tools
pnpm add -g .

- name: Clone and Build Registry Tool
run: |
git clone https://github.com/jaculus-org/Jaculus-registry.git ../jaculus-registry
cd ../jaculus-registry
pnpm install
# Link local jaculus packages (if any) from the previously cloned Jaculus-tools
for pkg in ../Jaculus-tools/packages/*; do
if [ -f "$pkg/package.json" ]; then
echo "Linking local package: $pkg"
pnpm link "$pkg" || true
fi
done
pnpm build || true

- name: Clone target registry repo (dist)
run: |
git clone $REGISTRY_GIT_URL ../jaculus-registry-dist
cd ../jaculus-registry-dist
git fetch --all
git checkout registry || git checkout -b registry
cd -

- name: Start local registry server
run: |
pnpm --dir ../jaculus-registry run cli -- serve "$GITHUB_WORKSPACE" "$GITHUB_WORKSPACE/../jaculus-registry-dist" &
echo "REGISTRY_PID=$!" >> $GITHUB_ENV
# Wait for server to be ready
for i in $(seq 1 10); do
if curl -sf http://127.0.0.1:3737/; then
exit 0
fi
sleep 1
done
echo "Registry server did not become ready in time" >&2
exit 1

- name: Prepare filtered registry source and Generate registry
run: |
# Use the previously cloned dist repo as the destination
pnpm --dir ../jaculus-registry run cli -- generate "$GITHUB_WORKSPACE" "$GITHUB_WORKSPACE/../jaculus-registry-dist"

- name: Stop local registry server
if: always()
run: |
if [ -n "${REGISTRY_PID:-}" ]; then
kill "$REGISTRY_PID" || true
fi

- name: Copy dist to accessible location
run: |
mkdir -p jaculus-registry-artifact
cp -r ../jaculus-registry-dist/* jaculus-registry-artifact/

- name: Upload registry dist artifact
uses: actions/upload-artifact@v7
with:
name: registry-dist
path: jaculus-registry-artifact/

- name: Push registry branch (optional)
if: ${{ env.PUSH_REGISTRY == 'true' && github.event_name == 'push' }}
run: |
set -euo pipefail
cd ../jaculus-registry-dist

# Configure git (email is optional - GitHub Actions provides defaults)
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

# Set up authentication
git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git checkout registry || git checkout -b registry

# If OVERRIDE_BRANCH is enabled, reset to single commit, otherwise just add commit
if [ "${{ env.OVERRIDE_BRANCH }}" = "true" ]; then
# Remove all history and keep only current state
git add -A
git commit --allow-empty -m "Update registry via GitHub Actions (${GITHUB_SHA})"
git reset --soft $(git rev-list --max-parents=0 HEAD)
git commit --amend -m "Registry build from $(git rev-parse --short HEAD:../Jaculus-libraries/.git/HEAD || echo 'main')"
git push --force origin registry
else
# Regular commit and push
git add -A
git commit -m "Update registry via GitHub Actions (${GITHUB_SHA})" || echo "No changes to commit"
git push origin registry
fi
125 changes: 125 additions & 0 deletions .github/workflows/test-registry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
name: Test Registry

on:
pull_request:
branches:
- main
- master

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
env:
TZ: Europe/Prague
# Default registry repo URL; derived from the current repository
REGISTRY_GIT_URL: https://github.com/${{ github.repository }}.git
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 0 # Full history for tags

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "24.x"

- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: latest

- name: Configure command PATH
run: |
echo "PNPM_HOME=$HOME/.local/share/pnpm" >> "$GITHUB_ENV"
mkdir -p "$HOME/.local/share/pnpm/bin"
echo "$HOME/.local/share/pnpm/bin" >> $GITHUB_PATH
pnpm config set global-bin-dir "$HOME/.local/share/pnpm/bin"

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT

- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: pnpm install

- name: Checkout Jaculus-tools
run: |
git clone https://github.com/jaculus-org/Jaculus-tools.git --branch master ../Jaculus-tools
cd ../Jaculus-tools
pnpm install
pnpm build
cd packages/tools
pnpm add -g .

- name: Clone and Build Registry Tool
run: |
git clone https://github.com/jaculus-org/Jaculus-registry.git ../jaculus-registry
cd ../jaculus-registry
pnpm install
# Link local jaculus packages (if any) from the previously cloned Jaculus-tools
for pkg in ../Jaculus-tools/packages/*; do
if [ -f "$pkg/package.json" ]; then
echo "Linking local package: $pkg"
pnpm link "$pkg" || true
fi
done
pnpm build || true

- name: Clone target registry repo (dist)
run: |
git clone $REGISTRY_GIT_URL ../jaculus-registry-dist
cd ../jaculus-registry-dist
git fetch --all
git checkout registry || git checkout -b registry
cd -

- name: Start local registry server
run: |
pnpm --dir ../jaculus-registry run cli -- serve "$GITHUB_WORKSPACE" "$GITHUB_WORKSPACE/../jaculus-registry-dist" &
echo "REGISTRY_PID=$!" >> $GITHUB_ENV
# Wait for server to be ready
for i in $(seq 1 10); do
if curl -sf http://127.0.0.1:3737/; then
exit 0
fi
sleep 1
done
echo "Registry server did not become ready in time" >&2
exit 1

- name: Prepare filtered registry source and Generate registry
run: |
# Use the previously cloned dist repo as the destination
pnpm --dir ../jaculus-registry run cli -- generate "$GITHUB_WORKSPACE" "$GITHUB_WORKSPACE/../jaculus-registry-dist"

- name: Stop local registry server
if: always()
run: |
if [ -n "${REGISTRY_PID:-}" ]; then
kill "$REGISTRY_PID" || true
fi

- name: Copy dist to accessible location
run: |
mkdir -p jaculus-registry-artifact
cp -r ../jaculus-registry-dist/* jaculus-registry-artifact/

- name: Upload registry dist artifact
uses: actions/upload-artifact@v7
with:
name: registry-dist
path: jaculus-registry-artifact/
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
node_modules
dist

.jaculus-libs-dist/
.DS_Store
tsconfig.tsbuildinfo
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
dist/
bin/
**/pnpm-lock.yaml
4 changes: 4 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"tabWidth": 4,
"useTabs": false
}
File renamed without changes.
File renamed without changes.
82 changes: 82 additions & 0 deletions @types/jaculus/blocks/adc.jacly.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"$schema": "https://jacly.jaculus.org/schema.json",
"package": "@types/jaculus",
"category": "adc",
"name": "%T%",
"description": "%T%",
"colour": "#9C27B0",
"icon": "AudioWaveform",
"priority": 105,
"import": ["import * as adc from \"adc\";"],
"contents": [
{
"kind": "label",
"text": "%SETUP%"
},
{
"kind": "block",
"type": "adc_configure",
"message0": "%T%",
"args0": [
{
"type": "input_value",
"name": "PIN",
"check": "Number"
},
{
"type": "field_dropdown",
"name": "ATTEN",
"options": [
["12 dB", "adc.Attenuation.Db12"],
["0 dB", "adc.Attenuation.Db0"],
["2.5 dB", "adc.Attenuation.Db2_5"],
["6 dB", "adc.Attenuation.Db6"]
]
}
],
"inputs": {
"PIN": {
"shadow": {
"type": "math_number",
"fields": {
"NUM": 1
}
}
}
},
"tooltip": "%T%",
"code": "adc.configure($[PIN], $[ATTEN]);",
"previousStatement": null,
"nextStatement": null
},
{
"kind": "label",
"text": "%READ%"
},
{
"kind": "block",
"type": "adc_read",
"message0": "%T%",
"args0": [
{
"type": "input_value",
"name": "PIN",
"check": "Number"
}
],
"inputs": {
"PIN": {
"shadow": {
"type": "math_number",
"fields": {
"NUM": 1
}
}
}
},
"output": "Number",
"tooltip": "%T%",
"code": "adc.read($[PIN])"
}
]
}
12 changes: 12 additions & 0 deletions @types/jaculus/blocks/communication.jacly.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "https://jacly.jaculus.org/schema.json",
"package": "@types/jaculus",
"category": "communication",
"name": "%T%",
"description": "%T%",
"colour": "#007A4B",
"icon": "Cable",
"priority": 118,
"import": [],
"contents": []
}
Loading