ci-validation-gates

GitHub

提供防御性CI/CD最佳实践,包括语义化版本校验、NPM自动化令牌验证、发布重试机制及草稿检测,旨在预防因配置错误导致的发布失败。

.squad/templates/skills/ci-validation-gates/SKILL.md microsoft/Generative-AI-for-beginners-dotnet

Trigger Scenarios

配置CI/CD流水线 发布npm包 修复发布故障

Install

npx skills add microsoft/Generative-AI-for-beginners-dotnet --skill ci-validation-gates -g -y
More Options

Non-standard path

npx skills add https://github.com/microsoft/Generative-AI-for-beginners-dotnet/tree/main/.squad/templates/skills/ci-validation-gates -g -y

Use without installing

npx skills use microsoft/Generative-AI-for-beginners-dotnet@ci-validation-gates

指定 Agent (Claude Code)

npx skills add microsoft/Generative-AI-for-beginners-dotnet --skill ci-validation-gates -a claude-code -g -y

安装 repo 全部 skill

npx skills add microsoft/Generative-AI-for-beginners-dotnet --all -g -y

预览 repo 内 skill

npx skills add microsoft/Generative-AI-for-beginners-dotnet --list

SKILL.md

Frontmatter
{
    "name": "ci-validation-gates",
    "domain": "ci-cd",
    "source": "extracted from Drucker and Trejo charters — earned knowledge from v0.8.22 release incident",
    "confidence": "high",
    "description": "Defensive CI\/CD patterns: semver validation, token checks, retry logic, draft detection — earned from v0.8.22"
}

Context

CI workflows must be defensive. These patterns were learned from the v0.8.22 release disaster where invalid semver, wrong token types, missing retry logic, and draft releases caused a multi-hour outage. Both Drucker (CI/CD) and Trejo (Release Manager) carried this knowledge in their charters — now centralized here.

Patterns

Semver Validation Gate

Every publish workflow MUST validate version format before npm publish. 4-part versions (e.g., 0.8.21.4) are NOT valid semver — npm mangles them.

- name: Validate semver
  run: |
    VERSION="${{ github.event.release.tag_name }}"
    VERSION="${VERSION#v}"
    if ! npx semver "$VERSION" > /dev/null 2>&1; then
      echo "❌ Invalid semver: $VERSION"
      echo "Only 3-part versions (X.Y.Z) or prerelease (X.Y.Z-tag.N) are valid."
      exit 1
    fi
    echo "✅ Valid semver: $VERSION"

NPM Token Type Verification

NPM_TOKEN MUST be an Automation token, not a User token with 2FA:

  • User tokens require OTP — CI can't provide it → EOTP error
  • Create Automation tokens at npmjs.com → Settings → Access Tokens → Automation
  • Verify before first publish in any workflow

Retry Logic for npm Registry Propagation

npm registry uses eventual consistency. After npm publish succeeds, the package may not be immediately queryable.

  • Propagation: typically 5-30s, up to 2min in rare cases
  • All verify steps: 5 attempts, 15-second intervals
  • Log each attempt: "Attempt 1/5: Checking package..."
  • Exit loop on success, fail after max attempts
- name: Verify package (with retry)
  run: |
    MAX_ATTEMPTS=5
    WAIT_SECONDS=15
    for attempt in $(seq 1 $MAX_ATTEMPTS); do
      echo "Attempt $attempt/$MAX_ATTEMPTS: Checking $PACKAGE@$VERSION..."
      if npm view "$PACKAGE@$VERSION" version > /dev/null 2>&1; then
        echo "✅ Package verified"
        exit 0
      fi
      [ $attempt -lt $MAX_ATTEMPTS ] && sleep $WAIT_SECONDS
    done
    echo "❌ Failed to verify after $MAX_ATTEMPTS attempts"
    exit 1

Draft Release Detection

Draft releases don't emit release: published event. Workflows MUST:

  • Trigger on release: published (NOT created)
  • If using workflow_dispatch: verify release is published via GitHub API before proceeding

Build Script Protection

