name: Hotfix Release
on:
workflow_dispatch:
inputs:
hotfix-description:
description: 'Brief description of the hotfix'
required: true
type: string
emergency:
description: 'Emergency release (skip some checks)'
required: false
default: false
type: boolean
env:
NODE_VERSION: '20.x'
jobs:
validate:
name: Validate Hotfix
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: Install dependencies
run: npm ci
- name: Run essential tests
run: npm run test
- name: Run linting
if: inputs.emergency == false
run: npm run lint
- name: Security audit
if: inputs.emergency == false
run: npm audit --audit-level=high
hotfix:
name: Create Hotfix Release
runs-on: ubuntu-latest
needs: [validate]
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Create hotfix release
run: |
# Create a patch release with custom message
npm run release:patch
# Update CHANGELOG with hotfix note
sed -i '1a\\n### 🚨 Hotfix: ${{ inputs.hotfix-description }}\n' CHANGELOG.md
- name: Push changes
run: |
git add CHANGELOG.md
git commit -m "docs: add hotfix note to changelog" || true
git push --follow-tags origin main
- name: Get new version
id: version
run: |
echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
echo "tag=v$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
- name: Install VSCE
run: npm install -g @vscode/vsce
- name: Package extension
run: vsce package
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.version.outputs.tag }}
name: 🚨 Hotfix Release ${{ steps.version.outputs.version }}
body: |
## 🚨 Hotfix Release
**Description**: ${{ inputs.hotfix-description }}
This is an emergency hotfix release to address a critical issue.
### Changes
- ${{ inputs.hotfix-description }}
### Installation
- VS Code Marketplace: Extension will be updated automatically
- Manual: Download the VSIX file below
**Emergency Release**: ${{ inputs.emergency }}
files: '*.vsix'
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to VS Code Marketplace
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
run: |
if [ -n "$VSCE_PAT" ]; then
vsce publish --pat $VSCE_PAT
else
echo "VSCE_PAT not configured, skipping marketplace publish"
fi
- name: Create issue for post-hotfix review
if: inputs.emergency == true
uses: actions/github-script@v7
with:
script: |
github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: '🔍 Post-Hotfix Review Required',
body: `## Post-Hotfix Review
An emergency hotfix was deployed: **${{ inputs.hotfix-description }}**
### Action Items
- [ ] Review the hotfix changes
- [ ] Ensure all tests pass
- [ ] Update documentation if needed
- [ ] Plan proper fix for next regular release
**Hotfix Version**: ${{ steps.version.outputs.version }}
**Emergency Release**: ${{ inputs.emergency }}`,
labels: ['hotfix', 'review-required', 'high-priority']
})
notify:
name: Notify Hotfix
runs-on: ubuntu-latest
needs: [hotfix]
if: always()
steps:
- name: Notify Success
if: needs.hotfix.result == 'success'
run: |
echo "🚨 Hotfix release completed successfully!"
echo "Description: ${{ inputs.hotfix-description }}"
- name: Notify Failure
if: needs.hotfix.result == 'failure'
run: |
echo "❌ Hotfix release failed!"
echo "Description: ${{ inputs.hotfix-description }}"
exit 1