Skip to content

Commit

Permalink
[PS-2367] CLI pkg ref for argon2 lib (#4579)
Browse files Browse the repository at this point in the history
* pkg ref argon2

* add argon to cli package.json

* argon2 assets

* ci matrix for cli

* simplify builds for testing

* fix env

* zip for each os

* add os prefix back to zip

* create checksums

* make sums 256

* fix shasum command

* combine some steps for unix

* LOWER_RUNNER_OS

* SHORT_RUNNER_OS

* SHORT_RUNNER_OS on dist

* upload unix assets

* restore old build files

* fix formatting

* fix zip folder structure

* fix condition on upload unix zip asset

* compute shasum like other parts of build

* change matrix os targets
  • Loading branch information
kspearrin committed Jan 27, 2023
1 parent b7a5c27 commit 61d94c7
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 33 deletions.
85 changes: 53 additions & 32 deletions .github/workflows/build-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ jobs:
cli:
name: Build CLI
runs-on: windows-2019
strategy:
matrix:
os: [ubuntu-20.04, windows-2019, macos-11]
runs-on: ${{ matrix.os }}
needs:
- setup
env:
Expand All @@ -78,7 +81,15 @@ jobs:
- name: Checkout repo
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2

- name: Setup Unix Vars
if: runner.os != 'Windows'
run: |
echo "LOWER_RUNNER_OS=$(echo $RUNNER_OS | awk '{print tolower($0)}')" >> $GITHUB_ENV
echo "SHORT_RUNNER_OS=$(echo $RUNNER_OS | awk '{print substr($0, 1, 3)}' | \
awk '{print tolower($0)}')" >> $GITHUB_ENV
- name: Setup Windows builder
if: runner.os == 'Windows'
run: |
choco install checksum --no-progress
choco install reshack --no-progress
Expand All @@ -98,6 +109,7 @@ jobs:
- name: Get pkg-fetch
shell: pwsh
if: runner.os == 'Windows'
run: |
cd $HOME
$fetchedUrl = "https://github.com/vercel/pkg-fetch/releases/download/v$env:_WIN_PKG_VERSION/node-v$env:_WIN_PKG_FETCH_VERSION-win-x64"
Expand All @@ -108,6 +120,7 @@ jobs:
- name: Setup Version Info
shell: pwsh
if: runner.os == 'Windows'
run: |
$major,$minor,$patch = $env:_PACKAGE_VERSION.split('.')
$versionInfo = @"
Expand Down Expand Up @@ -142,6 +155,7 @@ jobs:

- name: Resource Hacker
shell: cmd
if: runner.os == 'Windows'
run: |
set PATH=%PATH%;C:\Program Files (x86)\Resource Hacker
set WIN_PKG=C:\Users\runneradmin\.pkg-cache\v%_WIN_PKG_VERSION%\fetched-v%_WIN_PKG_FETCH_VERSION%-win-x64
Expand All @@ -155,25 +169,36 @@ jobs:
run: npm ci
working-directory: ./

- name: Build & Package
run: npm run dist --quiet
- name: Build & Package Windows
if: runner.os == 'Windows'
run: npm run dist:win --quiet

- name: Build & Package Unix
if: runner.os != 'Windows'
run: npm run dist:${{ env.SHORT_RUNNER_OS }} --quiet

- name: Package Chocolatey
shell: pwsh
if: runner.os == 'Windows'
run: |
Copy-Item -Path stores/chocolatey -Destination dist/chocolatey -Recurse
Copy-Item dist/windows/bw.exe -Destination dist/chocolatey/tools
Copy-Item ${{ github.workspace }}/LICENSE.txt -Destination dist/chocolatey/tools
choco pack dist/chocolatey/bitwarden-cli.nuspec --version ${{ env._PACKAGE_VERSION }} --out dist/chocolatey
- name: Zip
- name: Zip Windows
shell: cmd
if: runner.os == 'Windows'
run: 7z a ./dist/bw-windows-%_PACKAGE_VERSION%.zip ./dist/windows/bw.exe

- name: Zip Unix
if: runner.os != 'Windows'
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
cd ./dist/${{ env.LOWER_RUNNER_OS }}
zip ../bw-${{ env.LOWER_RUNNER_OS }}-${{ env._PACKAGE_VERSION }}.zip ./bw
- name: Version Test
if: runner.os == 'Windows'
run: |
dir ./dist/
Expand-Archive -Path "./dist/bw-windows-${env:_PACKAGE_VERSION}.zip" -DestinationPath "./test/windows"
Expand All @@ -184,65 +209,61 @@ jobs:
Throw "Version test failed."
}
- name: Create checksums
- name: Create checksums Windows
if: runner.os == 'Windows'
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
- name: Create checksums Unix
if: runner.os != 'Windows'
run: |
cd ./dist
sha256sum bw-${{ env.LOWER_RUNNER_OS }}-${{ env._PACKAGE_VERSION }}.zip \
| awk '{split($0, a); print a[1]}' > bw-${{ env.LOWER_RUNNER_OS }}-sha256-${{ env._PACKAGE_VERSION }}.txt
- name: Upload windows zip asset
if: runner.os == 'Windows'
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
with:
name: bw-windows-${{ env._PACKAGE_VERSION }}.zip
path: apps/cli/dist/bw-windows-${{ env._PACKAGE_VERSION }}.zip
if-no-files-found: error

