Skip to content

Merge pull request #203 from HunnySajid/feat/build-ci #10

Merge pull request #203 from HunnySajid/feat/build-ci

Merge pull request #203 from HunnySajid/feat/build-ci #10

Workflow file for this run

name: Build Browser Extension
on:
push:
branches:
- main
tags:
- v*
jobs:
publish:
name: Build Extension
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Build Chrome extension
run: npm run build
- name: Build Firefox extension
run: npm run build:firefox
- name: Zip Chrome folder
run: |
cd dist
zip -r chrome.zip chrome/
- name: Zip Firefox folder
run: |
cd dist
zip -r firefox.zip firefox/
- name: Get version and commit hash
id: vars
run: |
VERSION=$(cat manifest.json | jq -r .version)
SHORT_HASH=$(git rev-parse --short HEAD)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "short_hash=$SHORT_HASH" >> $GITHUB_OUTPUT
- name: Upload build asset
uses: actions/upload-artifact@v4
with:
name: v${{ steps.vars.outputs.version }}-${{ steps.vars.outputs.short_hash }}
path: dist/*.zip
- name: Remove dist folder
run: rm -rf dist
- name: Set custom workflow title
uses: actions/github-script@v6
with:
script: |
const branch = process.env.GITHUB_REF.replace('refs/heads/', '');
const version = '${{ steps.vars.outputs.version }}';
const shortHash = '${{ steps.vars.outputs.short_hash }}';
const customTitle = `v${version}-${shortHash} ${branch}`;
await github.rest.actions.updateWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.runId,
name: customTitle
});