2021-01-27 20:24:11 +01:00
|
|
|
name: Build
|
2020-12-22 00:44:29 +01:00
|
|
|
|
|
|
|
on:
|
2021-01-08 00:06:52 +01:00
|
|
|
push:
|
|
|
|
branches-ignore:
|
|
|
|
- 'l10n_master'
|
2020-12-22 00:44:29 +01:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
cloc:
|
2021-01-14 22:46:14 +01:00
|
|
|
runs-on: ubuntu-latest
|
2020-12-22 00:44:29 +01:00
|
|
|
steps:
|
|
|
|
- name: Checkout repo
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- name: Set up cloc
|
|
|
|
run: |
|
2020-12-22 00:53:41 +01:00
|
|
|
sudo apt update
|
|
|
|
sudo apt -y install cloc
|
2020-12-22 00:44:29 +01:00
|
|
|
|
|
|
|
- name: Print lines of code
|
2021-01-06 20:26:25 +01:00
|
|
|
run: cloc --include-lang TypeScript,JavaScript --vcs git
|
2020-12-22 00:44:29 +01:00
|
|
|
|
2021-01-27 23:48:50 +01:00
|
|
|
cli:
|
2020-12-22 00:44:29 +01:00
|
|
|
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
|
2021-01-27 20:15:29 +01:00
|
|
|
run: |
|
|
|
|
choco install checksum --no-progress
|
|
|
|
choco install reshack --no-progress
|
2020-12-22 23:36:37 +01:00
|
|
|
|
2020-12-22 00:44:29 +01:00
|
|
|
- name: Set up Node
|
|
|
|
uses: actions/setup-node@v1
|
|
|
|
with:
|
|
|
|
node-version: '10.x'
|
|
|
|
|
2021-01-06 20:26:25 +01:00
|
|
|
- name: Set PACKAGE_VERSION & VER_INFO
|
2020-12-22 22:23:15 +01:00
|
|
|
run: |
|
2021-01-27 20:24:11 +01:00
|
|
|
$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
|
2021-01-11 22:23:45 +01:00
|
|
|
echo "WIN_PKG=$env:WIN_PKG" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
2020-12-22 23:16:35 +01:00
|
|
|
echo "version: $env:pkgVersion"
|
2021-01-27 20:15:29 +01:00
|
|
|
env:
|
|
|
|
WIN_PKG: C:\Users\runneradmin\.pkg-cache\v2.5\fetched-v10.4.1-win-x64
|
2020-12-22 23:12:55 +01:00
|
|
|
|
2021-01-27 20:15:29 +01:00
|
|
|
- name: get pkg-fetch
|
|
|
|
shell: pwsh
|
|
|
|
run: |
|
|
|
|
cd $HOME
|
|
|
|
$fetchedUrl = "https://github.com/vercel/pkg-fetch/releases/download/v2.5/uploaded-v2.5-node-v10.4.1-win-x64"
|
2021-01-14 23:51:39 +01:00
|
|
|
|
2021-01-27 20:15:29 +01:00
|
|
|
New-Item -ItemType directory -Path .\.pkg-cache
|
|
|
|
New-Item -ItemType directory -Path .\.pkg-cache\v2.5
|
|
|
|
Invoke-RestMethod -Uri $fetchedUrl -OutFile ".\.pkg-cache\v2.5\fetched-v10.4.1-win-x64"
|
2021-01-06 20:26:25 +01:00
|
|
|
env:
|
2021-01-27 20:15:29 +01:00
|
|
|
WIN_PKG: C:\Users\runneradmin\.pkg-cache\v2.5\fetched-v10.4.1-win-x64
|
2021-01-06 20:26:25 +01:00
|
|
|
|
2021-01-12 23:25:03 +01:00
|
|
|
- name: Setup Version Info
|
|
|
|
shell: pwsh
|
2021-01-14 22:13:17 +01:00
|
|
|
run: ./scripts/make-versioninfo.ps1
|
2021-01-12 23:25:03 +01:00
|
|
|
|
2021-01-27 20:15:29 +01:00
|
|
|
- name: Resource Hacker
|
2021-01-07 21:52:43 +01:00
|
|
|
shell: cmd
|
2021-01-06 20:26:25 +01:00
|
|
|
run: |
|
2021-01-27 20:15:29 +01:00
|
|
|
set PATH=%PATH%;C:\Program Files (x86)\Resource Hacker
|
|
|
|
ResourceHacker -open %WIN_PKG% -save %WIN_PKG% -action delete -mask ICONGROUP,1,
|
|
|
|
ResourceHacker -open version-info.rc -save version-info.res -action compile
|
|
|
|
ResourceHacker -open %WIN_PKG% -save %WIN_PKG% -action addoverwrite -resource version-info.res
|
2021-01-06 20:26:25 +01:00
|
|
|
|
2020-12-22 00:53:41 +01:00
|
|
|
- name: Install
|
|
|
|
run: npm install
|
|
|
|
|
|
|
|
- name: Setup sub-module
|
2020-12-22 18:44:53 +01:00
|
|
|
run: npm run sub:init
|
2020-12-22 00:53:41 +01:00
|
|
|
|
2021-01-27 20:15:29 +01:00
|
|
|
- name: Build & Package
|
|
|
|
run: npm run dist
|
2020-12-22 00:44:29 +01:00
|
|
|
|
2021-01-08 20:19:52 +01:00
|
|
|
- name: Package Chocolatey
|
2021-01-08 23:32:16 +01:00
|
|
|
shell: pwsh
|
|
|
|
run: |
|
2021-01-14 22:13:17 +01:00
|
|
|
Copy-Item -Path stores/chocolatey -Destination dist/chocolatey -Recurse
|
|
|
|
Copy-Item dist/windows/bw.exe -Destination dist/chocolatey/tools
|
|
|
|
Copy-Item LICENSE.txt -Destination dist/chocolatey/tools
|
2021-01-08 23:32:16 +01:00
|
|
|
|
2021-01-14 22:13:17 +01:00
|
|
|
choco pack dist/chocolatey/bitwarden-cli.nuspec --version ${{ env.PACKAGE_VERSION }} --out dist/chocolatey
|
2021-01-08 23:32:16 +01:00
|
|
|
|
2020-12-22 00:44:29 +01:00
|
|
|
- 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/
|
2020-12-22 00:44:29 +01:00
|
|
|
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"
|
2020-12-22 00:44:29 +01:00
|
|
|
if($testVersion -ne $env:PACKAGE_VERSION) {
|
|
|
|
Throw "Version test failed."
|
|
|
|
}
|
|
|
|
|
2021-01-08 20:19:52 +01:00
|
|
|
- name: Create checksums
|
2021-03-04 18:51:45 +01:00
|
|
|
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rc'
|
2020-12-22 00:44:29 +01:00
|
|
|
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
|
2021-03-04 18:51:45 +01:00
|
|
|
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rc'
|
2020-12-23 00:21:15 +01:00
|
|
|
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
|
2021-03-04 18:51:45 +01:00
|
|
|
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rc'
|
2020-12-23 00:21:15 +01:00
|
|
|
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
|
2021-03-04 18:51:45 +01:00
|
|
|
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rc'
|
2020-12-23 00:21:15 +01:00
|
|
|
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
|
2021-03-04 18:51:45 +01:00
|
|
|
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rc'
|
2020-12-23 00:21:15 +01:00
|
|
|
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
|
2021-03-04 18:51:45 +01:00
|
|
|
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rc'
|
2020-12-23 00:21:15 +01:00
|
|
|
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
|
2021-03-04 18:51:45 +01:00
|
|
|
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rc'
|
2020-12-23 00:21:15 +01:00
|
|
|
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
|
2021-03-04 18:51:45 +01:00
|
|
|
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rc'
|
2020-12-23 00:21:15 +01:00
|
|
|
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
|
|
|
|
|
|
|
|
2021-01-27 23:48:50 +01:00
|
|
|
snap:
|
2021-01-11 19:00:05 +01:00
|
|
|
name: Build Snap
|
2021-01-14 22:46:14 +01:00
|
|
|
runs-on: ubuntu-latest
|
2021-01-27 23:48:50 +01:00
|
|
|
needs: cli
|
2021-03-04 18:51:45 +01:00
|
|
|
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rc'
|
2020-12-22 00:44:29 +01:00
|
|
|
steps:
|
|
|
|
- name: Checkout repo
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
|
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: |
|
2021-01-14 22:13:17 +01:00
|
|
|
$env:pkgVersion = (Get-Content -Raw -Path ./package.json | ConvertFrom-Json).version
|
2021-01-09 00:28:32 +01:00
|
|
|
echo "PACKAGE_VERSION=$env:pkgVersion" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
|
|
|
|
2020-12-22 00:44:29 +01:00
|
|
|
- name: Install Snapcraft
|
|
|
|
uses: samuelmeuli/action-snapcraft@v1
|
|
|
|
|
|
|
|
- name: Print environment
|
|
|
|
run: |
|
|
|
|
whoami
|
|
|
|
snapcraft --version
|
|
|
|
echo "GitHub ref: $GITHUB_REF"
|
|
|
|
echo "GitHub event: $GITHUB_EVENT"
|
2021-01-11 15:33:13 +01:00
|
|
|
echo "BW Package Version: $PACKAGE_VERSION"
|
2020-12-22 00:44:29 +01:00
|
|
|
env:
|
|
|
|
GITHUB_REF: ${{ github.ref }}
|
|
|
|
GITHUB_EVENT: ${{ github.event_name }}
|
|
|
|
|
2021-01-27 23:48:50 +01:00
|
|
|
- name: Get bw linux cli
|
|
|
|
uses: actions/download-artifact@v2
|
|
|
|
with:
|
|
|
|
name: bw-linux-${{ env.PACKAGE_VERSION }}.zip
|
2021-01-28 00:50:11 +01:00
|
|
|
path: ./dist/snap
|
2021-01-27 23:48:50 +01:00
|
|
|
|
2021-01-11 15:33:13 +01:00
|
|
|
- name: Build Snap Package
|
2021-01-11 16:30:36 +01:00
|
|
|
run: |
|
2021-01-28 17:42:01 +01:00
|
|
|
cp -r stores/snap/* -t dist/snap
|
2021-01-27 23:19:59 +01:00
|
|
|
sed -i s/__version__/${{ env.PACKAGE_VERSION }}/g dist/snap/snapcraft.yaml
|
2021-01-11 16:30:36 +01:00
|
|
|
|
2021-01-27 23:19:59 +01:00
|
|
|
cd dist/snap
|
2021-01-28 00:34:08 +01:00
|
|
|
ls -alth
|
2021-01-11 16:30:36 +01:00
|
|
|
snapcraft
|
|
|
|
|
2021-01-14 22:46:14 +01:00
|
|
|
sha256sum bw_${{ env.PACKAGE_VERSION }}_amd64.snap | awk '{split($0, a); print a[1]}' > bw-snap-sha256-${{ env.PACKAGE_VERSION }}.txt
|
2021-01-11 19:00:05 +01:00
|
|
|
|
2021-01-11 17:14:32 +01:00
|
|
|
- name: Install Snap
|
2021-01-27 23:19:59 +01:00
|
|
|
run: sudo snap install dist/snap/bw*.snap --dangerous
|
2021-01-11 16:30:36 +01:00
|
|
|
|
2020-12-22 00:44:29 +01:00
|
|
|
- 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: |
|
2021-01-11 17:27:01 +01:00
|
|
|
sudo snap remove bw
|
|
|
|
|
2021-01-11 19:00:05 +01:00
|
|
|
- name: Publish snap to GitHub
|
2021-01-09 00:28:32 +01:00
|
|
|
uses: actions/upload-artifact@v2
|
|
|
|
with:
|
|
|
|
name: bw_${{ env.PACKAGE_VERSION }}_amd64.snap
|
|
|
|
path: ./dist/snap/bw_${{ env.PACKAGE_VERSION }}_amd64.snap
|
2020-12-22 00:44:29 +01:00
|
|
|
|
2021-01-27 20:15:29 +01:00
|
|
|
- name: Publish snap checksum to GitHub
|
2021-01-11 19:00:05 +01:00
|
|
|
uses: actions/upload-artifact@v2
|
|
|
|
with:
|
|
|
|
name: bw-snap-sha256-${{ env.PACKAGE_VERSION }}.txt
|
|
|
|
path: ./dist/snap/bw-snap-sha256-${{ env.PACKAGE_VERSION }}.txt
|