- name: Upload windows checksum asset
if: runner.os == 'Windows'
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
with:
name: bw-windows-sha256-${{ env._PACKAGE_VERSION }}.txt
path: apps/cli/dist/bw-windows-sha256-${{ env._PACKAGE_VERSION }}.txt
if-no-files-found: error

- name: Upload macos zip asset
- name: Upload unix zip asset
if: runner.os != 'Windows'
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
with:
name: bw-macos-${{ env._PACKAGE_VERSION }}.zip
path: apps/cli/dist/bw-macos-${{ env._PACKAGE_VERSION }}.zip
if-no-files-found: error

- name: Upload macos checksum asset
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
with:
name: bw-macos-sha256-${{ env._PACKAGE_VERSION }}.txt
path: apps/cli/dist/bw-macos-sha256-${{ env._PACKAGE_VERSION }}.txt
if-no-files-found: error

- name: Upload linux zip asset
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
with:
name: bw-linux-${{ env._PACKAGE_VERSION }}.zip
path: apps/cli/dist/bw-linux-${{ env._PACKAGE_VERSION }}.zip
name: bw-${{ env.LOWER_RUNNER_OS }}-${{ env._PACKAGE_VERSION }}.zip
path: apps/cli/dist/bw-${{ env.LOWER_RUNNER_OS }}-${{ env._PACKAGE_VERSION }}.zip
if-no-files-found: error

- name: Upload linux checksum asset
- name: Upload unix checksum asset
if: runner.os != 'Windows'
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
with:
name: bw-linux-sha256-${{ env._PACKAGE_VERSION }}.txt
path: apps/cli/dist/bw-linux-sha256-${{ env._PACKAGE_VERSION }}.txt
name: bw-${{ env.LOWER_RUNNER_OS }}-sha256-${{ env._PACKAGE_VERSION }}.txt
path: apps/cli/dist/bw-${{ env.LOWER_RUNNER_OS }}-sha256-${{ env._PACKAGE_VERSION }}.txt
if-no-files-found: error

- name: Upload Chocolatey asset
if: runner.os == 'Windows'
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
with:
name: bitwarden-cli.${{ env._PACKAGE_VERSION }}.nupkg
path: apps/cli/dist/chocolatey/bitwarden-cli.${{ env._PACKAGE_VERSION }}.nupkg
if-no-files-found: error

- name: Upload NPM Build Directory asset
if: runner.os == 'Windows'
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
with:
name: bitwarden-cli-${{ env._PACKAGE_VERSION }}-npm-build.zip
Expand Down
6 changes: 5 additions & 1 deletion apps/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,15 @@
"bw": "build/bw.js"
},
"pkg": {
"assets": "./build/**/*"
"assets": [
"./build/**/*",
"../../node_modules/argon2/**/*"
]
},
"dependencies": {
"@koa/multer": "^3.0.0",
"@koa/router": "^10.1.1",
"argon2": "^0.30.3",
"big-integer": "^1.6.51",
"browser-hrtime": "^1.1.8",
"chalk": "^4.1.1",
Expand Down
2 changes: 2 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 61d94c7

Please sign in to comment.