diff --git a/.github/scripts/macos/clean-safari.ps1 b/.github/scripts/macos/clean-safari.ps1 new file mode 100644 index 00000000..ab3a51d6 --- /dev/null +++ b/.github/scripts/macos/clean-safari.ps1 @@ -0,0 +1,8 @@ +$rootPath = $env:GITHUB_WORKSPACE; +$distDir = $rootPath + "\dist"; +$distSafariDir = $distDir + "\safari"; + +if (Test-Path -Path $distSafariDir) { + Remove-Item -Recurse -Force $distSafariDir +} +New-Item $distSafariDir -ItemType Directory -ea 0 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5a7d23fe..3ee790b4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -150,9 +150,19 @@ jobs: - name: Run linter run: npm run lint + - name: Clean safari directory + shell: pwsh + run: ./scripts/clean-safari.ps1 + + - name: Checkout browser extension + uses: actions/checkout@v2 + with: + repository: 'bitwarden/browser' + path: 'dist/safari' + - name: Build Safari extension for .dmg shell: pwsh - run: ./scripts/safari-build.ps1 + run: ./scripts/safari-build.ps1 -skipcheckout - name: Build application for .dmg run: npm run dist:mac @@ -162,7 +172,7 @@ jobs: - name: Build Safari extension for App Store shell: pwsh - run: ./scripts/safari-build.ps1 -mas + run: ./scripts/safari-build.ps1 -mas -skipcheckout - name: Build application for App Store run: npm run dist:mac:mas diff --git a/scripts/safari-build.ps1 b/scripts/safari-build.ps1 index aa33e204..afd68fd5 100644 --- a/scripts/safari-build.ps1 +++ b/scripts/safari-build.ps1 @@ -1,7 +1,8 @@ param ( [string] $version, [switch] $mas, - [switch] $masdev + [switch] $masdev, + [switch] $skipcheckout ) # Dependencies: @@ -19,18 +20,19 @@ $distSafariAppexMas = $distSafariDir + "\browser\dist\Safari\mas\build\Release\s $distSafariAppexMasDev = $distSafariDir + "\browser\dist\Safari\masdev\build\Release\safari.appex"; $pluginsAppex = $rootDir + "\PlugIns\safari.appex"; -if (Test-Path -Path $distSafariDir) { - Remove-Item -Recurse -Force $distSafariDir -} - if (Test-Path -Path $pluginsAppex) { Remove-Item -Recurse -Force $pluginsAppex } -New-Item $distSafariDir -ItemType Directory -ea 0 -cd $distSafariDir -git clone git@github.com:bitwarden/browser.git -cd browser +if(-not $skipcheckout) { + if (Test-Path -Path $distSafariDir) { + Remove-Item -Recurse -Force $distSafariDir + } + New-Item $distSafariDir -ItemType Directory -ea 0 + cd $distSafariDir + git clone git@github.com:bitwarden/browser.git + cd browser +} if (-not ([string]::IsNullOrEmpty($version))) { $tag = "v" + $version