-
Notifications
You must be signed in to change notification settings - Fork 2
286 lines (242 loc) · 9.37 KB
/
release.yml
File metadata and controls
286 lines (242 loc) · 9.37 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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
name: Release
on:
# Manual trigger with version input
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 0.1.3)'
required: true
type: string
prerelease:
description: 'Mark as pre-release'
required: false
type: boolean
default: false
# Still support tag-based releases for automation
push:
tags:
- 'v*.*.*' # Trigger on version tags like v1.0.0
jobs:
release-npm:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # For npm provenance
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "24"
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
run: npm install
- name: Run tests
run: npm test
env:
CI: true
NODE_OPTIONS: --max-old-space-size=6144
- name: Build package
run: npm run build
- name: Verify package files
run: |
echo "📦 Package contents:"
npm pack --dry-run
echo "✅ Package verification complete"
- name: Set version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="${{ github.event.inputs.version }}"
TAG_NAME="v$VERSION"
else
VERSION=${GITHUB_REF#refs/tags/v}
TAG_NAME=${GITHUB_REF##*/}
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
echo "Setting package version to $VERSION"
npm version $VERSION --no-git-tag-version
- name: Publish to npm
shell: bash
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
# Publish alpha/beta as 'next', rc as both 'latest' and 'rc', stable as 'latest'
# Note: npm requires explicit --tag for prerelease versions
if [[ "$VERSION" == *-alpha* ]] || [[ "$VERSION" == *-beta* ]]; then
npm publish --access public --provenance --tag next
elif [[ "$VERSION" == *-rc* ]]; then
npm publish --access public --provenance --tag latest
npm dist-tag add "@probelabs/visor@$VERSION" rc || true
else
npm publish --access public --provenance --tag latest
fi
- name: Post-release notification
if: success()
run: |
echo "🎉 Successfully published @probelabs/visor@$VERSION to npm!"
echo "📦 Install with: npx -y @probelabs/visor"
# Publish Enterprise Edition with -ee version suffix
release-npm-ee:
runs-on: ubuntu-latest
needs: release-npm # Publish EE after OSS succeeds
permissions:
contents: read
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "24"
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
run: npm install
- name: Set version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="${{ github.event.inputs.version }}"
else
VERSION=${GITHUB_REF#refs/tags/v}
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "EE_VERSION=${VERSION}-ee" >> $GITHUB_ENV
- name: Build EE package
run: npm run build:ee
- name: Verify enterprise code in bundle
run: |
if grep -q "OpaPolicyEngine" dist/index.js && grep -q "LicenseValidator" dist/index.js; then
echo "✅ EE bundle contains enterprise code"
else
echo "❌ EE bundle is missing enterprise code"
exit 1
fi
- name: Set EE version
run: npm version "$EE_VERSION" --no-git-tag-version
- name: Publish EE to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
npm publish --access public --provenance --tag ee --ignore-scripts
- name: Post-release notification
if: success()
run: |
echo "🎉 Successfully published @probelabs/visor@$EE_VERSION to npm!"
echo "📦 Install with: npm install @probelabs/visor@ee"
# GitHub Release creation with AI-generated notes
create-release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Need full history for git log
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "24"
- name: Install dependencies and build
run: |
npm install
npm run build
- name: Set version variables
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="${{ github.event.inputs.version }}"
TAG_NAME="v$VERSION"
else
VERSION=${GITHUB_REF#refs/tags/v}
TAG_NAME=${GITHUB_REF##*/}
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
echo "📋 Processing release for ${TAG_NAME}"
- name: Generate AI release notes
id: release-notes
run: |
echo "🤖 Generating AI-powered release notes..."
# Get previous tag for comparison
PREV_TAG=$(git describe --tags --abbrev=0 ${TAG_NAME}^ 2>/dev/null || echo "")
# Get commits and diff stats since last tag
if [ -n "$PREV_TAG" ]; then
GIT_LOG=$(git log --oneline --no-merges ${PREV_TAG}..${TAG_NAME} 2>/dev/null || git log --oneline --no-merges ${TAG_NAME})
GIT_DIFF_STAT=$(git diff --stat ${PREV_TAG}..${TAG_NAME} 2>/dev/null || git diff --stat $(git hash-object -t tree /dev/null)..${TAG_NAME})
echo "📊 Found $(echo "$GIT_LOG" | wc -l) commits since ${PREV_TAG}"
else
GIT_LOG=$(git log --oneline --no-merges ${TAG_NAME})
GIT_DIFF_STAT=$(git diff --stat $(git hash-object -t tree /dev/null)..${TAG_NAME})
echo "📊 Found $(echo "$GIT_LOG" | wc -l) commits (first release)"
fi
# Generate release notes with Visor AI
echo "🔍 Running Visor AI to generate release notes..."
VISOR_OUTPUT=$(TAG_NAME=${{ env.TAG_NAME }} \
GIT_LOG="$GIT_LOG" \
GIT_DIFF_STAT="$GIT_DIFF_STAT" \
timeout 300 ./dist/index.js --cli --check release-notes --config .visor.yaml --output json 2>&1 || true)
echo "📋 Visor output:"
echo "$VISOR_OUTPUT"
# Extract release notes from JSON output
# The JSON structure is grouped by group name (e.g., "release": [...])
# We need to flatten all groups and find the release-notes check
RELEASE_NOTES=$(echo "$VISOR_OUTPUT" | jq -r '
to_entries[]
| .value[]
| select(.checkName == "release-notes")
| .output // .content // empty
' 2>/dev/null | head -1 || echo "")
# Track if we need GitHub to auto-generate notes
USE_GITHUB_NOTES="false"
# Fallback if AI generation fails
if [ -z "$RELEASE_NOTES" ] || [ "$RELEASE_NOTES" = "null" ]; then
echo "⚠️ AI release notes generation failed, using GitHub auto-generated notes"
RELEASE_NOTES=""
USE_GITHUB_NOTES="true"
else
echo "✅ Successfully generated AI release notes"
fi
# Save to GitHub output (handle multiline properly)
echo "RELEASE_NOTES<<EOF" >> $GITHUB_OUTPUT
echo "$RELEASE_NOTES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "USE_GITHUB_NOTES=$USE_GITHUB_NOTES" >> $GITHUB_OUTPUT
env:
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v2.3.3
with:
tag_name: ${{ env.TAG_NAME }}
name: Release ${{ env.TAG_NAME }}
# Only use GitHub auto-generated notes when AI generation failed
generate_release_notes: ${{ steps.release-notes.outputs.USE_GITHUB_NOTES == 'true' }}
draft: false
prerelease: ${{ github.event.inputs.prerelease || contains(env.VERSION, '-beta') || contains(env.VERSION, '-alpha') || contains(env.VERSION, '-rc') }}
body: |
${{ steps.release-notes.outputs.RELEASE_NOTES }}
---
## 📋 Installation & Usage
### Using Visor as a GitHub Action
```yaml
- uses: ${{ github.repository }}@${{ env.TAG_NAME }}
```
### Using Visor CLI
```bash
npx -y @probelabs/visor --check all
```
### Installation Options
**NPM (Global)**
```bash
npm install -g @probelabs/visor
visor --check all
```
**NPX (No installation)**
```bash
npx -y @probelabs/visor --check security --output json
```
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}