bitwarden-desktop/.github/workflows/build.yml

233 lines
6.7 KiB
YAML
Raw Normal View History

2020-03-24 14:03:14 +01:00
name: Build
2020-06-29 17:28:41 +02:00
on:
push:
branches-ignore:
- 'l10n_master'
- 'gh-pages'
2020-09-22 23:02:33 +02:00
release:
types:
- published
2020-03-24 14:03:14 +01:00
jobs:
2020-09-24 18:17:41 +02:00
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
2020-03-24 14:03:14 +01:00
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
2020-09-24 18:17:41 +02:00
os: [windows-latest, ubuntu-latest]
2020-03-24 14:03:14 +01:00
steps:
- name: Set up Node
uses: actions/setup-node@v1
with:
node-version: '10.x'
2020-03-24 15:33:49 +01:00
- name: Set up environment
2020-03-24 14:03:14 +01:00
shell: pwsh
run: |
if($env:RUNNER_OS -eq "Linux") {
sudo apt-get update
sudo apt-get -y install pkg-config libxss-dev libsecret-1-dev rpm
}
elseif($env:RUNNER_OS -eq "Windows") {
choco --version
}
- name: Print environment
run: |
node --version
npm --version
git --version
- name: Checkout repo
uses: actions/checkout@v2
2020-03-24 15:33:49 +01:00
- name: Determine deployment variables
shell: pwsh
env:
GITHUB_REF: ${{ github.ref }}
run: |
$PACKAGE_VERSION = (Get-Content -Raw -Path .\src\package.json | ConvertFrom-Json).version
$PROD_DEPLOY = "false"
2020-03-24 15:36:29 +01:00
if($env:GITHUB_REF.StartsWith("refs/tags/v")) {
echo "::set-env name=RELEASE_NAME::$env:GITHUB_REF.Replace('refs/tags/v', '')"
2020-03-24 15:33:49 +01:00
}
echo "::set-env name=PACKAGE_VERSION::$PACKAGE_VERSION"
echo "::set-env name=PROD_DEPLOY::$PROD_DEPLOY"
2020-03-24 14:03:14 +01:00
- name: Install Node dependencies
run: npm install
- name: Run linter
run: npm run lint
- name: Build application
2020-03-24 14:03:14 +01:00
shell: pwsh
run: |
2020-03-24 15:33:49 +01:00
echo "Building dist for $env:PACKAGE_VERSION"
2020-03-24 14:03:14 +01:00
if($env:RUNNER_OS -eq "Linux") {
npm run dist:lin
}
elseif($env:RUNNER_OS -eq "Windows") {
2020-03-24 15:42:20 +01:00
npm run dist:win:ci
2020-03-24 14:03:14 +01:00
}
2020-03-24 16:24:16 +01:00
- name: Compile artifacts
shell: bash
run: |
mkdir -p artifacts
2020-03-24 16:31:23 +01:00
if [ "$RUNNER_OS" == "Linux" ]; then
2020-03-24 16:24:16 +01:00
cp ./dist/*.{snap,AppImage,deb,rpm,freebsd} ./artifacts
2020-03-24 16:35:22 +01:00
elif [ "$RUNNER_OS" == "Windows" ]; then
2020-03-24 16:24:16 +01:00
cp ./dist/Bitwarden-*-x64.appx ./artifacts/Bitwarden-$PACKAGE_VERSION-x64-store.appx
cp ./dist/Bitwarden-*-ia32.appx ./artifacts/Bitwarden-$PACKAGE_VERSION-ia32-store.appx
cp ./dist/Bitwarden-Portable-*.exe ./artifacts
cp ./dist/nsis-web/Bitwarden-Installer-*.exe ./artifacts
fi
- name: Upload artifacts
if: runner.os == 'Linux' || runner.os == 'Windows'
uses: actions/upload-artifact@v2-preview
with:
2020-03-24 16:53:14 +01:00
name: desktop-artifacts
2020-03-24 16:24:16 +01:00
path: artifacts/*
2020-09-22 22:00:58 +02:00
macos:
runs-on: macos-latest
steps:
2020-09-24 21:51:17 +02:00
- name: Set up Node
uses: actions/setup-node@v1
with:
node-version: '10.x'
2020-09-24 22:13:26 +02:00
- name: Set Node options
2020-09-24 22:15:32 +02:00
run: echo "::set-env name=NODE_OPTIONS::--max_old_space_size=4096"
2020-09-24 22:13:26 +02:00
2020-09-22 22:00:58 +02:00
- name: Print environment
run: |
2020-09-24 21:51:17 +02:00
node --version
npm --version
git --version
2020-09-22 22:00:58 +02:00
Write-Output "GitHub ref: $env:GITHUB_REF"
Write-Output "GitHub event: $env:GITHUB_EVENT"
shell: pwsh
env:
GITHUB_REF: ${{ github.ref }}
GITHUB_EVENT: ${{ github.event_name }}
- name: Checkout repo
uses: actions/checkout@v2
- name: Decrypt secrets
run: ./.github/scripts/macos/decrypt-secrets.ps1
shell: pwsh
env:
DECRYPT_FILE_PASSWORD: ${{ secrets.DECRYPT_FILE_PASSWORD }}
- name: Set up keychain
run: ./.github/scripts/macos/setup-keychain.ps1
shell: pwsh
env:
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
DESKTOP_KEY_PASSWORD: ${{ secrets.DESKTOP_KEY_PASSWORD }}
DEVID_CERT_PASSWORD: ${{ secrets.DEVID_CERT_PASSWORD }}
APPSTORE_CERT_PASSWORD: ${{ secrets.APPSTORE_CERT_PASSWORD }}
2020-09-23 20:20:01 +02:00
MACDEV_CERT_PASSWORD: ${{ secrets.MACDEV_CERT_PASSWORD }}
2020-09-22 22:32:39 +02:00
APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
2020-09-22 22:00:58 +02:00
- name: Set up provisioning profiles
run: ./.github/scripts/macos/setup-profiles.ps1
shell: pwsh
2020-09-24 18:17:41 +02:00
- 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
2020-09-22 22:19:17 +02:00
- name: Install Node dependencies
run: npm install
- name: Run linter
run: npm run lint
2020-09-24 18:17:41 +02:00
- name: Create Safari directory
2020-09-22 23:28:09 +02:00
shell: pwsh
2020-09-24 19:01:50 +02:00
run: New-Item ./dist-safari -ItemType Directory -ea 0
2020-09-22 23:28:09 +02:00
- name: Checkout browser extension
uses: actions/checkout@v2
with:
repository: 'bitwarden/browser'
2020-09-24 19:21:15 +02:00
path: 'dist-safari/browser'
2020-09-22 23:28:09 +02:00
2020-09-24 18:17:41 +02:00
- name: Build Safari extension
shell: pwsh
run: ./scripts/safari-build.ps1 -skipcheckout -skipoutcopy
2020-09-22 22:00:58 +02:00
2020-09-24 18:17:41 +02:00
- name: Load Safari extension for .dmg
shell: pwsh
run: ./scripts/safari-build.ps1 -copyonly
2020-09-22 22:00:58 +02:00
2020-09-24 18:17:41 +02:00
- name: Build for .dmg
run: npm run dist:mac
env:
APPLE_ID_USERNAME: ${{ secrets.APPLE_ID_USERNAME }}
APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
2020-09-24 18:20:08 +02:00
- name: Upload .zip artifact
2020-09-24 18:17:41 +02:00
uses: actions/upload-artifact@v2
with:
2020-09-24 18:20:08 +02:00
name: Bitwarden-${{ env.PACKAGE_VERSION }}-mac.zip
path: ./dist/Bitwarden-${{ env.PACKAGE_VERSION }}-mac.zip
2020-09-24 18:17:41 +02:00
- name: Upload .dmg artifact
uses: actions/upload-artifact@v2
with:
name: Bitwarden-${{ env.PACKAGE_VERSION }}.dmg
2020-09-24 18:20:08 +02:00
path: ./dist/Bitwarden-${{ env.PACKAGE_VERSION }}.dmg
2020-09-24 18:17:41 +02:00
- name: Load Safari extension for App Store
2020-09-22 23:14:07 +02:00
shell: pwsh
2020-09-24 18:17:41 +02:00
run: ./scripts/safari-build.ps1 -mas -copyonly
2020-09-22 22:00:58 +02:00
2020-09-24 18:17:41 +02:00
- name: Build for App Store
2020-09-22 22:00:58 +02:00
run: npm run dist:mac:mas
2020-09-22 22:55:40 +02:00
env:
APPLE_ID_USERNAME: ${{ secrets.APPLE_ID_USERNAME }}
APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
2020-09-24 16:20:56 +02:00
2020-09-24 18:17:41 +02:00
- 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
2020-09-24 16:20:56 +02:00
run: npm run upload:mas
env:
APPLE_ID_USERNAME: ${{ secrets.APPLE_ID_USERNAME }}
APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}