Skip to content

refactor(dark-page-handler, dom-observer, index): streamline dark pag… #29

refactor(dark-page-handler, dom-observer, index): streamline dark pag…

refactor(dark-page-handler, dom-observer, index): streamline dark pag… #29

Workflow file for this run

name: CI/CD
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
jobs:
test-and-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run linter
run: npm run lint
- name: Run type checking
run: npm run typecheck
- name: Run tests
run: npm test
- name: Build project
run: npm run build
publish:
if: github.ref == 'refs/heads/main'
needs: test-and-build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Check if version changed
id: version-check
run: |
current_version=$(node -p "require('./manifest.json').version")
echo "current_version=$current_version" >> $GITHUB_OUTPUT
# Get previous version from the previous commit
previous_version=$(git show HEAD~1:manifest.json | node -p "JSON.parse(require('fs').readFileSync('/dev/stdin', 'utf8')).version" 2>/dev/null || echo "0.0.0")
echo "prev_version=$previous_version" >> $GITHUB_OUTPUT
if [ "$current_version" != "$previous_version" ]; then
echo "version_changed=true" >> $GITHUB_OUTPUT
echo "Version changed from $previous_version to $current_version"
else
echo "version_changed=false" >> $GITHUB_OUTPUT
echo "Version unchanged: $current_version"
fi
- name: Build extension and source
if: steps.version-check.outputs.version_changed == 'true'
run: |
npm run build
npm run build:firefox
npm run build:source
- name: Create GitHub Release
if: steps.version-check.outputs.version_changed == 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.version-check.outputs.current_version }}
name: Release v${{ steps.version-check.outputs.current_version }}
files: |
extension.xpi
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Submit to Firefox Add-ons
if: steps.version-check.outputs.version_changed == 'true'
uses: wdzeng/firefox-addon@v1
with:
addon-guid: SimpleAutoDarkMode@public
xpi-path: extension.xpi
source-file-path: source.zip
jwt-issuer: ${{ secrets.FIREFOX_JWT_ISSUER }}
jwt-secret: ${{ secrets.FIREFOX_JWT_SECRET }}