#!/usr/bin/env bash set -euo pipefail # create-release-packages.sh (workflow-local) # Build Spec Kit template release archives for each supported AI assistant and script type. # Usage: .github/workflows/scripts/create-release-packages.sh # Version argument should include leading 'v'. if [[ $# -ne 1 ]]; then echo "Usage: $0 " >&2 exit 1 fi NEW_VERSION="$1" if [[ ! $NEW_VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then echo "Version must look like v0.0.0" >&2 exit 1 fi echo "Building release packages for $NEW_VERSION" rm -rf sdd-package-base* sdd-*-package-* spec-kit-template-*-${NEW_VERSION}.zip || true mkdir -p sdd-package-base SPEC_DIR="sdd-package-base/.specify" mkdir -p "$SPEC_DIR" [[ -d memory ]] && { cp -r memory "$SPEC_DIR/"; echo "Copied memory -> .specify"; } [[ -d scripts ]] && { cp -r scripts "$SPEC_DIR/"; echo "Copied scripts -> .specify/scripts"; } [[ -d templates ]] && { mkdir -p "$SPEC_DIR/templates"; find templates -type f -not -path "templates/commands/*" -exec cp --parents {} "$SPEC_DIR"/ \; ; echo "Copied templates -> .specify/templates"; } rewrite_paths() { sed -E \ -e 's@(/?)memory/@.specify/memory/@g' \ -e 's@(/?)scripts/@.specify/scripts/@g' \ -e 's@(/?)templates/@.specify/templates/@g' } generate_commands() { local agent=$1 ext=$2 arg_format=$3 output_dir=$4 script_variant=$5 mkdir -p "$output_dir" for template in templates/commands/*.md; do [[ -f "$template" ]] || continue local name description raw_body variant_line injected body name=$(basename "$template" .md) description=$(awk '/^description:/ {gsub(/^description: *"?/, ""); gsub(/"$/, ""); print; exit}' "$template" | tr -d '\r') raw_body=$(awk '/^---$/{if(++count==2) start=1; next} start' "$template") # Find single-line variant comment matching the variant: or variant_line=$(printf '%s\n' "$raw_body" | awk -v sv="$script_variant" '//, m); if (m[1]!="") {print m[1]; exit}}') if [[ -z $variant_line ]]; then echo "Warning: no variant line found for $script_variant in $template" >&2 variant_line="(Missing variant command for $script_variant)" fi # Replace the token VARIANT-INJECT with the selected variant line injected=$(printf '%s\n' "$raw_body" | sed "s/VARIANT-INJECT/${variant_line//\//\/}/") # Remove all single-line variant comments injected=$(printf '%s\n' "$injected" | sed '//, m); if(m[1]!=""){print m[1]; exit}}' "$plan_tpl") if [[ -n $variant_line ]]; then tmp_file=$(mktemp) sed "s/VARIANT-INJECT/${variant_line//\//\/}/" "$plan_tpl" | sed "/__AGENT__/s//${agent}/g" | sed '/