From dec67d7bef12d8727fa4af9d86e7f310e10a36e6 Mon Sep 17 00:00:00 2001 From: Duong Tran Date: Tue, 5 Aug 2025 20:58:38 +0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20chore:=20update=20GitHub=20Actio?= =?UTF-8?q?ns=20publish=20workflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/publish.yml | 169 ++++++++++++++++++++++++++++++++-- README.md | 3 + 2 files changed, 162 insertions(+), 10 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6457b4c..e8aac1c 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -28,8 +28,10 @@ jobs: node-version: ${{ env.NODE_VERSION }} cache: 'npm' - - name: Install dependencies - run: npm ci + - name: Clean install dependencies + run: | + rm -rf node_modules package-lock.json + npm install - name: Lint code run: npm run lint @@ -40,6 +42,46 @@ jobs: - name: Package extension run: npm run package + - name: Send Discord notification - Test Started + if: always() + env: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} + run: | + if [ -n "$DISCORD_WEBHOOK" ]; then + status="โœ… Success" + color=65280 + if [ "${{ job.status }}" != "success" ]; then + status="โŒ Failed" + color=16711680 + fi + + curl -H "Content-Type: application/json" -X POST -d '{ + "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": "[`'${GITHUB_SHA:0:7}'`]('${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}')", + "inline": true + } + ], + "timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%S.000Z)'" + }] + }' "$DISCORD_WEBHOOK" + fi + publish: needs: test runs-on: ubuntu-latest @@ -57,8 +99,10 @@ jobs: node-version: ${{ env.NODE_VERSION }} cache: 'npm' - - name: Install dependencies - run: npm ci + - name: Clean install dependencies + run: | + rm -rf node_modules package-lock.json + npm install - name: Install VSCE run: npm install -g vsce @@ -66,11 +110,9 @@ jobs: - name: Check version changes id: version-check run: | - # Get the current version from package.json CURRENT_VERSION=$(node -p "require('./package.json').version") echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT - # Check if this version has been published if git tag | grep -q "v$CURRENT_VERSION"; then echo "version_changed=false" >> $GITHUB_OUTPUT echo "Version $CURRENT_VERSION already exists" @@ -79,6 +121,34 @@ jobs: 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 + curl -H "Content-Type: application/json" -X POST -d '{ + "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": "'$(date -u +%Y-%m-%dT%H:%M:%S.000Z)'" + }] + }' "$DISCORD_WEBHOOK" + fi + - name: Package extension if: steps.version-check.outputs.version_changed == 'true' run: | @@ -94,6 +164,7 @@ jobs: - name: Create GitHub Release if: steps.version-check.outputs.version_changed == 'true' + id: create-release uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -101,13 +172,19 @@ jobs: tag_name: v${{ steps.version-check.outputs.current_version }} release_name: Release v${{ steps.version-check.outputs.current_version }} body: | - ## Changes in v${{ steps.version-check.outputs.current_version }} + ## ๐ŸŽ‰ AI Commit Generator v${{ steps.version-check.outputs.current_version }} - See [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/main/README.md#changelog) for details. - - ### Installation + ### ๐Ÿ“ฆ Installation - Install from [VSCode Marketplace](https://marketplace.visualstudio.com/items?itemName=DTDucas.ai-commit-generator) - Or download the `.vsix` file from this release + + ### ๐Ÿ”— 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. draft: false prerelease: false @@ -129,3 +206,75 @@ jobs: 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: 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 + curl -H "Content-Type: application/json" -X POST -d '{ + "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": "'$(date -u +%Y-%m-%dT%H:%M:%S.000Z)'" + }] + }' "$DISCORD_WEBHOOK" + 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 + curl -H "Content-Type: application/json" -X POST -d '{ + "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": "'$(date -u +%Y-%m-%dT%H:%M:%S.000Z)'" + }] + }' "$DISCORD_WEBHOOK" + fi diff --git a/README.md b/README.md index 59a6cd9..72ed251 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,9 @@ Generate professional commit messages using AI (Google Gemini or AWS Bedrock) directly in VSCode. +**Author**: [Duong Tran Quang (DTDucas)](https://github.com/DTDucas) +**Contact**: [baymax.contact@gmail.com](mailto:baymax.contact@gmail.com) + ## Features - ๐Ÿค– **Dual AI Support**: Choose between Google Gemini or AWS Bedrock