Skip to content

Commit d9f7f84

Browse files
author
Prince Tripathi
committed
chore: add release test workflow for dry-run testing
1 parent 6558558 commit d9f7f84

1 file changed

Lines changed: 185 additions & 0 deletions

File tree

.github/workflows/release-test.yml

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
name: Release Test (Dry Run)
2+
3+
on:
4+
# Trigger on test tags (e.g., test-v1.0.0, test-v1.2.3)
5+
push:
6+
tags:
7+
- 'test-v*.*.*'
8+
# Allow manual workflow dispatch for testing
9+
workflow_dispatch:
10+
inputs:
11+
version:
12+
description: 'Version to test (e.g., 1.0.0)'
13+
required: true
14+
type: string
15+
16+
# Security: Minimal permissions (read-only for testing)
17+
permissions:
18+
contents: read # Only read (no publishing)
19+
20+
jobs:
21+
test-release:
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
30+
- name: Use Node.js
31+
uses: actions/setup-node@v4
32+
with:
33+
node-version: '20.x'
34+
registry-url: 'https://registry.npmjs.org'
35+
36+
- name: Extract version from tag
37+
id: version
38+
run: |
39+
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
40+
VERSION="${{ github.event.inputs.version }}"
41+
else
42+
# Extract version from test tag (remove 'test-v' prefix)
43+
VERSION="${GITHUB_REF#refs/tags/test-v}"
44+
fi
45+
echo "version=$VERSION" >> $GITHUB_OUTPUT
46+
echo "tag=test-v$VERSION" >> $GITHUB_OUTPUT
47+
echo "📦 Test Version: $VERSION"
48+
49+
# Security: Verify no package installations in workflow files
50+
- name: Security Check - No Package Installations
51+
run: |
52+
echo "🔍 Scanning workflow files for security..."
53+
if grep -rE "(npm install|npm ci|yarn install|pnpm install|bun install|pip install|pip3 install)" .github/workflows/ 2>/dev/null; then
54+
echo "❌ ERROR: Package installation detected in workflow files!"
55+
exit 1
56+
fi
57+
echo "✅ No package installations found in workflows"
58+
59+
# Security: Verify package.json has zero dependencies
60+
- name: Security Check - Zero Dependencies
61+
run: |
62+
echo "🔍 Verifying package.json has zero dependencies..."
63+
if node -e "const pkg = require('./package.json'); if (pkg.dependencies || pkg.devDependencies) { console.error('ERROR: Dependencies found!'); process.exit(1); } else { console.log('✅ Zero dependencies confirmed'); }"; then
64+
echo "✅ Package has zero dependencies"
65+
else
66+
echo "❌ ERROR: Dependencies detected"
67+
exit 1
68+
fi
69+
70+
# Security: Verify no node_modules directory exists
71+
- name: Security Check - No node_modules
72+
run: |
73+
if [ -d "node_modules" ]; then
74+
echo "❌ ERROR: node_modules directory found!"
75+
exit 1
76+
fi
77+
echo "✅ No node_modules directory found"
78+
79+
- name: Verify version matches package.json
80+
run: |
81+
PACKAGE_VERSION=$(node -p "require('./package.json').version")
82+
if [ "$PACKAGE_VERSION" != "${{ steps.version.outputs.version }}" ]; then
83+
echo "⚠️ WARNING: Version mismatch!"
84+
echo " Tag version: ${{ steps.version.outputs.version }}"
85+
echo " package.json version: $PACKAGE_VERSION"
86+
echo " (This is OK for testing - just a warning)"
87+
else
88+
echo "✅ Version matches package.json"
89+
fi
90+
91+
# Security: Verify package.json integrity
92+
- name: Security Check - Package.json Integrity
93+
run: |
94+
echo "🔍 Verifying package.json integrity..."
95+
node -e "
96+
const pkg = require('./package.json');
97+
const scripts = pkg.scripts || {};
98+
const suspicious = Object.keys(scripts).filter(k =>
99+
k.includes('install') || k.includes('post') || k.includes('pre')
100+
);
101+
if (suspicious.length > 0) {
102+
console.error('❌ ERROR: Suspicious scripts found:', suspicious);
103+
process.exit(1);
104+
}
105+
console.log('✅ Package.json integrity check passed');
106+
"
107+
108+
- name: Run tests
109+
run: |
110+
echo "🧪 Running tests..."
111+
npm run test:smoke
112+
113+
- name: Test npm publish dry run
114+
run: |
115+
echo "🔍 Testing npm publish dry run (no actual publish)..."
116+
# This simulates what would be published without actually publishing
117+
npm pack --dry-run 2>&1 | head -20
118+
echo ""
119+
echo "✅ Dry run successful - package would be published with these files:"
120+
npm pack --dry-run 2>&1 | grep -E "^\s+" | head -10
121+
122+
- name: Generate release notes (test)
123+
run: |
124+
VERSION="${{ steps.version.outputs.version }}"
125+
TAG="${{ steps.version.outputs.tag }}"
126+
REPO="${{ github.repository }}"
127+
128+
echo "📝 Generating release notes (test)..."
129+
130+
if [ -f CHANGELOG.md ]; then
131+
CHANGELOG_SECTION=$(awk -v version="$VERSION" '
132+
/^## \[/ {
133+
if (found) exit
134+
if ($0 ~ "## \\[" version "\\]") {
135+
found = 1
136+
print
137+
next
138+
}
139+
}
140+
found { print }
141+
' CHANGELOG.md)
142+
143+
if [ -z "$CHANGELOG_SECTION" ]; then
144+
CHANGELOG_SECTION="## Changes\n\nSee CHANGELOG.md for details."
145+
fi
146+
else
147+
CHANGELOG_SECTION="## Changes\n\nSee commit history for details."
148+
fi
149+
150+
{
151+
echo "# 🛡️ Sentinel Package Manager $VERSION (TEST)"
152+
echo ""
153+
echo "$CHANGELOG_SECTION"
154+
echo ""
155+
echo "## 📦 Installation"
156+
echo ""
157+
echo "\`\`\`bash"
158+
echo "npm install -g @dreamhorizonorg/sentinel@$VERSION"
159+
echo "\`\`\`"
160+
echo ""
161+
echo "## 🔗 Links"
162+
echo ""
163+
echo "- **npm**: https://www.npmjs.com/package/@dreamhorizonorg/sentinel/v/$VERSION"
164+
echo "- **GitHub**: https://github.com/$REPO/releases/tag/$TAG"
165+
} > release_notes_test.md
166+
167+
echo "✅ Release notes generated:"
168+
cat release_notes_test.md
169+
170+
- name: Test summary
171+
run: |
172+
echo "## ✅ Release Test Complete!" >> $GITHUB_STEP_SUMMARY
173+
echo "" >> $GITHUB_STEP_SUMMARY
174+
echo "**Test Version**: ${{ steps.version.outputs.tag }}" >> $GITHUB_STEP_SUMMARY
175+
echo "**Status**: All checks passed - ready for real release" >> $GITHUB_STEP_SUMMARY
176+
echo "" >> $GITHUB_STEP_SUMMARY
177+
echo "**What was tested:**" >> $GITHUB_STEP_SUMMARY
178+
echo "- ✅ Security checks" >> $GITHUB_STEP_SUMMARY
179+
echo "- ✅ Version verification" >> $GITHUB_STEP_SUMMARY
180+
echo "- ✅ Tests execution" >> $GITHUB_STEP_SUMMARY
181+
echo "- ✅ npm publish dry run" >> $GITHUB_STEP_SUMMARY
182+
echo "- ✅ Release notes generation" >> $GITHUB_STEP_SUMMARY
183+
echo "" >> $GITHUB_STEP_SUMMARY
184+
echo "**Next step**: Use a real tag (v*.*.*) to trigger actual release" >> $GITHUB_STEP_SUMMARY
185+

0 commit comments

Comments
 (0)