1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-10-30 08:10:34 +01:00
bitwarden-browser/.github/workflows/build.yml

315 lines
10 KiB
YAML
Raw Normal View History

name: "Build & Publish"
on:
2021-01-08 00:06:52 +01:00
push:
branches-ignore:
- 'l10n_master'
release:
types:
- published
jobs:
cloc:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Set up cloc
run: |
sudo apt update
sudo apt -y install cloc
- name: Print lines of code
run: cloc --include-lang TypeScript,JavaScript --vcs git
build:
name: Build CLI
runs-on: windows-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
2020-12-22 23:36:37 +01:00
- name: Setup Windows builder
run: choco install checksum --no-progress
- name: Set up Node
uses: actions/setup-node@v1
with:
node-version: '10.x'
2021-01-08 00:06:52 +01:00
- name: Download & Install RH
shell: pwsh
run: |
Invoke-WebRequest -Uri http://www.angusj.com/resourcehacker/resource_hacker.zip -OutFile "resource_hacker.zip"
Expand-Archive -Path resource_hacker.zip -DestinationPath scripts/resource_hacker
echo "D:\a\cli\cli\scripts\resource_hacker" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Set PACKAGE_VERSION & VER_INFO
2020-12-22 22:23:15 +01:00
run: |
$env:pkgVersion = (Get-Content -Raw -Path .\package.json | ConvertFrom-Json).version
2020-12-22 23:22:51 +01:00
echo "PACKAGE_VERSION=$env:pkgVersion" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "version: $env:pkgVersion"
2020-12-22 23:12:55 +01:00
if(Test-Path -Path $env:WIN_PKG) {
echo "VER_INFO=true" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
}
env:
WIN_PKG: C:\Users\appveyor\.pkg-cache\v2.5\fetched-v10.4.1-win-x64
2020-12-22 23:12:55 +01:00
- name: test setting env var
run: |
echo "version: $env:PACKAGE_VERSION"
2020-12-22 23:12:55 +01:00
2020-12-22 23:22:51 +01:00
if($env:PACKAGE_VERSION -eq "") {
2020-12-22 23:12:55 +01:00
Throw "test env failed."
}
2020-12-22 22:23:15 +01:00
- name: ResourceHacker
2021-01-07 21:52:43 +01:00
shell: cmd
run: |
if defined VER_INFO ResourceHacker -open %WIN_PKG% -save %WIN_PKG% -action delete -mask ICONGROUP,1,
if defined VER_INFO ResourceHacker -open version-info.rc -save version-info.res -action compile
if defined VER_INFO ResourceHacker -open %WIN_PKG% -save %WIN_PKG% -action addoverwrite -resource version-info.res
- name: Install
run: npm install
- name: Setup sub-module
2020-12-22 18:44:53 +01:00
run: npm run sub:init
- name: Build
2020-12-23 16:46:00 +01:00
run: npm run build:prod
- name: Clean Build
run: npm run clean
- name: Package Windows
2020-12-23 19:59:21 +01:00
run: npm run package:win
2020-12-23 16:46:00 +01:00
- name: Package Mac
2020-12-23 19:59:21 +01:00
run: npm run package:mac
2020-12-23 16:46:00 +01:00
- name: Package Linux
2020-12-23 19:59:21 +01:00
run: npm run package:lin
- name: Package Chocolatey
shell: pwsh
run: |
Copy-Item -Path stores\chocolatey -Destination dist\chocolatey -Recurse
Copy-Item dist\windows\bw.exe -Destination dist\chocolatey\tools
2021-01-08 23:40:34 +01:00
Copy-Item LICENSE.txt -Destination dist\chocolatey\tools
2021-01-08 23:33:20 +01:00
choco pack dist\chocolatey\bitwarden-cli.nuspec --version ${{ env.PACKAGE_VERSION }} --out dist\chocolatey
- name: Zip
shell: cmd
run: |
7z a ./dist/bw-windows-%PACKAGE_VERSION%.zip ./dist/windows/bw.exe
7z a ./dist/bw-macos-%PACKAGE_VERSION%.zip ./dist/macos/bw
7z a ./dist/bw-linux-%PACKAGE_VERSION%.zip ./dist/linux/bw
- name: Version Test
run: |
2020-12-22 22:45:05 +01:00
dir ./dist/
Expand-Archive -Path "./dist/bw-windows-${env:PACKAGE_VERSION}.zip" -DestinationPath "./test/windows"
$testVersion = Invoke-Expression '& ./test/windows/bw.exe -v'
2020-12-22 22:45:05 +01:00
echo "version: $env:PACKAGE_VERSION"
2020-12-22 23:22:51 +01:00
echo "testVersion: $testVersion"
if($testVersion -ne $env:PACKAGE_VERSION) {
Throw "Version test failed."
}
- name: Create checksums
run: |
checksum -f="./dist/bw-windows-${env:PACKAGE_VERSION}.zip" `
-t sha256 | Out-File -Encoding ASCII ./dist/bw-windows-sha256-${env:PACKAGE_VERSION}.txt
checksum -f="./dist/bw-macos-${env:PACKAGE_VERSION}.zip" `
-t sha256 | Out-File -Encoding ASCII ./dist/bw-macos-sha256-${env:PACKAGE_VERSION}.txt
checksum -f="./dist/bw-linux-${env:PACKAGE_VERSION}.zip" `
-t sha256 | Out-File -Encoding ASCII ./dist/bw-linux-sha256-${env:PACKAGE_VERSION}.txt
2020-12-23 00:21:15 +01:00
- name: Publish windows zip to GitHub
uses: actions/upload-artifact@v2
with:
2020-12-23 20:54:01 +01:00
name: bw-windows-${{ env.PACKAGE_VERSION }}.zip
path: ./dist/bw-windows-${{ env.PACKAGE_VERSION }}.zip
2020-12-23 00:21:15 +01:00
- name: Publish windows checksum to GitHub
uses: actions/upload-artifact@v2
with:
2020-12-23 20:54:01 +01:00
name: bw-windows-sha256-${{ env.PACKAGE_VERSION }}.txt
path: ./dist/bw-windows-sha256-${{ env.PACKAGE_VERSION }}.txt
2020-12-23 00:21:15 +01:00
- name: Publish macos zip to GitHub
uses: actions/upload-artifact@v2
with:
2020-12-23 20:54:01 +01:00
name: bw-macos-${{ env.PACKAGE_VERSION }}.zip
path: ./dist/bw-macos-${{ env.PACKAGE_VERSION }}.zip
2020-12-23 00:21:15 +01:00
- name: Publish macos checksum to GitHub
uses: actions/upload-artifact@v2
with:
2020-12-23 20:54:01 +01:00
name: bw-macos-sha256-${{ env.PACKAGE_VERSION }}.txt
path: ./dist/bw-macos-sha256-${{ env.PACKAGE_VERSION }}.txt
2020-12-23 00:21:15 +01:00
- name: Publish linux zip to GitHub
uses: actions/upload-artifact@v2
with:
2020-12-23 20:54:01 +01:00
name: bw-linux-${{ env.PACKAGE_VERSION }}.zip
path: ./dist/bw-linux-${{ env.PACKAGE_VERSION }}.zip
2020-12-23 00:21:15 +01:00
- name: Publish linux checksum to GitHub
uses: actions/upload-artifact@v2
with:
2020-12-23 20:54:01 +01:00
name: bw-linux-sha256-${{ env.PACKAGE_VERSION }}.txt
path: ./dist/bw-linux-sha256-${{ env.PACKAGE_VERSION }}.txt
2020-12-23 00:21:15 +01:00
- name: Publish Chocolatey CLI
uses: actions/upload-artifact@v2
with:
2020-12-23 20:54:01 +01:00
name: bitwarden-cli.${{ env.PACKAGE_VERSION }}.nupkg
path: ./dist/chocolatey/bitwarden-cli.${{ env.PACKAGE_VERSION }}.nupkg
2020-12-23 00:21:15 +01:00
publish_windows:
name: Publish Windows
runs-on: windows-latest
needs: build
2021-01-08 21:16:35 +01:00
#if: github.event_name == 'release'
steps:
- name: Checkout repo
uses: actions/checkout@v2
2021-01-08 21:41:15 +01:00
- name: Set PACKAGE_VERSION
run: |
$env:pkgVersion = (Get-Content -Raw -Path .\package.json | ConvertFrom-Json).version
echo "PACKAGE_VERSION=$env:pkgVersion" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
2021-01-08 21:29:28 +01:00
- name: Download Windows Nuget
uses: actions/download-artifact@v2
with:
name: bitwarden-cli.${{ env.PACKAGE_VERSION }}.nupkg
path: ./dist/bitwarden-cli.${{ env.PACKAGE_VERSION }}.nupkg
2021-01-08 21:16:35 +01:00
#- name: Setup Chocolatey
# run: choco apikey --key $env:CHOCO_API_KEY --source https://push.chocolatey.org/
# env:
# CHOCO_API_KEY: ${{ secrets.CHOCO_API_KEY }}
#- name: Publish
# run: |
# .\scripts\choco-update.ps1 -version $env:PACKAGE_VERSION
2021-01-11 15:34:39 +01:00
# Get-ChildItem dist
- name: Publish
2021-01-08 21:16:35 +01:00
shell: pwsh
run: |
2021-01-08 22:08:19 +01:00
# In place of ./scripts/choco-update.ps1
2021-01-08 21:29:28 +01:00
cd ./dist
Get-ChildItem
2021-01-08 21:16:35 +01:00
Write-Host "[+] Intead of pushing with choco, we are testing and writing this out"
2021-01-08 22:08:19 +01:00
Write-Host " Nuget Packge: bitwarden-cli.${{ env.PACKAGE_VERSION }}.nupkg"
#choco push
2020-12-23 16:52:24 +01:00
# This process seems independent from the others
publish_snap:
name: Publish Snap
runs-on: ubuntu-latest
needs: build
2021-01-09 00:28:32 +01:00
#if: github.event_name == 'release'
steps:
- name: Checkout repo
uses: actions/checkout@v2
Get-ChildItem dist
Get-ChildItem dist
2021-01-09 00:28:32 +01:00
- name: Set PACKAGE_VERSION
2021-01-09 00:44:51 +01:00
shell: pwsh
2021-01-09 00:28:32 +01:00
run: |
$env:pkgVersion = (Get-Content -Raw -Path .\package.json | ConvertFrom-Json).version
echo "PACKAGE_VERSION=$env:pkgVersion" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Install Snapcraft
uses: samuelmeuli/action-snapcraft@v1
2021-01-09 00:28:32 +01:00
#with:
# snapcraft_token: ${{ secrets.SNAP_TOKEN }}
- name: Print environment
run: |
whoami
snapcraft --version
echo "GitHub ref: $GITHUB_REF"
echo "GitHub event: $GITHUB_EVENT"
echo "BW Package Version: $PACKAGE_VERSION"
env:
GITHUB_REF: ${{ github.ref }}
GITHUB_EVENT: ${{ github.event_name }}
- name: Build Snap Package
shell: pwsh
run: |
2021-01-09 00:28:32 +01:00
#./scripts/snap-build.ps1 -version $env:PACKAGE_VERSION
2021-01-09 01:47:16 +01:00
#New-Item -Path 'dist' -ItemType Directory
2021-01-09 01:29:59 +01:00
Copy-Item -Path stores\snap -Destination dist\snap -Recurse
2021-01-09 01:47:16 +01:00
Get-ChildItem dist
2021-01-09 01:07:34 +01:00
Get-ChildItem dist\snap
(Get-Content dist\snap\snapcraft.yaml).replace('__version__', $env:PACKAGE_VERSION) | Set-Content dist\snap\snapcraft.yaml
2021-01-09 00:28:32 +01:00
cd dist\snap
Get-ChildItem
snapcraft
cd ..\..
Get-ChildItem
snap install ./dist/snap/bw*.snap --dangerous
- name: Test Snap
shell: pwsh
run: |
$testVersion = Invoke-Expression '& bw -v'
if($testVersion -ne $env:PACKAGE_VERSION) {
Throw "Version test failed."
}
- name: Cleanup Test & Update Snap for Publish
shell: pwsh
run: |
snap remove bw
2021-01-09 00:31:39 +01:00
#./scripts/snap-update.ps1
2021-01-09 00:28:32 +01:00
- name: Publish linux checksum to GitHub
uses: actions/upload-artifact@v2
with:
name: bw_${{ env.PACKAGE_VERSION }}_amd64.snap
path: ./dist/snap/bw_${{ env.PACKAGE_VERSION }}_amd64.snap
2021-01-09 00:31:39 +01:00
#- name: Snap Logout
# run: snapcraft logout
2020-12-23 16:52:24 +01:00
# This job is independent: it reruns 'npm run build:prod'
publish_npm:
name: Publish NPM
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'release'
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Setup NPM
shell: pwsh
2020-12-22 00:46:44 +01:00
run: |
"//registry.npmjs.org/:_authToken=${env:NPM_TOKEN}" | Out-File ".npmrc" -Encoding UTF8
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish NPM
run: npm run publish:npm