From 30e898b6978963bcd51e6b4cf07c84966fb32a66 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 24 Sep 2020 12:17:41 -0400 Subject: [PATCH] artifacts and stuff --- .github/scripts/load-version.ps1 | 5 ++ .github/scripts/macos/clean-safari.ps1 | 8 --- .github/workflows/build.yml | 95 +++++++++++++++++--------- scripts/safari-build.ps1 | 30 +++++--- 4 files changed, 89 insertions(+), 49 deletions(-) create mode 100644 .github/scripts/load-version.ps1 delete mode 100644 .github/scripts/macos/clean-safari.ps1 diff --git a/.github/scripts/load-version.ps1 b/.github/scripts/load-version.ps1 new file mode 100644 index 00000000..b8494f7c --- /dev/null +++ b/.github/scripts/load-version.ps1 @@ -0,0 +1,5 @@ +$rootPath = $env:GITHUB_WORKSPACE; +$packageVersion = (Get-Content -Raw -Path $rootPath\src\package.json | ConvertFrom-Json).version; + +Write-Output "Setting package version to $packageVersion"; +Write-Output "::set-env name=PACKAGE_VERSION::$packageVersion"; diff --git a/.github/scripts/macos/clean-safari.ps1 b/.github/scripts/macos/clean-safari.ps1 deleted file mode 100644 index ab3a51d6..00000000 --- a/.github/scripts/macos/clean-safari.ps1 +++ /dev/null @@ -1,8 +0,0 @@ -$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 cb3fa1c5..d112d4bb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,13 +10,29 @@ on: - published jobs: + + cloc: + runs-on: ubuntu-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v2 + + - name: Set up cloc + run: | + sudo apt-get update + sudo apt-get -y install cloc + + - name: Print lines of code + run: cloc --include-lang TypeScript,JavaScript,HTML,Sass,CSS --vcs git + build: runs-on: ${{ matrix.os }} strategy: matrix: - os: [windows-latest, macos-latest, ubuntu-latest] + os: [windows-latest, ubuntu-latest] steps: - name: Set up Node @@ -27,7 +43,6 @@ jobs: - name: Set up environment shell: pwsh run: | - npm install -g cloc if($env:RUNNER_OS -eq "Linux") { sudo apt-get update sudo apt-get -y install pkg-config libxss-dev libsecret-1-dev rpm @@ -41,7 +56,6 @@ jobs: node --version npm --version git --version - cloc --version - name: Checkout repo uses: actions/checkout@v2 @@ -59,10 +73,6 @@ jobs: echo "::set-env name=PACKAGE_VERSION::$PACKAGE_VERSION" echo "::set-env name=PROD_DEPLOY::$PROD_DEPLOY" - - name: Print LOC - shell: bash - run: cloc --include-lang TypeScript,JavaScript,HTML,Sass,CSS --vcs git - - name: Install Node dependencies run: npm install @@ -79,9 +89,6 @@ jobs: elseif($env:RUNNER_OS -eq "Windows") { npm run dist:win:ci } - elseif($env:RUNNER_OS -eq "macOS") { - npm run build - } - name: Compile artifacts shell: bash @@ -125,11 +132,6 @@ jobs: env: DECRYPT_FILE_PASSWORD: ${{ secrets.DECRYPT_FILE_PASSWORD }} - - name: Increment version - if: github.ref == 'refs/heads/master' || github.event_name == 'release' - run: ./.github/scripts/macos/increment-version.ps1 - shell: pwsh - - name: Set up keychain run: ./.github/scripts/macos/setup-keychain.ps1 shell: pwsh @@ -145,15 +147,24 @@ jobs: run: ./.github/scripts/macos/setup-profiles.ps1 shell: pwsh + - name: Increment version + if: github.ref == 'refs/heads/master' || github.event_name == 'release' + run: ./.github/scripts/macos/increment-version.ps1 + shell: pwsh + + - name: Load package version + run: ./.github/scripts/load-version.ps1 + shell: pwsh + - name: Install Node dependencies run: npm install - name: Run linter run: npm run lint - - name: Clean Safari directory + - name: Create Safari directory shell: pwsh - run: ./.github/scripts/macos/clean-safari.ps1 + run: New-Item ./dist/safari -ItemType Directory -ea 0 - name: Checkout browser extension uses: actions/checkout@v2 @@ -161,27 +172,49 @@ jobs: repository: 'bitwarden/browser' path: 'dist/safari/browser' -# - name: Build Safari extension for .dmg -# shell: pwsh -# run: ./scripts/safari-build.ps1 -skipcheckout - -# - name: Build application for .dmg -# run: npm run dist:mac -# env: -# APPLE_ID_USERNAME: ${{ secrets.APPLE_ID_USERNAME }} -# APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} - - - name: Build Safari extension for App Store + - name: Build Safari extension shell: pwsh - run: ./scripts/safari-build.ps1 -mas -skipcheckout + run: ./scripts/safari-build.ps1 -skipcheckout -skipoutcopy - - name: Build application for App Store + - name: Load Safari extension for .dmg + shell: pwsh + run: ./scripts/safari-build.ps1 -copyonly + + - name: Build for .dmg + run: npm run dist:mac + env: + APPLE_ID_USERNAME: ${{ secrets.APPLE_ID_USERNAME }} + APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} + + - name: Upload .app artifact + uses: actions/upload-artifact@v2 + with: + name: Bitwarden.app + path: ./dist/mac/Bitwarden.app + + - name: Upload .dmg artifact + uses: actions/upload-artifact@v2 + with: + name: Bitwarden-${{ env.PACKAGE_VERSION }}.dmg + path: ./dist/mac/Bitwarden-${{ env.PACKAGE_VERSION }}.dmg + + - name: Load Safari extension for App Store + shell: pwsh + run: ./scripts/safari-build.ps1 -mas -copyonly + + - name: Build for App Store run: npm run dist:mac:mas env: APPLE_ID_USERNAME: ${{ secrets.APPLE_ID_USERNAME }} APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} - - name: Publish to App Store + - name: Upload .pkg artifact + uses: actions/upload-artifact@v2 + with: + name: Bitwarden-${{ env.PACKAGE_VERSION }}.pkg + path: ./dist/mas/Bitwarden-${{ env.PACKAGE_VERSION }}.pkg + + - name: Deploy to App Store run: npm run upload:mas env: APPLE_ID_USERNAME: ${{ secrets.APPLE_ID_USERNAME }} diff --git a/scripts/safari-build.ps1 b/scripts/safari-build.ps1 index 5d44bcc0..d5d9eb4d 100644 --- a/scripts/safari-build.ps1 +++ b/scripts/safari-build.ps1 @@ -3,7 +3,8 @@ [switch] $mas, [switch] $masdev, [switch] $skipcheckout, - [switch] $skipoutcopy + [switch] $skipoutcopy, + [switch] $copyonly ) # Dependencies: @@ -21,10 +22,27 @@ $distSafariAppexMas = $distSafariDir + "\browser\dist\Safari\mas\build\Release\s $distSafariAppexMasDev = $distSafariDir + "\browser\dist\Safari\masdev\build\Release\safari.appex"; $pluginsAppex = $rootDir + "\PlugIns\safari.appex"; +function CopyOutput { + if ($mas) { + Copy-Item -Path $distSafariAppexMas -Destination $pluginsAppex –Recurse + } + elseif ($masdev) { + Copy-Item -Path $distSafariAppexMasDev -Destination $pluginsAppex –Recurse + } + else { + Copy-Item -Path $distSafariAppexDmg -Destination $pluginsAppex –Recurse + } +} + if (Test-Path -Path $pluginsAppex) { Remove-Item -Recurse -Force $pluginsAppex } +if ($copyonly) { + CopyOutput + exit +} + if(-not $skipcheckout) { if (Test-Path -Path $distSafariDir) { Remove-Item -Recurse -Force $distSafariDir @@ -49,15 +67,7 @@ npm i npm run dist:safari if (-not $skipoutcopy) { - if ($mas) { - Copy-Item -Path $distSafariAppexMas -Destination $pluginsAppex –Recurse - } - elseif ($masdev) { - Copy-Item -Path $distSafariAppexMasDev -Destination $pluginsAppex –Recurse - } - else { - Copy-Item -Path $distSafariAppexDmg -Destination $pluginsAppex –Recurse - } + CopyOutput } cd $rootDir