mirror of
https://github.com/bitwarden/browser
synced 2026-02-12 22:44:11 +00:00
Switch to using tar command directly
This commit is contained in:
8
.github/workflows/build-browser.yml
vendored
8
.github/workflows/build-browser.yml
vendored
@@ -170,7 +170,7 @@ jobs:
|
||||
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
|
||||
with:
|
||||
name: dist-chrome-MV3-${{ env._BUILD_NUMBER }}.zip
|
||||
path: browser-source/apps/browser/dist/dist-chrome-mv3.zip
|
||||
path: browser-source/apps/browser/dist/dist-chrome.zip
|
||||
if-no-files-found: error
|
||||
|
||||
- name: Build Edge
|
||||
@@ -192,7 +192,7 @@ jobs:
|
||||
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
|
||||
with:
|
||||
name: DO-NOT-USE-FOR-PROD-dist-edge-MV3-${{ env._BUILD_NUMBER }}.zip
|
||||
path: browser-source/apps/browser/dist/dist-edge-mv3.zip
|
||||
path: browser-source/apps/browser/dist/dist-edge.zip
|
||||
if-no-files-found: error
|
||||
|
||||
- name: Build Firefox
|
||||
@@ -214,7 +214,7 @@ jobs:
|
||||
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
|
||||
with:
|
||||
name: DO-NOT-USE-FOR-PROD-dist-firefox-MV3-${{ env._BUILD_NUMBER }}.zip
|
||||
path: browser-source/apps/browser/dist/dist-firefox-mv3.zip
|
||||
path: browser-source/apps/browser/dist/dist-firefox.zip
|
||||
if-no-files-found: error
|
||||
|
||||
- name: Build Opera
|
||||
@@ -236,7 +236,7 @@ jobs:
|
||||
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
|
||||
with:
|
||||
name: DO-NOT-USE-FOR-PROD-dist-opera-MV3-${{ env._BUILD_NUMBER }}.zip
|
||||
path: browser-source/apps/browser/dist/dist-opera-mv3.zip
|
||||
path: browser-source/apps/browser/dist/dist-opera.zip
|
||||
if-no-files-found: error
|
||||
|
||||
build-safari:
|
||||
|
||||
@@ -9,21 +9,21 @@
|
||||
"build:opera": "cross-env BROWSER=opera webpack",
|
||||
"build:safari": "cross-env BROWSER=safari webpack",
|
||||
"build:watch": "npm run build:watch:chrome",
|
||||
"build:watch:chrome": "cross-env BROWSER=chrome MANIFEST_VERSION=3 webpack --watch",
|
||||
"build:watch:edge": "cross-env BROWSER=edge webpack --watch",
|
||||
"build:watch:firefox": "cross-env BROWSER=firefox webpack --watch",
|
||||
"build:watch:opera": "cross-env BROWSER=opera webpack --watch",
|
||||
"build:watch:safari": "cross-env BROWSER=safari webpack --watch",
|
||||
"build:watch:chrome": "npm run build:chrome -- --watch",
|
||||
"build:watch:edge": "npm run build:edge -- --watch",
|
||||
"build:watch:firefox": "npm run build:firefox -- --watch",
|
||||
"build:watch:opera": "npm run build:opera -- --watch",
|
||||
"build:watch:safari": "npm run build:safari -- --watch",
|
||||
"build:prod:chrome": "cross-env NODE_ENV=production NODE_OPTIONS=\"--max-old-space-size=4096\" npm run build:chrome",
|
||||
"build:prod:edge": "cross-env NODE_ENV=production NODE_OPTIONS=\"--max-old-space-size=4096\" npm run build:edge",
|
||||
"build:prod:firefox": "cross-env NODE_ENV=production NODE_OPTIONS=\"--max-old-space-size=4096\" npm run build:firefox",
|
||||
"build:prod:opera": "cross-env NODE_ENV=production NODE_OPTIONS=\"--max-old-space-size=4096\" npm run build:opera",
|
||||
"build:prod:safari": "cross-env NODE_ENV=production NODE_OPTIONS=\"--max-old-space-size=4096\" npm run build:safari",
|
||||
"dist:chrome": "npm run build:prod:chrome && cross-env MANIFEST_VERSION=3 ./scripts/dist.ps1 chrome",
|
||||
"dist:edge": "npm run build:prod:edge && ./scripts/dist.ps1 edge",
|
||||
"dist:firefox": "npm run build:prod:firefox && ./scripts/dist.ps1 firefox",
|
||||
"dist:opera": "npm run build:prod:opera && ./scripts/dist.ps1 opera",
|
||||
"dist:safari": "npm run build:prod:safari && ./scripts/dist.ps1 safari",
|
||||
"dist:chrome": "npm run build:prod:chrome && tar -czf dist/dist-chrome.zip ./build",
|
||||
"dist:edge": "npm run build:prod:edge && tar -czf dist/dist-edge.zip ./build",
|
||||
"dist:firefox": "npm run build:prod:firefox && tar -czf dist/dist-firefox.zip ./build",
|
||||
"dist:opera": "npm run build:prod:opera && tar -czf dist/dist-opera.zip ./build",
|
||||
"dist:safari": "npm run build:prod:safari && ./scripts/package-safari.ps1",
|
||||
"dist:edge:mv3": "cross-env MANIFEST_VERSION=3 npm run dist:edge",
|
||||
"dist:firefox:mv3": "cross-env MANIFEST_VERSION=3 npm run dist:firefox",
|
||||
"dist:opera:mv3": "cross-env MANIFEST_VERSION=3 npm run dist:opera",
|
||||
|
||||
@@ -1,156 +0,0 @@
|
||||
#!/usr/bin/env pwsh
|
||||
|
||||
####
|
||||
# Performs the last step of the build process, zipping the built files. For Mac, it also builds the safari extension.
|
||||
####
|
||||
|
||||
param (
|
||||
[Parameter(Mandatory = $false)]
|
||||
[String] $browser
|
||||
)
|
||||
|
||||
if (-not $browser) {
|
||||
$browser = $env:BROWSER
|
||||
if (-not $browser) {
|
||||
Write-Error "Missing mandatory Browser environment variable."
|
||||
exit 1
|
||||
}
|
||||
|
||||
if ($browser -notin 'chrome', 'edge', 'firefox', 'opera', 'safari') {
|
||||
Write-Error "Invalid browser specified. Valid options are: chrome, edge, firefox, opera, safari."
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
$manifestVersion = $env:MANIFEST_VERSION
|
||||
if (-not $manifestVersion) {
|
||||
$manifestVersion = 2
|
||||
}
|
||||
|
||||
$buildDir = Join-Path $PSScriptRoot "../build"
|
||||
$distDir = Join-Path $PSScriptRoot "../dist"
|
||||
|
||||
Write-Output $PSScriptRoot
|
||||
|
||||
if (-not (Test-Path $buildDir)) {
|
||||
Write-Output "No build directory found. Exiting..."
|
||||
exit
|
||||
}
|
||||
|
||||
# Create dist directory if it doesn't exist
|
||||
if (-not (Test-Path $distDir)) {
|
||||
New-Item -ItemType Directory -Path $distDir
|
||||
}
|
||||
|
||||
if ($browser -ne 'safari') {
|
||||
if ($manifestVersion -eq 2) {
|
||||
$distPath = Join-Path $distDir "dist-$browser.zip"
|
||||
}
|
||||
else {
|
||||
$distPath = Join-Path $distDir "dist-$browser-mv3.zip"
|
||||
}
|
||||
|
||||
if (Test-Path $distPath) {
|
||||
Remove-Item $distPath
|
||||
}
|
||||
|
||||
# Compress build directory
|
||||
if (Test-Path $buildDir) {
|
||||
Compress-Archive -Path $buildDir -DestinationPath $distPath
|
||||
Write-Output "Zipped $buildDir into $distPath"
|
||||
}
|
||||
}
|
||||
else {
|
||||
$subBuildPaths = @("mas", "masdev", "dmg")
|
||||
$safariSrc = Join-Path $PSScriptRoot "../src/safari"
|
||||
$safariDistPath = Join-Path -Path $distDir -ChildPath "Safari"
|
||||
|
||||
if (-not (Test-Path $safariDistPath)) {
|
||||
New-Item -ItemType Directory -Path $safariDistPath
|
||||
}
|
||||
|
||||
# Delete old safari dists
|
||||
Remove-Item -LiteralPath $safariDistPath -Force -Recurse
|
||||
|
||||
|
||||
foreach ($subBuildPath in $subBuildPaths) {
|
||||
$safariBuildPath = Join-Path -Path $safariDistPath -ChildPath $subBuildPath
|
||||
$builtAppexPath = Join-Path -Path $safariBuildPath -ChildPath "build/Release/safari.appex"
|
||||
$builtAppexFrameworkPath = Join-Path -Path $safariBuildPath -ChildPath "build/Release/safari.appex/Contents/Frameworks/"
|
||||
$entitlementsPath = Join-Path -Path $safariSrc -ChildPath "safari/safari.entitlements"
|
||||
|
||||
switch ($subBuildPath) {
|
||||
"mas" {
|
||||
$codesignArgs = @(
|
||||
"--verbose",
|
||||
"--force",
|
||||
"--sign",
|
||||
"3rd Party Mac Developer Application: Bitwarden Inc",
|
||||
"--entitlements",
|
||||
$entitlementsPath
|
||||
)
|
||||
}
|
||||
"masdev" {
|
||||
$codesignArgs = @(
|
||||
"--verbose",
|
||||
"--force",
|
||||
"--sign",
|
||||
"E7C9978F6FBCE0553429185C405E61F5380BE8EB",
|
||||
"--entitlements",
|
||||
$entitlementsPath
|
||||
)
|
||||
}
|
||||
"dmg" {
|
||||
$codesignArgs = @(
|
||||
"--verbose",
|
||||
"--force",
|
||||
"-o",
|
||||
"runtime",
|
||||
"--sign",
|
||||
"Developer ID Application: 8bit Solutions LLC",
|
||||
"--entitlements",
|
||||
$entitlementsPath
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
# Copy safari src
|
||||
Copy-Item -Path $safariSrc -Destination $safariBuildPath -Recurse
|
||||
|
||||
# Copy build
|
||||
$target = Join-Path -Path $safariBuildPath -ChildPath "safari/app"
|
||||
Copy-Item -Path $buildDir -Destination $target -Recurse
|
||||
|
||||
# Update versions
|
||||
$jsonFilePath = Join-Path $buildDir "manifest.json"
|
||||
$jsonContent = Get-Content -Path $jsonFilePath -Raw
|
||||
$jsonObject = $jsonContent | ConvertFrom-Json
|
||||
|
||||
$infoFile = Join-Path -Path $safariBuildPath -ChildPath "safari/Info.plist"
|
||||
(Get-Content $infoFile).Replace('0.0.1', $jsonObject.version).Replace('0.0.2', $jsonObject.version) | Set-Content $infoFile
|
||||
|
||||
$projectFile = Join-Path -Path $safariBuildPath -ChildPath "desktop.xcodeproj/project.pbxproj"
|
||||
(Get-Content $projectFile).Replace('../../../build', "../safari/app") | Set-Content $projectFile
|
||||
|
||||
# Build using xcode
|
||||
$xcodeBuildArgs = @(
|
||||
"-project",
|
||||
(Join-Path $safariBuildPath "desktop.xcodeproj"),
|
||||
"-alltargets",
|
||||
"-configuration",
|
||||
"Release"
|
||||
)
|
||||
$proc = Start-Process "xcodebuild" -ArgumentList $xcodeBuildArgs -NoNewWindow -PassThru
|
||||
$proc.WaitForExit()
|
||||
|
||||
# Codesign
|
||||
$libs = Get-ChildItem -Path $builtAppexFrameworkPath -Filter "*.dylib"
|
||||
foreach ($lib in $libs) {
|
||||
$proc = Start-Process "codesign" -ArgumentList ($codesignArgs + $lib.FullName) -NoNewWindow -PassThru
|
||||
$proc.WaitForExit()
|
||||
}
|
||||
|
||||
$proc = Start-Process "codesign" -ArgumentList ($codesignArgs + $builtAppexPath) -NoNewWindow -PassThru
|
||||
$proc.WaitForExit()
|
||||
}
|
||||
}
|
||||
112
apps/browser/scripts/package-safari.ps1
Executable file
112
apps/browser/scripts/package-safari.ps1
Executable file
@@ -0,0 +1,112 @@
|
||||
#!/usr/bin/env pwsh
|
||||
|
||||
####
|
||||
# Builds the safari appex.
|
||||
####
|
||||
|
||||
$buildDir = Join-Path $PSScriptRoot "../build"
|
||||
$distDir = Join-Path $PSScriptRoot "../dist"
|
||||
|
||||
Write-Output $PSScriptRoot
|
||||
|
||||
if (-not (Test-Path $buildDir)) {
|
||||
Write-Output "No build directory found. Exiting..."
|
||||
exit
|
||||
}
|
||||
|
||||
# Create dist directory if it doesn't exist
|
||||
if (-not (Test-Path $distDir)) {
|
||||
New-Item -ItemType Directory -Path $distDir
|
||||
}
|
||||
|
||||
$subBuildPaths = @("mas", "masdev", "dmg")
|
||||
$safariSrc = Join-Path $PSScriptRoot "../src/safari"
|
||||
$safariDistPath = Join-Path -Path $distDir -ChildPath "Safari"
|
||||
|
||||
if (-not (Test-Path $safariDistPath)) {
|
||||
New-Item -ItemType Directory -Path $safariDistPath
|
||||
}
|
||||
|
||||
# Delete old safari dists
|
||||
Remove-Item -LiteralPath $safariDistPath -Force -Recurse
|
||||
|
||||
foreach ($subBuildPath in $subBuildPaths) {
|
||||
$safariBuildPath = Join-Path -Path $safariDistPath -ChildPath $subBuildPath
|
||||
$builtAppexPath = Join-Path -Path $safariBuildPath -ChildPath "build/Release/safari.appex"
|
||||
$builtAppexFrameworkPath = Join-Path -Path $safariBuildPath -ChildPath "build/Release/safari.appex/Contents/Frameworks/"
|
||||
$entitlementsPath = Join-Path -Path $safariSrc -ChildPath "safari/safari.entitlements"
|
||||
|
||||
switch ($subBuildPath) {
|
||||
"mas" {
|
||||
$codesignArgs = @(
|
||||
"--verbose",
|
||||
"--force",
|
||||
"--sign",
|
||||
"3rd Party Mac Developer Application: Bitwarden Inc",
|
||||
"--entitlements",
|
||||
$entitlementsPath
|
||||
)
|
||||
}
|
||||
"masdev" {
|
||||
$codesignArgs = @(
|
||||
"--verbose",
|
||||
"--force",
|
||||
"--sign",
|
||||
"E7C9978F6FBCE0553429185C405E61F5380BE8EB",
|
||||
"--entitlements",
|
||||
$entitlementsPath
|
||||
)
|
||||
}
|
||||
"dmg" {
|
||||
$codesignArgs = @(
|
||||
"--verbose",
|
||||
"--force",
|
||||
"-o",
|
||||
"runtime",
|
||||
"--sign",
|
||||
"Developer ID Application: 8bit Solutions LLC",
|
||||
"--entitlements",
|
||||
$entitlementsPath
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
# Copy safari src
|
||||
Copy-Item -Path $safariSrc -Destination $safariBuildPath -Recurse
|
||||
|
||||
# Copy build
|
||||
$target = Join-Path -Path $safariBuildPath -ChildPath "safari/app"
|
||||
Copy-Item -Path $buildDir -Destination $target -Recurse
|
||||
|
||||
# Update versions
|
||||
$jsonFilePath = Join-Path $buildDir "manifest.json"
|
||||
$jsonContent = Get-Content -Path $jsonFilePath -Raw
|
||||
$jsonObject = $jsonContent | ConvertFrom-Json
|
||||
|
||||
$infoFile = Join-Path -Path $safariBuildPath -ChildPath "safari/Info.plist"
|
||||
(Get-Content $infoFile).Replace('0.0.1', $jsonObject.version).Replace('0.0.2', $jsonObject.version) | Set-Content $infoFile
|
||||
|
||||
$projectFile = Join-Path -Path $safariBuildPath -ChildPath "desktop.xcodeproj/project.pbxproj"
|
||||
(Get-Content $projectFile).Replace('../../../build', "../safari/app") | Set-Content $projectFile
|
||||
|
||||
# Build using xcode
|
||||
$xcodeBuildArgs = @(
|
||||
"-project",
|
||||
(Join-Path $safariBuildPath "desktop.xcodeproj"),
|
||||
"-alltargets",
|
||||
"-configuration",
|
||||
"Release"
|
||||
)
|
||||
$proc = Start-Process "xcodebuild" -ArgumentList $xcodeBuildArgs -NoNewWindow -PassThru
|
||||
$proc.WaitForExit()
|
||||
|
||||
# Codesign
|
||||
$libs = Get-ChildItem -Path $builtAppexFrameworkPath -Filter "*.dylib"
|
||||
foreach ($lib in $libs) {
|
||||
$proc = Start-Process "codesign" -ArgumentList ($codesignArgs + $lib.FullName) -NoNewWindow -PassThru
|
||||
$proc.WaitForExit()
|
||||
}
|
||||
|
||||
$proc = Start-Process "codesign" -ArgumentList ($codesignArgs + $builtAppexPath) -NoNewWindow -PassThru
|
||||
$proc.WaitForExit()
|
||||
}
|
||||
Reference in New Issue
Block a user