Skip to content

Commit

Permalink
Merge pull request #174 from dcSpark/fix/new-node-version-format
Browse files Browse the repository at this point in the history
Support standardized node version formatting and automatic builds.
  • Loading branch information
guillevalin authored Feb 13, 2025
2 parents 5fee589 + 5d3ac25 commit e21ce82
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/build_tools.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ on:
workflow_dispatch:
inputs:
node_version:
description: 'Shinkai Node version to use (e.g. 0.9.8)'
description: 'Shinkai Node version to use (e.g. v0.9.8)'
required: true
type: string
default: "0.9.8"
default: "v0.9.8"
environment:
type: environment
default: "development"
Expand Down Expand Up @@ -54,12 +54,13 @@ jobs:
SHINKAI_NODE_ADDR: "http://localhost:9550"
BEARER_TOKEN: ${{ secrets.API_V2_KEY }}
INITIALIZATION_DATA: ${{ secrets.INITIALIZATION_DATA }}
DOWNLOAD_PREFIX: ${{ vars.DOWNLOAD_PREFIX }}${{ inputs.node_version }}
DOWNLOAD_PREFIX: ${{ vars.DOWNLOAD_PREFIX }}
NODE_VERSION: ${{ inputs.node_version }}
SKIP_IMPORT_FROM_DIRECTORY: true
SHINKAI_STORE_ADDR: ${{ vars.SHINKAI_STORE_ADDR }}
SHINKAI_STORE_TOKEN: ${{ secrets.SHINKAI_STORE_TOKEN }}
USE_DOCKER: true
SHINKAI_NODE_IMAGE: "dcsparkdevops/shinkai-node:${{ inputs.node_version }}"
SHINKAI_NODE_IMAGE: "dcspark/shinkai-node:${{ inputs.node_version }}"
run: |
./scripts/run_node.sh &
timeout 60 bash -c 'until curl -s --location "$SHINKAI_NODE_ADDR/v2/health_check" | jq -e ".status == \"ok\"" > /dev/null; do sleep 1; done'
Expand Down Expand Up @@ -87,12 +88,13 @@ jobs:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_ZONE: ${{ secrets.CLOUDFLARE_ZONE }}
CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_CACHE_INVALIDATION_TOKEN }}
DOWNLOAD_PREFIX: ${{ vars.DOWNLOAD_PREFIX }}${{ inputs.node_version }}
DOWNLOAD_PREFIX: ${{ vars.DOWNLOAD_PREFIX }}
NODE_VERSION: ${{ inputs.node_version }}
run: |
export AWS_ACCESS_KEY_ID=${R2_ACCESS_KEY_ID}
export AWS_SECRET_ACCESS_KEY=${R2_SECRET_ACCESS_KEY}
export AWS_ENDPOINT_URL=https://${CLOUDFLARE_ACCOUNT_ID}.r2.cloudflarestorage.com
UPLOAD_PATH=${{ inputs.environment == 'development' && format('dev-tools-{0}', inputs.node_version) || format('tools-{0}', inputs.node_version) }}
export UPLOAD_PATH=$([ "${{ inputs.environment }}" = "development" ] && echo "dev-tools-" || echo "tools-")${NODE_VERSION#v}
aws configure set default.s3.max_concurrent_requests 1
aws s3 sync ./packages/ s3://${R2_BUCKET}/${UPLOAD_PATH}/ --exclude "*" --include "*.zip" --include "directory.json" \
--endpoint-url https://${CLOUDFLARE_ACCOUNT_ID}.r2.cloudflarestorage.com
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
SHINKAI_STORE_ADDR: ${{ vars.SHINKAI_STORE_ADDR }}
SHINKAI_STORE_TOKEN: ${{ secrets.SHINKAI_STORE_TOKEN }}
USE_DOCKER: true
SHINKAI_NODE_IMAGE: "dcsparkdevops/shinkai-node:${{ inputs.node_version || 'release-latest' }}"
SHINKAI_NODE_IMAGE: "dcspark/shinkai-node:${{ inputs.node_version || 'release-latest' }}"
run: |
./scripts/run_node.sh &
timeout 60 bash -c 'until curl -s --location "$SHINKAI_NODE_ADDR/v2/health_check" | jq -e ".status == \"ok\"" > /dev/null; do sleep 1; done'
Expand Down
6 changes: 3 additions & 3 deletions scripts/build_tools/save_tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ async function processAgentsDirectory() {
version: agentContent.version,
description: agentContent.ui_description,
hash: blake3Hash,
file: `${Deno.env.get("DOWNLOAD_PREFIX")}/${agentId}.zip`,
file: `${Deno.env.get("DOWNLOAD_PREFIX")}${Deno.env.get("NODE_VERSION")?.replace(/^v/, '')}/${agentId}.zip`,
agent_id: agentId,
routerKey: '',
});
Expand Down Expand Up @@ -149,7 +149,7 @@ async function processCronsDirectory() {
version: cronContent.version,
description: cronContent.description,
hash: blake3Hash,
file: `${Deno.env.get("DOWNLOAD_PREFIX")}/${cronId}.zip`,
file: `${Deno.env.get("DOWNLOAD_PREFIX")}${Deno.env.get("NODE_VERSION")?.replace(/^v/, '')}/${cronId}.zip`,
routerKey: '',
});
}
Expand Down Expand Up @@ -237,7 +237,7 @@ export async function processToolsDirectory(): Promise<DirectoryEntry[]> {
description: metadata.description,
hash: '',
toolFile,
file: `${Deno.env.get("DOWNLOAD_PREFIX")}/${toolName.toLowerCase().replace(/[^a-z0-9_.-]/g, '_')}.zip`,
file: `${Deno.env.get("DOWNLOAD_PREFIX")}${Deno.env.get("NODE_VERSION")?.replace(/^v/, '')}/${toolName.toLowerCase().replace(/[^a-z0-9_.-]/g, '_')}.zip`,
price_usd: metadata.price_usd || 0.00,
categoryId: storeMetadata.categoryId,
dependencies,
Expand Down
3 changes: 1 addition & 2 deletions scripts/invalidate_cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ interface DirectoryEntry {

const CLOUDFLARE_ZONE = Deno.env.get("CLOUDFLARE_ZONE");
const CLOUDFLARE_TOKEN = Deno.env.get("CLOUDFLARE_TOKEN");
const DOWNLOAD_PREFIX = Deno.env.get("DOWNLOAD_PREFIX");

if (!CLOUDFLARE_TOKEN) {
console.error("CLOUDFLARE_TOKEN environment variable is required");
Expand All @@ -19,7 +18,7 @@ try {
const directory: DirectoryEntry[] = JSON.parse(directoryContent);

const files = directory.map(entry => entry.file);
files.push(`${DOWNLOAD_PREFIX}/directory.json`);
files.push(`${Deno.env.get("DOWNLOAD_PREFIX")}${Deno.env.get("NODE_VERSION")?.replace(/^v/, '')}/directory.json`);
console.log(`URLs to invalidate: ${JSON.stringify(files, null, 2)}`);

const response = await fetch(
Expand Down

0 comments on commit e21ce82

Please sign in to comment.