Skip to content

Merge pull request #4 from DTDucas/dev #9

Merge pull request #4 from DTDucas/dev

Merge pull request #4 from DTDucas/dev #9

Workflow file for this run

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