-
Notifications
You must be signed in to change notification settings - Fork 1
121 lines (102 loc) · 4.22 KB
/
Copy pathsquad-release.yml
File metadata and controls
121 lines (102 loc) · 4.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
name: Squad Release
on:
push:
branches: [main]
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-node@v5
with:
node-version: 22
- name: Run tests
run: node --test test/*.test.cjs
- name: Validate custom agent prompt length
run: |
node <<'EOF'
const fs = require('fs');
const path = require('path');
const AGENT_DIR = path.join(process.cwd(), '.github', 'agents');
const MAX_PROMPT_CHARS = 30000;
if (!fs.existsSync(AGENT_DIR)) {
console.log('No .github/agents directory found; skipping prompt-length validation.');
process.exit(0);
}
const agentFiles = fs
.readdirSync(AGENT_DIR)
.filter((name) => name.endsWith('.agent.md'))
.map((name) => path.join(AGENT_DIR, name));
if (agentFiles.length === 0) {
console.log('No .agent.md files found; skipping prompt-length validation.');
process.exit(0);
}
let hasError = false;
for (const filePath of agentFiles) {
const content = fs.readFileSync(filePath, 'utf8');
const frontmatter = content.match(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/);
const prompt = frontmatter ? content.slice(frontmatter[0].length) : content;
const promptChars = [...prompt].length;
if (promptChars > MAX_PROMPT_CHARS) {
hasError = true;
console.error(`::error file=${path.relative(process.cwd(), filePath)}::Prompt length ${promptChars} exceeds ${MAX_PROMPT_CHARS} characters.`);
} else {
console.log(`✓ ${path.relative(process.cwd(), filePath)} prompt length ${promptChars}/${MAX_PROMPT_CHARS}`);
}
}
if (hasError) {
process.exit(1);
}
EOF
- name: Validate version consistency
run: |
VERSION=$(node -e "console.log(require('./package.json').version)")
if ! grep -q "## \[$VERSION\]" CHANGELOG.md 2>/dev/null; then
echo "::error::Version $VERSION not found in CHANGELOG.md — update CHANGELOG.md before release"
exit 1
fi
echo "✅ Version $VERSION validated in CHANGELOG.md"
- name: Read version from package.json
id: version
run: |
VERSION=$(node -e "console.log(require('./package.json').version)")
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "tag=v$VERSION" >> "$GITHUB_OUTPUT"
echo "📦 Version: $VERSION (tag: v$VERSION)"
- name: Check if tag already exists
id: check_tag
run: |
if git rev-parse "refs/tags/${{ steps.version.outputs.tag }}" >/dev/null 2>&1; then
echo "exists=true" >> "$GITHUB_OUTPUT"
echo "⏭️ Tag ${{ steps.version.outputs.tag }} already exists — skipping release."
else
echo "exists=false" >> "$GITHUB_OUTPUT"
echo "🆕 Tag ${{ steps.version.outputs.tag }} does not exist — creating release."
fi
- name: Create git tag
if: steps.check_tag.outputs.exists == 'false'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "${{ steps.version.outputs.tag }}" -m "Release ${{ steps.version.outputs.tag }}"
git push origin "${{ steps.version.outputs.tag }}"
- name: Create GitHub Release
if: steps.check_tag.outputs.exists == 'false'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "${{ steps.version.outputs.tag }}" \
--title "${{ steps.version.outputs.tag }}" \
--generate-notes \
--latest
- name: Verify release
if: steps.check_tag.outputs.exists == 'false'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release view "${{ steps.version.outputs.tag }}"
echo "✅ Release ${{ steps.version.outputs.tag }} created and verified."