Skip to content

Commit 4697e03

Browse files
committed
Add publishing to CI/CD Pipeline
1 parent 66e2e93 commit 4697e03

File tree

5 files changed

+408
-119
lines changed

5 files changed

+408
-119
lines changed

.github/workflows/ci-cd.yml

Lines changed: 165 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -2,151 +2,199 @@ name: CI/CD Pipeline
22

33
on:
44
push:
5-
branches: [ main, develop ]
5+
branches: [main, develop]
66
pull_request:
7-
branches: [ main ]
7+
branches: [main]
88
release:
9-
types: [ published ]
9+
types: [published]
1010

1111
jobs:
1212
test:
1313
runs-on: ubuntu-latest
14-
14+
1515
strategy:
1616
matrix:
1717
node-version: [20.x]
18-
18+
1919
steps:
20-
- name: Checkout code
21-
uses: actions/checkout@v4
22-
23-
- name: Setup Node.js ${{ matrix.node-version }}
24-
uses: actions/setup-node@v4
25-
with:
26-
node-version: ${{ matrix.node-version }}
27-
cache: 'npm'
28-
29-
- name: Install dependencies
30-
run: npm ci --ignore-scripts
31-
32-
- name: Run linting
33-
run: npm run lint
34-
35-
- name: Run type checking
36-
run: npm run typecheck
37-
38-
- name: Run tests
39-
run: npm test
40-
41-
- name: Build extension
42-
run: npm run build
43-
44-
- name: Build Firefox version
45-
run: npm run build:firefox
46-
47-
- name: Create packages
48-
run: npm run package:all-formats
49-
50-
- name: Upload artifacts
51-
uses: actions/upload-artifact@v4
52-
with:
53-
name: extension-packages-${{ matrix.node-version }}
54-
path: |
55-
*.zip
56-
*.crx
57-
*.xpi
58-
retention-days: 30
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Setup Node.js ${{ matrix.node-version }}
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: ${{ matrix.node-version }}
27+
cache: 'npm'
28+
29+
- name: Install dependencies
30+
run: npm ci --ignore-scripts
31+
32+
- name: Run linting
33+
run: npm run lint
34+
35+
- name: Run type checking
36+
run: npm run typecheck
37+
38+
- name: Run tests
39+
run: npm test
40+
41+
- name: Build extension
42+
run: npm run build
43+
44+
- name: Build Firefox version
45+
run: npm run build:firefox
46+
47+
- name: Create packages
48+
run: npm run package:all-formats
49+
50+
- name: Upload artifacts
51+
uses: actions/upload-artifact@v4
52+
with:
53+
name: extension-packages-${{ matrix.node-version }}
54+
path: |
55+
*.zip
56+
*.crx
57+
*.xpi
58+
retention-days: 30
5959

6060
security-scan:
6161
runs-on: ubuntu-latest
6262
steps:
63-
- name: Checkout code
64-
uses: actions/checkout@v4
65-
66-
- name: Setup Node.js
67-
uses: actions/setup-node@v4
68-
with:
69-
node-version: '20.x'
70-
cache: 'npm'
71-
72-
- name: Install dependencies
73-
run: npm ci --ignore-scripts
74-
75-
- name: Run security audit
76-
run: npm audit --audit-level=moderate
77-
78-
- name: Generate security report
79-
run: |
80-
echo "Security audit completed"
81-
npm audit --audit-level=moderate --json > security-report.json || true
82-
echo "Security report generated"
63+
- name: Checkout code
64+
uses: actions/checkout@v4
65+
66+
- name: Setup Node.js
67+
uses: actions/setup-node@v4
68+
with:
69+
node-version: '20.x'
70+
cache: 'npm'
71+
72+
- name: Install dependencies
73+
run: npm ci --ignore-scripts
74+
75+
- name: Run security audit
76+
run: npm audit --audit-level=moderate
77+
78+
- name: Generate security report
79+
run: |
80+
echo "Security audit completed"
81+
npm audit --audit-level=moderate --json > security-report.json || true
82+
echo "Security report generated"
8383
8484
release:
8585
needs: [test, security-scan]
8686
runs-on: ubuntu-latest
8787
if: github.event_name == 'release'
88-
88+
8989
steps:
90-
- name: Checkout code
91-
uses: actions/checkout@v4
92-
93-
- name: Setup Node.js
94-
uses: actions/setup-node@v4
95-
with:
96-
node-version: '20.x'
97-
cache: 'npm'
98-
99-
- name: Install dependencies
100-
run: npm ci --ignore-scripts
101-
102-
- name: Build and package
103-
run: |
104-
npm run build
105-
npm run build:firefox
106-
npm run package:all-formats
107-
108-
- name: Upload release assets
109-
uses: softprops/action-gh-release@v1
110-
with:
111-
files: |
112-
*.zip
113-
*.crx
114-
*.xpi
115-
env:
116-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90+
- name: Checkout code
91+
uses: actions/checkout@v4
92+
93+
- name: Setup Node.js
94+
uses: actions/setup-node@v4
95+
with:
96+
node-version: '20.x'
97+
cache: 'npm'
98+
99+
- name: Install dependencies
100+
run: npm ci --ignore-scripts
101+
102+
- name: Build and package
103+
run: |
104+
npm run build
105+
npm run build:firefox
106+
npm run package:all-formats
107+
108+
- name: Upload release assets
109+
uses: softprops/action-gh-release@v1
110+
with:
111+
files: |
112+
*.zip
113+
*.crx
114+
*.xpi
115+
env:
116+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
117117