Set SKIP_BUILD_BUMP=1 (or $env:SKIP_BUILD_BUMP = "1" on Windows) before ANY release build. bump-build.mjs is for dev builds ONLY — it silently mutates versions.

Known Failure Modes (v0.8.22 Incident)

# What Happened Root Cause Prevention
1 4-part version published, npm mangled it No semver validation gate npx semver check before every publish
2 CI failed 5+ times with EOTP User token with 2FA Automation token only
3 Verify returned false 404 No retry logic for propagation 5 attempts, 15s intervals
4 Workflow never triggered Draft release doesn't emit event Never create draft releases
5 Version mutated during release bump-build.mjs ran in release SKIP_BUILD_BUMP=1

Anti-Patterns

  • ❌ Publishing without semver validation gate
  • ❌ Single-shot verification without retry
  • ❌ Hard-coded secrets in workflows
  • ❌ Silent CI failures — every error needs actionable output with remediation
  • ❌ Assuming npm publish is instantly queryable

Version History

  • bd4e082 Current 2026-08-20 14:05

Same Skill Collection

.github/skills/agent-collaboration/SKILL.md
.github/skills/coordinator-init-mode/SKILL.md
.github/skills/coordinator-response-mode/SKILL.md
.github/skills/coordinator-source-of-truth/SKILL.md
.github/skills/cross-squad-communication/SKILL.md
.github/skills/cross-squad/SKILL.md
.github/skills/error-recovery/SKILL.md
.github/skills/git-workflow/SKILL.md
.github/skills/iterative-retrieval/SKILL.md
.github/skills/reflect/SKILL.md
.github/skills/reviewer-protocol/SKILL.md
.github/skills/secret-handling/SKILL.md
.github/skills/session-recovery/SKILL.md
.github/skills/squad-conventions/SKILL.md
.github/skills/squad-help/SKILL.md
.github/skills/squad-version-check/SKILL.md
.github/skills/squad/SKILL.md
.github/skills/tiered-memory/SKILL.md
.squad/templates/skills/agent-collaboration/SKILL.md
.squad/templates/skills/agent-conduct/SKILL.md
.squad/templates/skills/architectural-proposals/SKILL.md
.squad/templates/skills/client-compatibility/SKILL.md
.squad/templates/skills/coordinator-init-mode/SKILL.md
.squad/templates/skills/coordinator-response-mode/SKILL.md
.squad/templates/skills/coordinator-source-of-truth/SKILL.md
.squad/templates/skills/cross-machine-coordination/SKILL.md
.squad/templates/skills/cross-squad-communication/SKILL.md
.squad/templates/skills/cross-squad/SKILL.md
.squad/templates/skills/distributed-mesh/SKILL.md
.squad/templates/skills/docs-standards/SKILL.md
.squad/templates/skills/e2e-template-testing/SKILL.md
.squad/templates/skills/economy-mode/SKILL.md
.squad/templates/skills/error-recovery/SKILL.md
.squad/templates/skills/external-comms/SKILL.md
.squad/templates/skills/fact-checking/SKILL.md
.squad/templates/skills/gh-auth-isolation/SKILL.md
.squad/templates/skills/git-workflow/SKILL.md
.squad/templates/skills/github-multi-account/SKILL.md
.squad/templates/skills/history-hygiene/SKILL.md
.squad/templates/skills/humanizer/SKILL.md
.squad/templates/skills/init-mode/SKILL.md
.squad/templates/skills/iterative-retrieval/SKILL.md
.squad/templates/skills/model-selection/SKILL.md
.squad/templates/skills/nap/SKILL.md
.squad/templates/skills/notification-routing/SKILL.md
.squad/templates/skills/personal-squad/SKILL.md
.squad/templates/skills/pr-review-response/SKILL.md
.squad/templates/skills/pr-screenshots/SKILL.md
.squad/templates/skills/ralph-two-pass-scan/SKILL.md

Metadata

Files
0
Version
bd4e082
Hash
d0d5e86d
Indexed
2026-08-20 14:05

- 위키
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-25 11:06
浙ICP备14020137号-1 $방문자$