Skip to content

Commit 1a4f140

Browse files
committed
Add workflow
1 parent 963a131 commit 1a4f140

File tree

4 files changed

+317
-1
lines changed

4 files changed

+317
-1
lines changed

.github/workflows/ci.yml

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
name: CI - Validate Extension
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
validate:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Validate manifest.json
18+
run: |
19+
echo "Validating manifest.json..."
20+
if ! jq empty src/manifest.json; then
21+
echo "❌ manifest.json is not valid JSON"
22+
exit 1
23+
fi
24+
echo "✅ manifest.json is valid JSON"
25+
26+
- name: Check required manifest fields
27+
run: |
28+
echo "Checking required manifest fields..."
29+
30+
# Check manifest version
31+
if ! jq -e '.manifest_version' src/manifest.json > /dev/null; then
32+
echo "❌ Missing manifest_version"
33+
exit 1
34+
fi
35+
36+
# Check name
37+
if ! jq -e '.name' src/manifest.json > /dev/null; then
38+
echo "❌ Missing name"
39+
exit 1
40+
fi
41+
42+
# Check version
43+
if ! jq -e '.version' src/manifest.json > /dev/null; then
44+
echo "❌ Missing version"
45+
exit 1
46+
fi
47+
48+
# Check description
49+
if ! jq -e '.description' src/manifest.json > /dev/null; then
50+
echo "❌ Missing description"
51+
exit 1
52+
fi
53+
54+
echo "✅ All required manifest fields present"
55+
56+
- name: Validate file structure
57+
run: |
58+
echo "Checking file structure..."
59+
60+
# Check for required files
61+
required_files=(
62+
"src/manifest.json"
63+
"src/background.js"
64+
"src/content.js"
65+
"src/popup.html"
66+
"src/popup.js"
67+
)
68+
69+
for file in "${required_files[@]}"; do
70+
if [ ! -f "$file" ]; then
71+
echo "❌ Missing required file: $file"
72+
exit 1
73+
fi
74+
done
75+
76+
echo "✅ All required files present"
77+
78+
- name: Check for icon files
79+
run: |
80+
echo "Checking for icon files..."
81+
82+
icon_files=(
83+
"src/assets/icon16.png"
84+
"src/assets/icon48.png"
85+
"src/assets/icon128.png"
86+
)
87+
88+
for file in "${icon_files[@]}"; do
89+
if [ ! -f "$file" ]; then
90+
echo "❌ Missing icon file: $file"
91+
exit 1
92+
fi
93+
done
94+
95+
echo "✅ All icon files present"
96+
97+
- name: Test extension package creation
98+
run: |
99+
echo "Testing extension package creation..."
100+
cd src
101+
zip -r ../test-package.zip . -x "README.md" "assets/README.md"
102+
cd ..
103+
104+
# Verify the package was created
105+
if [ ! -f "test-package.zip" ]; then
106+
echo "❌ Failed to create package"
107+
exit 1
108+
fi
109+
110+
# Check package size (should be reasonable)
111+
size=$(wc -c < test-package.zip)
112+
if [ $size -gt 10485760 ]; then # 10MB limit
113+
echo "❌ Package too large: ${size} bytes"
114+
exit 1
115+
fi
116+
117+
echo "✅ Package created successfully (${size} bytes)"
118+
119+
- name: Validate JavaScript syntax
120+
run: |
121+
echo "Validating JavaScript files..."
122+
123+
# Install Node.js for syntax checking
124+
sudo apt-get update
125+
sudo apt-get install -y nodejs
126+
127+
# Check each JS file
128+
js_files=(
129+
"src/background.js"
130+
"src/content.js"
131+
"src/popup.js"
132+
)
133+
134+
for file in "${js_files[@]}"; do
135+
echo "Checking $file..."
136+
if ! node -c "$file"; then
137+
echo "❌ Syntax error in $file"
138+
exit 1
139+
fi
140+
done
141+
142+
echo "✅ All JavaScript files have valid syntax"
143+
144+
- name: Generate build info
145+
run: |
146+
echo "Extension Build Information:" > build-info.txt
147+
echo "==========================" >> build-info.txt
148+
echo "Commit: $GITHUB_SHA" >> build-info.txt
149+
echo "Branch: $GITHUB_REF_NAME" >> build-info.txt
150+
echo "Build Date: $(date -u)" >> build-info.txt
151+
echo "Extension Version: $(jq -r '.version' src/manifest.json)" >> build-info.txt
152+
echo "Manifest Version: $(jq -r '.manifest_version' src/manifest.json)" >> build-info.txt
153+
154+
cat build-info.txt
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Create Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Release version (e.g., v1.0.0)'
8+
required: true
9+
type: string
10+
release_notes:
11+
description: 'Release notes'
12+
required: false
13+
type: string
14+
default: 'New release with bug fixes and improvements'
15+
16+
jobs:
17+
create-release:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Validate version format
25+
run: |
26+
if [[ ! "${{ github.event.inputs.version }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
27+
echo "❌ Version must be in format v1.0.0"
28+
exit 1
29+
fi
30+
echo "✅ Version format is valid"
31+
32+
- name: Update manifest version
33+
run: |
34+
VERSION="${{ github.event.inputs.version }}"
35+
VERSION_NO_V="${VERSION#v}" # Remove 'v' prefix
36+
37+
# Update manifest.json
38+
jq --arg version "$VERSION_NO_V" '.version = $version' src/manifest.json > temp.json
39+
mv temp.json src/manifest.json
40+
41+
echo "Updated manifest.json to version $VERSION_NO_V"
42+
43+
- name: Update CHANGELOG.md
44+
run: |
45+
VERSION="${{ github.event.inputs.version }}"
46+
VERSION_NO_V="${VERSION#v}"
47+
DATE=$(date +%Y-%m-%d)
48+
49+
# Create new changelog entry
50+
{
51+
echo "# Changelog"
52+
echo ""
53+
echo "## [$VERSION_NO_V] - $DATE"
54+
echo ""
55+
echo "${{ github.event.inputs.release_notes }}"
56+
echo ""
57+
tail -n +3 CHANGELOG.md
58+
} > temp_changelog.md
59+
60+
mv temp_changelog.md CHANGELOG.md
61+
62+
echo "Updated CHANGELOG.md"
63+
64+
- name: Commit version changes
65+
run: |
66+
git config --local user.email "[email protected]"
67+
git config --local user.name "GitHub Action"
68+
git add src/manifest.json CHANGELOG.md
69+
git commit -m "Release ${{ github.event.inputs.version }}"
70+
git push
71+
72+
- name: Create Release
73+
uses: actions/create-release@v1
74+
env:
75+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76+
with:
77+
tag_name: ${{ github.event.inputs.version }}
78+
release_name: BlazorSnap ${{ github.event.inputs.version }}
79+
body: |
80+
## What's New in ${{ github.event.inputs.version }}
81+
82+
${{ github.event.inputs.release_notes }}
83+
84+
## Installation
85+
86+
### For Users
87+
1. Download the `BlazorSnap-store-v*.zip` file below
88+
2. Extract it to a folder
89+
3. Open Chrome/Edge and go to `chrome://extensions/` or `edge://extensions/`
90+
4. Enable "Developer mode"
91+
5. Click "Load unpacked" and select the extracted folder
92+
93+
### For Developers
94+
Download the `BlazorSnap-v*.zip` file which includes all source files and documentation.
95+
96+
## Chrome Web Store
97+
This extension is also available on the Chrome Web Store: [Coming Soon]
98+
99+
---
100+
101+
**Full Changelog**: https://github.com/${{ github.repository }}/blob/main/CHANGELOG.md
102+
draft: false
103+
prerelease: false

.github/workflows/release.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Build and Release Extension
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build-and-release:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
15+
- name: Get version from manifest
16+
id: get_version
17+
run: |
18+
VERSION=$(grep '"version"' src/manifest.json | sed 's/.*"version": "\(.*\)".*/\1/')
19+
echo "version=$VERSION" >> $GITHUB_OUTPUT
20+
echo "Extension version: $VERSION"
21+
22+
- name: Create extension package
23+
run: |
24+
cd src
25+
zip -r ../BlazorSnap-v${{ steps.get_version.outputs.version }}.zip . -x "README.md"
26+
cd ..
27+
28+
- name: Verify package contents
29+
run: |
30+
echo "Package contents:"
31+
unzip -l BlazorSnap-v${{ steps.get_version.outputs.version }}.zip
32+
33+
- name: Upload release asset
34+
uses: actions/upload-release-asset@v1
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
with:
38+
upload_url: ${{ github.event.release.upload_url }}
39+
asset_path: ./BlazorSnap-v${{ steps.get_version.outputs.version }}.zip
40+
asset_name: BlazorSnap-v${{ steps.get_version.outputs.version }}.zip
41+
asset_content_type: application/zip
42+
43+
- name: Create Chrome Web Store package
44+
run: |
45+
cd src
46+
# Remove the README.md from assets folder for store submission
47+
rm -f assets/README.md
48+
zip -r ../BlazorSnap-store-v${{ steps.get_version.outputs.version }}.zip .
49+
cd ..
50+
51+
- name: Upload Chrome Web Store package
52+
uses: actions/upload-release-asset@v1
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
with:
56+
upload_url: ${{ github.event.release.upload_url }}
57+
asset_path: ./BlazorSnap-store-v${{ steps.get_version.outputs.version }}.zip
58+
asset_name: BlazorSnap-store-v${{ steps.get_version.outputs.version }}.zip
59+
asset_content_type: application/zip

src/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 3,
33
"name": "BlazorSnap",
44
"description": "Convert any HTML element into a reusable Blazor component stub",
5-
"version": "1.0.0",
5+
"version": "0.0.1",
66
"permissions": [
77
"contextMenus",
88
"scripting",

0 commit comments

Comments
 (0)