Feature/state management #13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Release Extension | |
on: | |
push: | |
branches: [ "main" ] | |
tags: | |
- 'v*' | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
strategy: | |
matrix: | |
node-version: [18.x] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Install Dependencies | |
run: npm ci | |
- name: Build Extension | |
run: | | |
NODE_ENV=production npm run build | |
if [ $? -ne 0 ]; then | |
echo "Build failed" | |
exit 1 | |
fi | |
- name: Validate Extension Files | |
run: | | |
# Check required files exist | |
required_files=("manifest.json" "popup/index.html" "background/background.js" "assets/icons/icon16.png" "assets/icons/icon48.png" "assets/icons/icon128.png") | |
for file in "${required_files[@]}"; do | |
if [ ! -f "dist/$file" ]; then | |
echo "Error: Required file $file is missing" | |
exit 1 | |
fi | |
done | |
# Validate manifest.json | |
if ! jq empty dist/manifest.json; then | |
echo "Error: Invalid manifest.json" | |
exit 1 | |
fi | |
# Check manifest version matches tag | |
if [[ "${{ github.ref }}" =~ ^refs/tags/v([0-9]+\.[0-9]+\.[0-9]+) ]]; then | |
version="${BASH_REMATCH[1]}" | |
manifest_version=$(jq -r .version dist/manifest.json) | |
if [ "$version" != "$manifest_version" ]; then | |
echo "Error: Tag version ($version) doesn't match manifest version ($manifest_version)" | |
exit 1 | |
fi | |
fi | |
echo "✓ Extension validation complete" | |
- name: Create Extension ZIP | |
if: startsWith(github.ref, 'refs/tags/') | |
run: | | |
cd dist | |
zip -r ../extension.zip * | |
cd .. | |
echo "✓ Extension ZIP created" | |
- name: Create Release | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: extension.zip | |
generate_release_notes: true | |
- name: Cleanup | |
run: | | |
rm -rf dist | |
rm -f extension.zip | |
echo "✓ Cleanup complete" | |
- name: Workflow Summary | |
run: | | |
echo "Build and validation completed successfully" | |
echo "Artifacts created and cleaned up" | |
echo "Workflow finished" |