-
Notifications
You must be signed in to change notification settings - Fork 6
186 lines (165 loc) · 6.77 KB
/
test-release.yml
File metadata and controls
186 lines (165 loc) · 6.77 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
name: Test Release (Dry Run)
on:
workflow_dispatch:
inputs:
tag:
description: 'Release version tag (e.g., v2.0.0-test)'
required: true
type: string
release_notes:
description: 'Release notes/description'
required: true
type: string
set_as_latest:
description: 'Set as the latest release'
required: false
type: boolean
default: false
is_prerelease:
description: 'Set as a pre-release'
required: false
type: boolean
default: true
jobs:
test-release:
name: Test Release Process (Dry Run)
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- name: Validate tag format
run: |
TAG="${{ inputs.tag }}"
echo "Testing with tag: $TAG"
# For testing, allow -test, -rc, -beta suffixes
if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?$ ]]; then
echo "Error: Tag must be in format v*.*.* or v*.*.*-suffix (e.g., v2.0.0-test)"
exit 1
fi
echo "✅ Tag format is valid: $TAG"
- name: Check if tag already exists
run: |
TAG="${{ inputs.tag }}"
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "⚠️ Warning: Tag $TAG already exists (will skip tag creation)"
echo "TAG_EXISTS=true" >> $GITHUB_ENV
else
echo "✅ Tag $TAG is available"
echo "TAG_EXISTS=false" >> $GITHUB_ENV
fi
- name: Verify branch is main
run: |
BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [ "$BRANCH" != "main" ]; then
echo "Error: Current branch is $BRANCH, must be main"
exit 1
fi
echo "✅ Confirmed on main branch"
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Clean and install dependencies
run: |
echo "Cleaning any existing installation..."
rm -rf node_modules package-lock.json
echo "Installing dependencies with npm install..."
npm install --prefer-offline --no-audit
echo "Verifying installation..."
if [ -f "node_modules/.bin/ncc" ]; then
echo "✅ ncc binary found"
ls -la node_modules/.bin/ncc
else
echo "❌ ncc binary not found"
echo "Contents of node_modules/.bin/:"
ls -la node_modules/.bin/ || echo "node_modules/.bin/ directory does not exist"
echo "Contents of @vercel/ncc:"
ls -la node_modules/@vercel/ || echo "@vercel directory not found"
exit 1
fi
echo "✅ Dependencies installed"
- name: Build distribution
run: |
echo "Building distribution..."
npm run build
echo "✅ Build completed"
- name: Verify build artifacts
run: |
if [ ! -f "dist/index.js" ]; then
echo "❌ Error: dist/index.js not found after build"
exit 1
fi
echo "✅ Build artifacts verified"
echo "dist/index.js size: $(wc -c < dist/index.js) bytes"
- name: Check for uncommitted changes
run: |
if [[ -n $(git status -s dist/) ]]; then
echo "⚠️ Warning: There are uncommitted changes in dist/"
git status -s dist/
echo ""
echo "In production, these would be committed and pushed"
else
echo "✅ No changes to build artifacts"
fi
- name: Simulate tag creation (DRY RUN)
run: |
TAG="${{ inputs.tag }}"
if [ "$TAG_EXISTS" = "false" ]; then
echo "🔍 DRY RUN: Would create tag: $TAG"
echo "Command: git tag -a '$TAG' -m 'Release $TAG'"
echo "Command: git push origin '$TAG'"
else
echo "⏭️ Skipping tag creation (already exists)"
fi
- name: Create Draft Release (TEST)
uses: actions/create-release@v1
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ inputs.tag }}
release_name: ${{ inputs.tag }} (TEST)
body: |
🧪 **THIS IS A TEST RELEASE**
${{ inputs.release_notes }}
---
*This is a test release created for validation purposes.*
draft: true
prerelease: ${{ inputs.is_prerelease }}
- name: Test Summary
run: |
echo "## 🧪 Test Release Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Version:** ${{ inputs.tag }}" >> $GITHUB_STEP_SUMMARY
echo "**Draft Release URL:** ${{ steps.create_release.outputs.html_url }}" >> $GITHUB_STEP_SUMMARY
echo "**Pre-release:** ${{ inputs.is_prerelease }}" >> $GITHUB_STEP_SUMMARY
echo "**Latest Release:** ${{ inputs.set_as_latest }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### ✅ Test Results:" >> $GITHUB_STEP_SUMMARY
echo "- Tag format validation: PASSED" >> $GITHUB_STEP_SUMMARY
echo "- Branch verification: PASSED" >> $GITHUB_STEP_SUMMARY
echo "- Dependencies installation: PASSED" >> $GITHUB_STEP_SUMMARY
echo "- Build process: PASSED" >> $GITHUB_STEP_SUMMARY
echo "- Build artifacts: VERIFIED" >> $GITHUB_STEP_SUMMARY
echo "- Draft release: CREATED" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 📝 Next Steps:" >> $GITHUB_STEP_SUMMARY
echo "1. Review the draft release at: ${{ steps.create_release.outputs.html_url }}" >> $GITHUB_STEP_SUMMARY
echo "2. If everything looks good, delete this draft release" >> $GITHUB_STEP_SUMMARY
echo "3. Run the actual 'Create Release' workflow for production" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### ⚠️ Remember:" >> $GITHUB_STEP_SUMMARY
echo "- This created a DRAFT release that won't be published" >> $GITHUB_STEP_SUMMARY
echo "- Delete the draft release after testing" >> $GITHUB_STEP_SUMMARY
echo "- Use a test tag like v2.0.0-test to avoid conflicts" >> $GITHUB_STEP_SUMMARY
- name: Notify on failure
if: failure()
run: |
echo "## ❌ Test Failed" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Please check the workflow logs for details." >> $GITHUB_STEP_SUMMARY