Skip to content

Build Browser

Build Browser #93

Workflow file for this run

# https://github.com/bitwarden/clients/blob/main/.github/workflows/build-browser.yml
---
name: Build Browser
on:
workflow_call:
inputs: {}
workflow_dispatch:
inputs: {}
push:
branches: [master, main]
schedule:
# On every Sunday 12:00
- cron: "0 12 * * 0"
permissions:
contents: write # To Release
defaults:
run:
shell: bash
jobs:
setup:
name: Setup
runs-on: ubuntu-22.04
outputs:
latest_browser_tag: ${{ steps.gen_vars.outputs.latest_browser_tag }}
node_version: ${{ steps.retrieve-node-version.outputs.node_version }}
steps:
- name: Checkout repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Clone real repo
run: |
git clone https://github.com/bitwarden/clients.git
- name: Get Latest Browser Tag
id: gen_vars
working-directory: ./clients
run: |
# Find all tags and sort by time
git fetch --tags
tags=$(git tag --sort=-creatordate)
# Find "browser" tag
latest_browser_tag=""
for tag in $tags; do
if [[ $tag == *"browser"* ]]; then
latest_browser_tag=$tag
break
fi
done
echo "latest_browser_tag=$latest_browser_tag" >> $GITHUB_OUTPUT
echo "latest_browser_tag=$latest_browser_tag"
- name: Get Node Version
id: retrieve-node-version
working-directory: ./clients
run: |
NODE_NVMRC=$(cat .nvmrc)
NODE_VERSION=${NODE_NVMRC/v/''}
echo "node_version=$NODE_VERSION" >> $GITHUB_OUTPUT
# - name: Testing locales - extName length
# working-directory: ./clients/apps/browser/
# continue-on-error: true
# run: |
# found_error=false
# echo "Locales Test"
# echo "============"
# echo "extName string must be 40 characters or less"
# echo
# for locale in $(ls src/_locales/); do
# string_length=$(jq '.extName.message | length' src/_locales/$locale/messages.json)
# if [[ $string_length -gt 40 ]]; then
# echo "$locale: $string_length"
# found_error=true
# fi
# done
# if $found_error; then
# echo
# echo "Please fix 'extName' for the locales listed above."
# exit 1
# else
# echo "Test passed!"
# fi
build:
name: Build
runs-on: ubuntu-22.04
needs:
- setup
env:
_LATEST_BROWSER_TAG: ${{ needs.setup.outputs.latest_browser_tag }}
_NODE_VERSION: ${{ needs.setup.outputs.node_version }}
steps:
- name: Checkout repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Clone real repo
run: |
git clone https://github.com/bitwarden/clients.git
- name: Setup repo
working-directory: ./clients
run: |
git fetch --tags
echo "Checking out ${{ env._LATEST_BROWSER_TAG }}"
git checkout ${{ env._LATEST_BROWSER_TAG }}
- name: Set up Node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
cache: "npm"
cache-dependency-path: "**/package-lock.json"
node-version: ${{ env._NODE_VERSION }}
- name: Print environment
run: |
node --version
npm --version
- name: Apply internal patch
run: |
# To create a patch, git diff > mypatch.patch
repo_dir="clients"
patches_dir="patches"
cp -r $patches_dir/* .
cp fakePremium.patch "$repo_dir"
# Python script before cd
python patchManifestV3.py
python patchManifestV2.py
cd "$repo_dir"
git apply fakePremium.patch -v
- name: Build sources for reviewers
working-directory: ./clients
run: |
# Include hidden files in glob copy
shopt -s dotglob
# Remove ".git" directory
rm -r .git
# Copy root level files to source directory
mkdir browser-source
FILES=$(find . -maxdepth 1 -type f)
for FILE in $FILES; do cp "$FILE" browser-source/; done
# Copy patches to the Browser source directory
mkdir -p browser-source/patches
cp -r patches/* browser-source/patches
# Copy apps/browser to the Browser source directory
mkdir -p browser-source/apps/browser
cp -r apps/browser/* browser-source/apps/browser
# Copy libs to Browser source directory
mkdir browser-source/libs
cp -r libs/* browser-source/libs
zip -r browser-source.zip browser-source
- name: NPM setup
run: npm ci
working-directory: ./clients/browser-source/
- name: Build
run: npm run dist
working-directory: ./clients/browser-source/apps/browser
- name: Build Manifest v3
run: npm run dist:mv3
working-directory: ./clients/browser-source/apps/browser
- name: Build Chrome Manifest v3 Beta
run: npm run dist:chrome:beta
working-directory: ./clients/browser-source/apps/browser
- name: Gulp
run: gulp ci
working-directory: ./clients/browser-source/apps/browser
- name: Upload Opera artifact
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: dist-opera-${{ env._LATEST_BROWSER_TAG }}.zip
path: ./clients/browser-source/apps/browser/dist/dist-opera.zip
if-no-files-found: error
# - name: Upload Opera MV3 artifact
# uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
# with:
# name: dist-opera-MV3-${{ env._LATEST_BROWSER_TAG }}.zip
# path: browser-source/apps/browser/dist/dist-opera-mv3.zip
# if-no-files-found: error
- name: Upload Chrome MV3 artifact
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: dist-chrome-MV3-${{ env._LATEST_BROWSER_TAG }}.zip
path: ./clients/browser-source/apps/browser/dist/dist-chrome-mv3.zip
if-no-files-found: error
- name: Upload Chrome MV3 Beta artifact (DO NOT USE FOR PROD)
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: DO-NOT-USE-FOR-PROD-dist-chrome-MV3-beta-${{ env._LATEST_BROWSER_TAG }}.zip
path: ./clients/browser-source/apps/browser/dist/dist-chrome-mv3-beta.zip
if-no-files-found: error
- name: Upload Firefox artifact
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: dist-firefox-${{ env._LATEST_BROWSER_TAG }}.zip
path: ./clients/browser-source/apps/browser/dist/dist-firefox.zip
if-no-files-found: error
- name: Upload Edge artifact
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: dist-edge-${{ env._LATEST_BROWSER_TAG }}.zip
path: ./clients/browser-source/apps/browser/dist/dist-edge.zip
if-no-files-found: error
# - name: Upload Edge MV3 artifact
# uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
# with:
# name: dist-edge-MV3-${{ env._LATEST_BROWSER_TAG }}.zip
# path: browser-source/apps/browser/dist/dist-edge-mv3.zip
# if-no-files-found: error
- name: Upload browser source
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
name: browser-source-${{ env._LATEST_BROWSER_TAG }}.zip
path: ./clients/browser-source.zip
if-no-files-found: error
# - name: Upload coverage artifact
# if: false
# uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
# with:
# name: coverage-${{ env._LATEST_BROWSER_TAG }}.zip
# path: ./clients/browser-source/apps/browser/coverage/coverage-${{ env._LATEST_BROWSER_TAG }}.zip
# if-no-files-found: error
# - name: Upload Release
# uses: marvinpinto/action-automatic-releases@d68defdd11f9dcc7f52f35c1b7c236ee7513bcc1 # Last commit before archived
# continue-on-error: true
# if: success()
# with:
# repo_token: "${{ secrets.GITHUB_TOKEN }}"
# automatic_release_tag: "${{ env._LATEST_BROWSER_TAG }}"
# prerelease: false
# title: "${{ env._LATEST_BROWSER_TAG }}"
# files: |
# ./clients/browser-source/apps/browser/dist/*
# ./clients/browser-source.zip
- name: Create release
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0
with:
artifacts: "./clients/browser-source/apps/browser/dist/*,./clients/browser-source.zip"
tag: "${{ env._LATEST_BROWSER_TAG }}"
name: "${{ env._LATEST_BROWSER_TAG }}"
body: "${{ env._LATEST_BROWSER_TAG }} [Original Changelog](https://github.com/bitwarden/clients/releases/tag/${{ env._LATEST_BROWSER_TAG }})"
token: ${{ secrets.GITHUB_TOKEN }}
draft: false
allowUpdates: true