feat: add GitHub Actions release workflow

Implements automated release workflow per design document.

- Triggers on semantic version tags (e.g., 1.2.3)
- Validates version consistency across package.json, manifest.json, and git tag
- Runs test suite (blocks release if tests fail)
- Builds plugin using production build process
- Verifies build artifacts exist (main.js, manifest.json, styles.css)
- Creates draft GitHub release with required files

Workflow uses single-job architecture for simplicity and runs on Node.js 18 with npm caching for performance.
This commit is contained in:
2025-10-26 11:50:37 -04:00
parent 2b7a16cf23
commit b7cf858c1c

91
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,91 @@
name: Release Plugin
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Validate version consistency
run: |
TAG_VERSION="${GITHUB_REF#refs/tags/}"
PKG_VERSION=$(node -p "require('./package.json').version")
MANIFEST_VERSION=$(node -p "require('./manifest.json').version")
echo "Checking version consistency..."
echo "Git tag: $TAG_VERSION"
echo "package.json: $PKG_VERSION"
echo "manifest.json: $MANIFEST_VERSION"
if [ "$TAG_VERSION" != "$PKG_VERSION" ] || [ "$TAG_VERSION" != "$MANIFEST_VERSION" ]; then
echo "❌ Version mismatch detected!"
echo "Git tag: $TAG_VERSION"
echo "package.json: $PKG_VERSION"
echo "manifest.json: $MANIFEST_VERSION"
exit 1
fi
echo "✅ All versions match: $TAG_VERSION"
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
- name: Build plugin
run: npm run build
- name: Verify build artifacts
run: |
echo "Verifying required files exist..."
if [ ! -f main.js ]; then
echo "❌ main.js not found!"
exit 1
fi
if [ ! -f manifest.json ]; then
echo "❌ manifest.json not found!"
exit 1
fi
if [ ! -f styles.css ]; then
echo "❌ styles.css not found!"
exit 1
fi
echo "✅ All required files present"
echo "File sizes:"
ls -lh main.js manifest.json styles.css
- name: Create draft release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG_VERSION="${GITHUB_REF#refs/tags/}"
gh release create "$TAG_VERSION" \
--title="$TAG_VERSION" \
--draft \
main.js \
manifest.json \
styles.css
echo "✅ Draft release created: $TAG_VERSION"
echo "Visit https://github.com/${{ github.repository }}/releases to review and publish"