118118
deploy-stores:
119119
needs: [test, security-scan]
120120
runs-on: ubuntu-latest
121-
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
122-
121+
if: github.event_name == 'release'
122+
123123
steps:
124-
- name: Checkout code
125-
uses: actions/checkout@v4
126-
127-
- name: Setup Node.js
128-
uses: actions/setup-node@v4
124+
- name: Checkout code
125+
uses: actions/checkout@v4
126+
127+
- name: Setup Node.js
128+
uses: actions/setup-node@v4
129+
with:
130+
node-version: '20.x'
131+
cache: 'npm'
132+
133+
- name: Install dependencies
134+
run: npm ci --ignore-scripts
135+
136+
- name: Build and package
137+
run: |
138+
npm run build
139+
npm run build:firefox
140+
npm run package:all-formats
141+
142+
- name: Deploy to Chrome Web Store
143+
uses: PlasmoHQ/bpp@v2
144+
with:
145+
keys: ${{ secrets.CHROME_CLIENT_ID }}:${{ secrets.CHROME_CLIENT_SECRET }}:${{ secrets.CHROME_REFRESH_TOKEN }}
146+
zip: blog-link-analyzer-*.zip
147+
extension-id: ${{ secrets.CHROME_EXTENSION_ID }}
148+
149+
- name: Deploy to Firefox Add-ons
150+
uses: firefox-devtools/firefox-addon-submit@v1
129151
with:
130-
node-version: '20.x'
131-
cache: 'npm'
152+
api-key: ${{ secrets.FIREFOX_JWT_ISSUER }}
153+
api-secret: ${{ secrets.FIREFOX_JWT_SECRET }}
154+
xpi: blog-link-analyzer-firefox-*.xpi
132155

133-
- name: Install dependencies
134-
run: npm ci --ignore-scripts
135-
136-
- name: Build and package
156+
- name: Notify deployment success
157+
if: success()
158+
uses: actions/github-script@v7
159+
with:
160+
script: |
161+
github.rest.issues.createComment({
162+
issue_number: context.issue.number,
163+
owner: context.repo.owner,
164+
repo: context.repo.repo,
165+
body: '🚀 **Store Deployment Successful**\n\n✅ Chrome Web Store: Submitted for review\n✅ Firefox Add-ons: Submitted for review\n\nRelease: ${{ github.event.release.tag_name }}'
166+
})
167+
168+
- name: Notify deployment failure
169+
if: failure()
170+
uses: actions/github-script@v7
171+
with:
172+
script: |
173+
github.rest.issues.createComment({
174+
issue_number: context.issue.number,
175+
owner: context.repo.owner,
176+
repo: context.repo.repo,
177+
body: '❌ **Store Deployment Failed**\n\nPlease check the workflow logs for details.\nRelease: ${{ github.event.release.tag_name }}\n\nTo rollback, run:\n```bash\n./scripts/rollback.sh latest chrome,firefox\n```'
178+
})
179+
180+
- name: Store deployment metadata
181+
if: success()
137182
run: |
138-
npm run build
139-
npm run build:firefox
140-
npm run package:all-formats
183+
echo "DEPLOYMENT_VERSION=${{ github.event.release.tag_name }}" >> deployment.env
184+
echo "DEPLOYMENT_TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> deployment.env
185+
echo "CHROME_PACKAGE=blog-link-analyzer-$(node -p "require('./package.json').version").zip" >> deployment.env
186+
echo "FIREFOX_PACKAGE=blog-link-analyzer-firefox-$(node -p "require('./package.json').version").xpi" >> deployment.env
141187
142-
- name: Deploy to Chrome Web Store
143-
run: |
144-
echo "Chrome Web Store deployment would go here"
145-
echo "Package: blog-link-analyzer-*.zip"
146-
echo "Configure with Chrome Web Store API credentials"
188+
- name: Upload deployment metadata
189+
if: success()
190+
uses: actions/upload-artifact@v4
191+
with:
192+
name: deployment-metadata-${{ github.event.release.tag_name }}
193+
path: deployment.env
194+
retention-days: 90
147195

148-
- name: Deploy to Firefox Add-ons
196+
- name: Validate deployment
197+
if: success()
149198
run: |
150-
echo "Firefox Add-ons deployment would go here"
151-
echo "Package: blog-link-analyzer-firefox-*.xpi"
152-
echo "Configure with Firefox Add-ons API credentials"
199+
chmod +x scripts/validate-deployment.sh
200+
./scripts/validate-deployment.sh

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
www.lesswrong.com.har
2-
*.pem
2+
*.pem
3+
STORE_DEPLOYMENT_CREDENTIALS.md
4+
DEPLOYMENT_ENVIRONMENT.md

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@
3636
"pre-deploy": "./scripts/pre-deploy.sh",
3737
"deploy:chrome": "echo 'Upload blog-link-analyzer-$(node -p \"require(\\\"./package.json\\\").version\").zip to Chrome Web Store'",
3838
"deploy:firefox": "echo 'Upload blog-link-analyzer-firefox-$(node -p \"require(\\\"./package.json\\\").version\").zip to Firefox Add-ons'",
39-
"deploy:all": "npm run deploy:chrome && npm run deploy:firefox"
39+
"deploy:all": "npm run deploy:chrome && npm run deploy:firefox",
40+
"deploy:validate": "./scripts/validate-deployment.sh",
41+
"deploy:rollback": "./scripts/rollback.sh",
42+
"deploy:rollback:chrome": "./scripts/rollback.sh latest chrome",
43+
"deploy:rollback:firefox": "./scripts/rollback.sh latest firefox"
4044
},
4145
"keywords": [
4246
"blog",

0 commit comments

Comments
 (0)