apiVersion: tekton.dev/v1 kind: Task metadata: name: rust-nx-merge annotations: tekton.dev/pipelines.minVersion: "0.30.0" tekton.dev/categories: GitOps tekton.dev/tags: git, nx, rust, monorepo tekton.dev/displayName: "Merge Rust Projects into Nx Monorepo" spec: description: | Imports Rust projects into an Nx monorepo structure and synchronizes Cargo.toml versions. Accepts space-separated project pairs for bulk operations. params: - name: context type: string description: context directory default: "" - name: targetProjects type: string description: "Space-separated target project paths in monorepo (e.g., 'libs/auth libs/payment')" - name: sourceProjects type: string description: "Space-separated source project paths in workspace (e.g., 'generated/auth generated/payment')" - name: version type: string description: "Version to set in Cargo.toml files" default: "0.1.0" - name: workspaceName type: string description: "Name of the monorepo workspace directory" default: "unbox-x" workspaces: - name: base steps: - name: import-projects image: node:18-alpine workingDir: /workspace/base/$(params.context)/source env: - name: HOME value: /workspace/base/$(params.context)/home script: | #!/bin/sh set -ex # Install Nx if missing command -v nx >/dev/null || npm install -g nx@latest TARGETS="$(params.targetProjects)" SOURCES="$(params.sourceProjects)" set -- $TARGETS for TARGET in "$@"; do SRC=$(echo "$SOURCES" | cut -d' ' -f1) SOURCES=$(echo "$SOURCES" | cut -s -d' ' -f2-) echo "Importing: $SRC → $TARGET" nx import "$SRC" "$TARGET" echo "Updating version to $(params.version)" sed -i.bak "s/^version = .*/version = \"$(params.version)\"/" "$TARGET/Cargo.toml" rm -f "$TARGET/Cargo.toml.bak" done - name: git-commit image: alpine/git:latest workingDir: /workspace/base/$(params.context)/source env: - name: HOME value: /workspace/base/$(params.context)/home script: | #!/bin/sh set -e git add . git commit -m "chore: merge projects (version $(params.version))" || exit 0 git push origin HEAD:main