diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..4617d82 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,82 @@ +name: Build and Deploy +run-name: ${{ github.actor }} started build action +on: + push: + branches: + - main + tags: + - 'v*.*.*' + pull_request: + branches: + - main + + # Allows to run this workflow manually from the Actions tab + workflow_dispatch: + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: '${{ github.workflow }}-${{ github.ref }}' + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Build for all browsers + run: npm run build + + - name: Upload Chrome extension artifact + uses: actions/upload-artifact@v4 + with: + name: chrome-extension + path: extension/chrome.zip + + - name: Upload Firefox extension artifact + uses: actions/upload-artifact@v4 + with: + name: firefox-extension + path: extension/firefox.xpi + + deploy: + needs: build + runs-on: ubuntu-latest + # Only deploy when a tag is pushed (e.g., v1.0.0) + if: startsWith(github.ref, 'refs/tags/v') + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Build for all browsers + run: npm run build + + - name: Deploy to extension branch + uses: peaceiris/actions-gh-pages@v4 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./extension + publish_branch: extension + keep_files: false