Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Refactor browser extension build to reusable workflow (#887)

Leendert de Borst22aaf17cd1f9
diff --git a/.github/actions/build-browser-extension/action.yml b/.github/actions/build-browser-extension/action.yml
new file mode 100644
index 000000000..64b9b6233
--- /dev/null
+++ b/.github/actions/build-browser-extension/action.yml
@@ -0,0 +1,93 @@
+name: "Build Browser Extension"
+description: "Builds, tests, lints, zips, and optionally uploads a browser extension"
+inputs:
+ browser:
+ description: "Target browser to build for (chrome, firefox, edge)"
+ required: true
+ upload_to_release:
+ description: "Whether to upload the resulting zip to GitHub Release"
+ required: false
+ default: "false"
+
+runs:
+ using: "composite"
+ steps:
+ - uses: actions/setup-node@v4
+ with:
+ node-version: '20'
+ cache: 'npm'
+ cache-dependency-path: apps/browser-extension/package-lock.json
+
+ - name: Install dependencies
+ run: npm ci
+ shell: bash
+ working-directory: apps/browser-extension
+
+ - name: Build extension
+ run: npm run build:${{ inputs.browser }}
+ shell: bash
+ working-directory: apps/browser-extension
+
+ - name: Run tests
+ run: npm run test
+ shell: bash
+ working-directory: apps/browser-extension
+
+ - name: Run linting
+ run: npm run lint
+ shell: bash
+ working-directory: apps/browser-extension
+
+ - name: Zip Extension
+ run: npm run zip:${{ inputs.browser }}
+ shell: bash
+ working-directory: apps/browser-extension
+
+ - name: Rename zip with semver
+ run: |
+ VERSION=$(node -p "require('./package.json').version")
+ echo "VERSION=$VERSION" >> $GITHUB_ENV
+ mv dist/aliasvault-browser-extension-*-${{ inputs.browser }}.zip dist/aliasvault-browser-extension-${VERSION}-${{ inputs.browser }}.zip
+ shell: bash
+ working-directory: apps/browser-extension
+
+ - name: Unzip extension
+ run: |
+ mkdir -p dist/${{ inputs.browser }}-unpacked
+ unzip dist/aliasvault-browser-extension-${VERSION}-${{ inputs.browser }}.zip -d dist/${{ inputs.browser }}-unpacked
+ shell: bash
+ working-directory: apps/browser-extension
+
+ - name: Upload artifact
+ uses: actions/upload-artifact@v4
+ with:
+ name: aliasvault-browser-extension-${{ inputs.browser }}-${{ env.VERSION }}
+ path: apps/browser-extension/dist/${{ inputs.browser }}-unpacked
+
+ - name: Unzip and upload Firefox sources
+ if: ${{ inputs.browser == 'firefox' }}
+ run: |
+ mkdir -p dist/sources-unpacked
+ unzip dist/aliasvault-browser-extension-${VERSION}-sources.zip -d dist/sources-unpacked
+ shell: bash
+ working-directory: apps/browser-extension
+
+ - name: Upload Firefox sources artifact
+ if: ${{ inputs.browser == 'firefox' }}
+ uses: actions/upload-artifact@v4
+ with:
+ name: aliasvault-browser-extension-sources-${{ env.VERSION }}
+ path: apps/browser-extension/dist/sources-unpacked
+
+ - name: Upload to GitHub Release
+ if: ${{ inputs.upload_to_release == 'true' }}
+ uses: softprops/action-gh-release@v1
+ with:
+ files: |
+ apps/browser-extension/dist/aliasvault-browser-extension-${{ env.VERSION }}-${{ inputs.browser }}.zip
+
+ - name: Upload Firefox sources to Release
+ if: ${{ inputs.upload_to_release == 'true' && inputs.browser == 'firefox' }}
+ uses: softprops/action-gh-release@v1
+ with:
+ files: apps/browser-extension/dist/aliasvault-browser-extension-${{ env.VERSION }}-sources.zip
diff --git a/.github/workflows/browser-extension-build.yml b/.github/workflows/browser-extension-build.yml
index cdbfbb594..872a684a8 100644
--- a/.github/workflows/browser-extension-build.yml
+++ b/.github/workflows/browser-extension-build.yml
@@ -63,157 +63,32 @@ jobs:
build-chrome-extension:
needs: build-shared-libraries
runs-on: ubuntu-latest
- defaults:
- run:
- working-directory: apps/browser-extension
-
steps:
- uses: actions/checkout@v4
- - name: Get short SHA
- id: vars
- run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
-
- - name: Setup Node.js
- uses: actions/setup-node@v4
- with:
- node-version: '20'
- cache: 'npm'
- cache-dependency-path: apps/browser-extension/package-lock.json
-
- - name: Install dependencies
- run: npm ci
-
- - name: Build extension
- run: npm run build:chrome
-
- - name: Run tests
- run: npm run test
-
- - name: Run linting
- run: npm run lint
-
- - name: Zip Chrome Extension
- run: npm run zip:chrome
-
- - name: Unzip for artifact
- run: |
- mkdir -p dist/chrome-unpacked
- unzip dist/aliasvault-browser-extension-*-chrome.zip -d dist/chrome-unpacked
-
- - name: Upload dist artifact Chrome
- uses: actions/upload-artifact@v4
+ - name: Build Chrome Extension
+ uses: ./.github/actions/build-browser-extension
with:
- name: aliasvault-browser-extension-${{ github.event_name == 'release' && github.ref_name || (github.ref_name == 'main' && format('main-{0}', steps.vars.outputs.sha_short) || steps.vars.outputs.sha_short) }}-chrome
- path: apps/browser-extension/dist/chrome-unpacked
-
- outputs:
- sha_short: ${{ steps.vars.outputs.sha_short }}
+ browser: chrome
build-firefox-extension:
needs: build-shared-libraries
runs-on: ubuntu-latest
- defaults:
- run:
- working-directory: apps/browser-extension
-
steps:
- uses: actions/checkout@v4
- - name: Get short SHA
- id: vars
- run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
-
- - name: Setup Node.js
- uses: actions/setup-node@v4
+ - name: Build Firefox Extension
+ uses: ./.github/actions/build-browser-extension
with:
- node-version: '20'
- cache: 'npm'
- cache-dependency-path: apps/browser-extension/package-lock.json
-
- - name: Install dependencies
- run: npm ci
-
- - name: Build extension
- run: npm run build:firefox
-
- - name: Run tests
- run: npm run test
-
- - name: Run linting
- run: npm run lint
-
- - name: Zip Firefox Extension
- run: npm run zip:firefox
-
- - name: Unzip for artifact
- run: |
- mkdir -p dist/firefox-unpacked
- unzip dist/aliasvault-browser-extension-*-firefox.zip -d dist/firefox-unpacked
- mkdir -p dist/sources-unpacked
- unzip dist/aliasvault-browser-extension-*-sources.zip -d dist/sources-unpacked
-
- - name: Upload dist artifact Firefox
- uses: actions/upload-artifact@v4
- with:
- name: aliasvault-browser-extension-${{ github.event_name == 'release' && github.ref_name || (github.ref_name == 'main' && format('main-{0}', steps.vars.outputs.sha_short) || steps.vars.outputs.sha_short) }}-firefox
- path: apps/browser-extension/dist/firefox-unpacked
-
- - name: Upload dist artifact Firefox sources
- uses: actions/upload-artifact@v4
- with:
- name: aliasvault-browser-extension-${{ github.event_name == 'release' && github.ref_name || (github.ref_name == 'main' && format('main-{0}', steps.vars.outputs.sha_short) || steps.vars.outputs.sha_short) }}-sources
- path: apps/browser-extension/dist/sources-unpacked
-
- outputs:
- sha_short: ${{ steps.vars.outputs.sha_short }}
+ browser: firefox
build-edge-extension:
needs: build-shared-libraries
runs-on: ubuntu-latest
- defaults:
- run:
- working-directory: apps/browser-extension
-
steps:
- uses: actions/checkout@v4
- - name: Get short SHA
- id: vars
- run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
-
- - name: Setup Node.js
- uses: actions/setup-node@v4
+ - name: Build Edge Extension
+ uses: ./.github/actions/build-browser-extension
with:
- node-version: '20'
- cache: 'npm'
- cache-dependency-path: apps/browser-extension/package-lock.json
-
- - name: Install dependencies
- run: npm ci
-
- - name: Build extension
- run: npm run build:edge
-
- - name: Run tests
- run: npm run test
-
- - name: Run linting
- run: npm run lint
-
- - name: Zip Edge Extension
- run: npm run zip:edge
-
- - name: Unzip for artifact
- run: |
- mkdir -p dist/edge-unpacked
- unzip dist/aliasvault-browser-extension-*-edge.zip -d dist/edge-unpacked
-
- - name: Upload dist artifact Edge
- uses: actions/upload-artifact@v4
- with:
- name: aliasvault-browser-extension-${{ github.event_name == 'release' && github.ref_name || (github.ref_name == 'main' && format('main-{0}', steps.vars.outputs.sha_short) || steps.vars.outputs.sha_short) }}-edge
- path: apps/browser-extension/dist/edge-unpacked
-
- outputs:
- sha_short: ${{ steps.vars.outputs.sha_short }}
+ browser: edge
diff --git a/.github/workflows/builds/browser-extension.yml b/.github/workflows/builds/browser-extension.yml
new file mode 100644
index 000000000..bd2753c1a
--- /dev/null
+++ b/.github/workflows/builds/browser-extension.yml
@@ -0,0 +1,93 @@
+name: Browser Extension Build
+
+on:
+ workflow_call:
+ inputs:
+ browser:
+ required: true
+ type: string
+ upload_to_release:
+ required: false
+ type: boolean
+ default: false
+
+ outputs:
+ sha_short:
+ description: "Short SHA"
+ value: ${{ jobs.build.outputs.sha_short }}
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ defaults:
+ run:
+ working-directory: apps/browser-extension
+
+ outputs:
+ sha_short: ${{ steps.vars.outputs.sha_short }}
+
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Get short SHA
+ id: vars
+ run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
+
+ - name: Setup Node.js
+ uses: actions/setup-node@v4
+ with:
+ node-version: '20'
+ cache: 'npm'
+ cache-dependency-path: apps/browser-extension/package-lock.json
+
+ - name: Install dependencies
+ run: npm ci
+
+ - name: Build extension
+ run: npm run build:${{ inputs.browser }}
+
+ - name: Run tests
+ run: npm run test
+
+ - name: Run linting
+ run: npm run lint
+
+ - name: Zip Extension
+ run: npm run zip:${{ inputs.browser }}
+
+ - name: Unzip extension for artifact
+ run: |
+ mkdir -p dist/${{ inputs.browser }}-unpacked
+ unzip dist/aliasvault-browser-extension-*-${{ inputs.browser }}.zip -d dist/${{ inputs.browser }}-unpacked
+
+ - name: Upload dist artifact
+ uses: actions/upload-artifact@v4
+ with:
+ name: aliasvault-browser-extension-${{ github.ref_name }}-${{ inputs.browser }}
+ path: apps/browser-extension/dist/${{ inputs.browser }}-unpacked
+
+ - name: Upload to GitHub Release
+ if: ${{ inputs.upload_to_release }}
+ uses: softprops/action-gh-release@v2
+ with:
+ files: |
+ apps/browser-extension/dist/aliasvault-browser-extension-*-${{ inputs.browser }}.zip
+
+ - name: Unzip sources for Firefox (if applicable)
+ if: ${{ inputs.browser == 'firefox' }}
+ run: |
+ mkdir -p dist/sources-unpacked
+ unzip dist/aliasvault-browser-extension-*-sources.zip -d dist/sources-unpacked
+
+ - name: Upload dist artifact Firefox sources
+ if: ${{ inputs.browser == 'firefox' }}
+ uses: actions/upload-artifact@v4
+ with:
+ name: aliasvault-browser-extension-${{ github.ref_name }}-sources
+ path: apps/browser-extension/dist/sources-unpacked
+
+ - name: Upload Firefox sources to Release
+ if: ${{ inputs.browser == 'firefox' && inputs.upload_to_release }}
+ uses: softprops/action-gh-release@v2
+ with:
+ files: apps/browser-extension/dist/aliasvault-browser-extension-*-sources.zip