Lewati ke konten

Membangun Pack

Pack adalah unit distribusi di Greentic. Panduan ini membahas pembuatan, pembangunan, penandatanganan, dan publikasi pack menggunakan alat CLI.

Terminal window
gtc pack <COMMAND>
Commands:
build Build a pack from source directory
verify Verify pack signature and contents
info Display pack metadata
extract Extract pack contents
sign Sign a pack
publish Publish pack to registry
  1. Buat struktur direktori pack

    Terminal window
    mkdir -p my-pack/{flows,components,assets}
  2. Buat manifest pack

    my-pack/pack.toml
    [pack]
    name = "my-feature"
    version = "1.0.0"
    description = "My awesome feature pack"
    authors = ["Your Name <you@example.com>"]
    [capabilities]
    id = "greentic.cap.app.v1"
    provides = ["my-feature"]
    [flows]
    main = "flows/main.ygtc"
    [components]
    processor = "components/processor.wasm"
    [assets]
    templates = "assets/templates/"
  3. Tambahkan flow

    my-pack/flows/main.ygtc
    name: main
    version: "1.0"
    description: Main flow
    nodes:
    - id: process
    type: reply
    config:
    message: "Hello from my pack!"
    triggers:
    - type: message
    target: process
  4. Tambahkan komponen (jika ada)

    Build komponen WASM dan letakkan di components/:

    Terminal window
    cd my-component
    cargo build --target wasm32-wasip2 --release
    cp target/wasm32-wasip2/release/my_component.wasm ../my-pack/components/
Terminal window
gtc pack build ./my-pack
# Output: my-feature-1.0.0.gtpack
Terminal window
# Specify output path
gtc pack build ./my-pack --output ./dist/my-feature.gtpack
# Skip WASM optimization
gtc pack build ./my-pack --no-optimize
# Include debug info
gtc pack build ./my-pack --debug
  • Directorymy-feature-1.0.0.gtpack
    • manifest.cbor
    • Directoryflows/
      • main.ygtc
    • Directorycomponents/
      • processor.wasm
    • Directoryassets/
      • Directorytemplates/
    • sbom.json
Terminal window
# Generate new Ed25519 key pair
gtc pack keygen --output my-signing-key
# Creates:
# - my-signing-key.pem (private key - keep secret!)
# - my-signing-key.pub (public key - distribute)
Terminal window
gtc pack sign my-feature-1.0.0.gtpack --key my-signing-key.pem
# Output: my-feature-1.0.0.gtpack (updated with signature)
Terminal window
gtc pack verify my-feature-1.0.0.gtpack --pubkey my-signing-key.pub
# Output: Signature valid
Terminal window
gtc pack info my-feature-1.0.0.gtpack

Output:

Pack: my-feature
Version: 1.0.0
Description: My awesome feature pack
Authors: Your Name <you@example.com>
Capabilities:
ID: greentic.cap.app.v1
Provides: my-feature
Contents:
Flows: 1
Components: 1
Assets: 2 directories
Signature: Valid (signed by: ABC123...)
Terminal window
gtc pack info my-feature-1.0.0.gtpack --list
# Lists all files in the pack
Terminal window
gtc pack extract my-feature-1.0.0.gtpack --output ./extracted/
# Extracts pack contents for inspection
Terminal window
# Validate all flows in a directory
gtc flow doctor ./my-pack/flows/
# Validate specific flow
gtc flow validate ./my-pack/flows/main.ygtc
Terminal window
gtc flow doctor ./flows/
# Output:
# Checking flows/main.ygtc... OK
# Checking flows/helper.ygtc... OK
#
# 2 flows checked, 0 errors, 0 warnings
ErrorPenyebabPerbaikan
Unknown node typeTipe node tidak validPeriksa tipe node yang tersedia
Missing target nodeEdge mengarah ke node yang tidak adaPerbaiki referensi ID node
Circular dependencyNode membentuk siklusPutuskan siklusnya
No trigger definedFlow tidak memiliki entry pointTambahkan trigger
Terminal window
# Login to registry
gtc pack login ghcr.io --username USER --password TOKEN
# Publish pack
gtc pack publish my-feature-1.0.0.gtpack --registry ghcr.io/greentic
Terminal window
gtc pack pull ghcr.io/greentic/my-feature:1.0.0
greentic.demo.yaml
apps:
my-app:
pack: "oci://ghcr.io/greentic/my-feature:1.0.0"
pack.toml
[pack]
name = "messaging-custom"
version = "1.0.0"
description = "Custom messaging provider"
[capabilities]
id = "greentic.cap.messaging.provider.v1"
provides = ["custom"]
[flows]
setup_default = "flows/setup.ygtc"
verify_webhooks = "flows/verify.ygtc"
[components]
ingress = "components/ingress.wasm"
egress = "components/egress.wasm"
operator = "components/operator.wasm"
[secrets]
required = ["api_key"]
optional = ["webhook_secret"]
pack.toml
[pack]
name = "helpdesk-bot"
version = "1.0.0"
description = "IT Helpdesk bot"
[capabilities]
id = "greentic.cap.app.v1"
provides = ["helpdesk"]
[dependencies]
greentic-templates = "^0.4"
greentic-llm-openai = "^0.4"
[flows]
on_message = "flows/on_message.ygtc"
on_ticket = "flows/on_ticket.ygtc"
[assets]
cards = "assets/cards/"
templates = "assets/templates/"
  1. Gunakan versioning semantik - Gunakan semver (MAJOR.MINOR.PATCH)
  2. Tandatangani semua rilis - Jangan pernah mendistribusikan pack tanpa tanda tangan
  3. Sertakan SBOM - Dokumentasikan dependensi untuk audit keamanan
  4. Uji sebelum publikasi - Validasi flow dan uji komponen
  5. Dokumentasikan secara menyeluruh - Sertakan README di pack
  6. Jaga pack tetap fokus - Satu fitur atau provider per pack
  7. Gunakan CI/CD - Otomatiskan build dan publikasi
.github/workflows/pack.yml
name: Build and Publish Pack
on:
push:
tags:
- 'v*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@1.90.0
- name: Build Pack
run: gtc pack build ./my-pack
- name: Sign Pack
run: |
echo "${{ secrets.SIGNING_KEY }}" > key.pem
gtc pack sign my-feature-*.gtpack --key key.pem
- name: Publish
run: |
gtc pack login ghcr.io --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }}
gtc pack publish my-feature-*.gtpack --registry ghcr.io/${{ github.repository }}