Update workflow #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- 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 | |
locales-test: | |
name: Locales Test | |
runs-on: ubuntu-22.04 | |
needs: | |
- setup | |
defaults: | |
run: | |
working-directory: ./clients/apps/browser/ | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Testing locales - extName length | |
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 | |
- locales-test | |
env: | |
_LATEST_BROWSER_TAG: ${{ needs.setup.outputs.latest_browser_tag }} | |
_NODE_VERSION: ${{ needs.setup.outputs.node_version }} | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- 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@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 | |
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" | |
cp images/* "$repo_dir/apps/browser/src/images/" | |
# 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: Upload Opera artifact | |
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | |
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 (DO NOT USE FOR PROD) | |
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | |
with: | |
name: DO-NOT-USE-FOR-PROD-dist-opera-MV3-${{ env._LATEST_BROWSER_TAG }}.zip | |
path: ./clients/browser-source/apps/browser/dist/dist-opera-mv3.zip | |
if-no-files-found: error | |
- name: Upload Chrome MV3 artifact | |
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | |
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@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | |
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@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | |
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 Firefox MV3 artifact (DO NOT USE FOR PROD) | |
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | |
with: | |
name: DO-NOT-USE-FOR-PROD-dist-firefox-MV3-${{ env._LATEST_BROWSER_TAG }}.zip | |
path: ./clients/browser-source/apps/browser/dist/dist-firefox-mv3.zip | |
if-no-files-found: error | |
- name: Upload Edge artifact | |
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | |
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 (DO NOT USE FOR PROD) | |
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | |
with: | |
name: DO-NOT-USE-FOR-PROD-dist-edge-MV3-${{ env._LATEST_BROWSER_TAG }}.zip | |
path: ./clients/browser-source/apps/browser/dist/dist-edge-mv3.zip | |
if-no-files-found: error | |
- name: Upload browser source | |
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 | |
with: | |
name: browser-source-${{ env._LATEST_BROWSER_TAG }}.zip | |
path: ./clients/browser-source.zip | |
if-no-files-found: error | |
- 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 | |
makeLatest: true |