-
Notifications
You must be signed in to change notification settings - Fork 0
313 lines (275 loc) · 10.4 KB
/
publish.yml
File metadata and controls
313 lines (275 loc) · 10.4 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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
name: Publish VSCode Extension
on:
push:
branches: [main]
paths-ignore:
- '**.md'
- '.gitignore'
- '.vscodeignore'
- 'LICENSE'
pull_request:
branches: [main]
env:
NODE_VERSION: '20'
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Clean install dependencies
run: |
rm -rf node_modules package-lock.json
npm install
- name: Lint code
run: npm run lint
- name: Compile TypeScript
run: npm run compile
- name: Package extension
run: npm run package
- name: Send Discord notification - Test Results
if: always()
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
run: |
if [ -n "$DISCORD_WEBHOOK" ]; then
if [ "${{ job.status }}" = "success" ]; then
STATUS="✅ Success"
COLOR=65280
else
STATUS="❌ Failed"
COLOR=16711680
fi
COMMIT_SHORT="${{ github.sha }}"
COMMIT_SHORT="${COMMIT_SHORT:0:7}"
TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%S.000Z)
cat > payload.json << EOF
{
"embeds": [{
"title": "🧪 AI Commit Generator - Test Phase",
"description": "Testing extension build and compilation",
"color": $COLOR,
"fields": [
{
"name": "Status",
"value": "$STATUS",
"inline": true
},
{
"name": "Branch",
"value": "${{ github.ref_name }}",
"inline": true
},
{
"name": "Commit",
"value": "[\`$COMMIT_SHORT\`](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }})",
"inline": true
}
],
"timestamp": "$TIMESTAMP"
}]
}
EOF
curl -H "Content-Type: application/json" -X POST "$DISCORD_WEBHOOK" -d @payload.json
rm payload.json
fi
publish:
needs: test
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
permissions:
contents: write
actions: read
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Clean install dependencies
run: |
rm -rf node_modules package-lock.json
npm install
- name: Install VSCE (latest)
run: npm install -g @vscode/vsce@latest
- name: Check version changes
id: version-check
run: |
CURRENT_VERSION=$(node -p "require('./package.json').version")
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
if git tag | grep -q "v$CURRENT_VERSION"; then
echo "version_changed=false" >> $GITHUB_OUTPUT
echo "Version $CURRENT_VERSION already exists"
else
echo "version_changed=true" >> $GITHUB_OUTPUT
echo "New version $CURRENT_VERSION detected"
fi
- name: Send Discord notification - Version Check
if: steps.version-check.outputs.version_changed == 'false'
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
run: |
if [ -n "$DISCORD_WEBHOOK" ]; then
TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%S.000Z)
cat > payload.json << EOF
{
"embeds": [{
"title": "⚠️ AI Commit Generator - Version Skipped",
"description": "No new version detected, skipping publish",
"color": 16776960,
"fields": [
{
"name": "Current Version",
"value": "v${{ steps.version-check.outputs.current_version }}",
"inline": true
},
{
"name": "Status",
"value": "Already published",
"inline": true
}
],
"timestamp": "$TIMESTAMP"
}]
}
EOF
curl -H "Content-Type: application/json" -X POST "$DISCORD_WEBHOOK" -d @payload.json
rm payload.json
fi
- name: Package extension with VSCE
if: steps.version-check.outputs.version_changed == 'true'
run: |
npm run package
vsce package --no-dependencies --out ai-commit-generator-${{ steps.version-check.outputs.current_version }}.vsix
ls -la *.vsix
echo "VSIX file created: ai-commit-generator-${{ steps.version-check.outputs.current_version }}.vsix"
- name: Publish to Visual Studio Marketplace
if: steps.version-check.outputs.version_changed == 'true'
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
run: |
vsce publish --pat $VSCE_PAT --no-dependencies
- name: Create Git Tag
if: steps.version-check.outputs.version_changed == 'true'
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git tag v${{ steps.version-check.outputs.current_version }}
git push origin v${{ steps.version-check.outputs.current_version }}
- name: Create GitHub Release
if: steps.version-check.outputs.version_changed == 'true'
id: create-release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.version-check.outputs.current_version }}
name: Release v${{ steps.version-check.outputs.current_version }}
body: |
## 🎉 AI Commit Generator v${{ steps.version-check.outputs.current_version }}
### 📦 Installation
- Install from [VSCode Marketplace](https://marketplace.visualstudio.com/items?itemName=DTDucas.ai-commit-generator)
- Or download the `.vsix` file from this release and install via `code --install-extension filename.vsix`
### 🔗 Links
- [Repository](https://github.com/${{ github.repository }})
- [Documentation](https://github.com/${{ github.repository }}/blob/main/README.md)
- [Issues](https://github.com/${{ github.repository }}/issues)
### 📋 Changelog
See [README.md](https://github.com/${{ github.repository }}/blob/main/README.md#changelog) for detailed changes.
### 🚀 Features
- 🤖 **Dual AI Support**: Google Gemini & AWS Bedrock
- ✨ **Smart Analysis**: Analyzes staged git changes
- 📝 **Strict Format**: Conventional commits with emojis
- 🎯 **VSCode Integration**: Source Control panel button
- ⚙️ **JSON Configuration**: Workspace-specific settings
draft: false
prerelease: false
files: |
ai-commit-generator-${{ steps.version-check.outputs.current_version }}.vsix
- name: Send Discord notification - Success
if: steps.version-check.outputs.version_changed == 'true' && success()
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
run: |
if [ -n "$DISCORD_WEBHOOK" ]; then
TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%S.000Z)
cat > payload.json << EOF
{
"embeds": [{
"title": "🚀 AI Commit Generator - Published Successfully!",
"description": "New version has been published to VS Code Marketplace",
"color": 65280,
"fields": [
{
"name": "Version",
"value": "v${{ steps.version-check.outputs.current_version }}",
"inline": true
},
{
"name": "Marketplace",
"value": "[Install Extension](https://marketplace.visualstudio.com/items?itemName=DTDucas.ai-commit-generator)",
"inline": true
},
{
"name": "GitHub Release",
"value": "[View Release](${{ github.server_url }}/${{ github.repository }}/releases/tag/v${{ steps.version-check.outputs.current_version }})",
"inline": true
}
],
"footer": {
"text": "Deployed by ${{ github.actor }}"
},
"timestamp": "$TIMESTAMP"
}]
}
EOF
curl -H "Content-Type: application/json" -X POST "$DISCORD_WEBHOOK" -d @payload.json
rm payload.json
fi
- name: Send Discord notification - Failure
if: steps.version-check.outputs.version_changed == 'true' && failure()
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
run: |
if [ -n "$DISCORD_WEBHOOK" ]; then
TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%S.000Z)
cat > payload.json << EOF
{
"embeds": [{
"title": "❌ AI Commit Generator - Publish Failed",
"description": "Failed to publish extension to VS Code Marketplace",
"color": 16711680,
"fields": [
{
"name": "Version",
"value": "v${{ steps.version-check.outputs.current_version }}",
"inline": true
},
{
"name": "Failed Step",
"value": "Publish to Marketplace",
"inline": true
},
{
"name": "Logs",
"value": "[View Logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})",
"inline": true
}
],
"footer": {
"text": "Attempted by ${{ github.actor }}"
},
"timestamp": "$TIMESTAMP"
}]
}
EOF
curl -H "Content-Type: application/json" -X POST "$DISCORD_WEBHOOK" -d @payload.json
rm payload.json
fi