-
Notifications
You must be signed in to change notification settings - Fork 0
92 lines (79 loc) · 2.48 KB
/
webpack.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
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"