2022-05-31 15:20:06 +02:00
|
|
|
name: Build CLI
|
2020-12-22 00:44:29 +01:00
|
|
|
|
|
|
|
on:
|
2022-05-31 15:20:06 +02:00
|
|
|
pull_request:
|
2021-01-08 00:06:52 +01:00
|
|
|
branches-ignore:
|
|
|
|
- 'l10n_master'
|
2022-06-20 21:16:51 +02:00
|
|
|
- 'cf-pages'
|
2022-05-31 15:20:06 +02:00
|
|
|
paths:
|
|
|
|
- 'apps/cli/**'
|
2022-06-08 19:53:35 +02:00
|
|
|
- 'libs/**'
|
2022-06-13 09:59:15 +02:00
|
|
|
- '*'
|
|
|
|
- '!*.md'
|
|
|
|
- '!*.txt'
|
2022-05-31 15:20:06 +02:00
|
|
|
- '.github/workflows/build-cli.yml'
|
2024-06-06 01:06:27 +02:00
|
|
|
- 'bitwarden_license/bit-cli/**'
|
2022-05-31 15:20:06 +02:00
|
|
|
push:
|
|
|
|
branches:
|
2023-12-12 20:57:50 +01:00
|
|
|
- 'main'
|
2022-05-31 15:20:06 +02:00
|
|
|
- 'rc'
|
2022-08-16 17:55:57 +02:00
|
|
|
- 'hotfix-rc-cli'
|
2022-05-31 15:20:06 +02:00
|
|
|
paths:
|
|
|
|
- 'apps/cli/**'
|
2022-06-08 19:53:35 +02:00
|
|
|
- 'libs/**'
|
2022-06-13 09:59:15 +02:00
|
|
|
- '*'
|
|
|
|
- '!*.md'
|
|
|
|
- '!*.txt'
|
2022-05-31 15:20:06 +02:00
|
|
|
- '.github/workflows/build-cli.yml'
|
2024-06-06 01:06:27 +02:00
|
|
|
- 'bitwarden_license/bit-cli/**'
|
2022-03-15 17:08:29 +01:00
|
|
|
workflow_dispatch:
|
|
|
|
inputs: {}
|
2020-12-22 00:44:29 +01:00
|
|
|
|
2022-05-31 15:20:06 +02:00
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
working-directory: apps/cli
|
|
|
|
|
2020-12-22 00:44:29 +01:00
|
|
|
jobs:
|
2021-10-05 22:20:18 +02:00
|
|
|
setup:
|
|
|
|
name: Setup
|
2023-08-28 21:31:09 +02:00
|
|
|
runs-on: ubuntu-22.04
|
2021-10-05 22:20:18 +02:00
|
|
|
outputs:
|
2023-10-04 18:23:40 +02:00
|
|
|
package_version: ${{ steps.retrieve-package-version.outputs.package_version }}
|
|
|
|
node_version: ${{ steps.retrieve-node-version.outputs.node_version }}
|
2021-10-05 22:20:18 +02:00
|
|
|
steps:
|
|
|
|
- name: Checkout repo
|
2024-10-17 16:45:49 +02:00
|
|
|
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
|
2021-10-05 22:20:18 +02:00
|
|
|
|
|
|
|
- name: Get Package Version
|
2023-10-04 18:23:40 +02:00
|
|
|
id: retrieve-package-version
|
2021-10-05 22:20:18 +02:00
|
|
|
run: |
|
|
|
|
PKG_VERSION=$(jq -r .version package.json)
|
2022-12-05 16:04:04 +01:00
|
|
|
echo "package_version=$PKG_VERSION" >> $GITHUB_OUTPUT
|
2021-10-05 22:20:18 +02:00
|
|
|
|
2023-10-04 18:23:40 +02:00
|
|
|
- name: Get Node Version
|
|
|
|
id: retrieve-node-version
|
|
|
|
working-directory: ./
|
|
|
|
run: |
|
|
|
|
NODE_NVMRC=$(cat .nvmrc)
|
|
|
|
NODE_VERSION=${NODE_NVMRC/v/''}
|
|
|
|
echo "node_version=$NODE_VERSION" >> $GITHUB_OUTPUT
|
|
|
|
|
2021-10-05 22:20:18 +02:00
|
|
|
|
2021-01-27 23:48:50 +01:00
|
|
|
cli:
|
2024-05-24 16:36:26 +02:00
|
|
|
name: "${{ matrix.os.base }} - ${{ matrix.license_type.readable }}"
|
2023-01-27 15:52:08 +01:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2024-05-24 16:36:26 +02:00
|
|
|
os:
|
2024-08-22 16:54:23 +02:00
|
|
|
[
|
|
|
|
{ base: "linux", distro: "ubuntu-22.04" },
|
|
|
|
{ base: "mac", distro: "macos-13" }
|
|
|
|
]
|
2024-05-24 16:36:26 +02:00
|
|
|
license_type:
|
2024-08-22 16:54:23 +02:00
|
|
|
[
|
|
|
|
{ build_prefix: "oss", artifact_prefix: "-oss", readable: "open source license" },
|
|
|
|
{ build_prefix: "bit", artifact_prefix: "", readable: "commercial license" }
|
|
|
|
]
|
2024-05-24 16:36:26 +02:00
|
|
|
runs-on: ${{ matrix.os.distro }}
|
2022-03-15 19:09:46 +01:00
|
|
|
needs:
|
|
|
|
- setup
|
2021-07-14 20:41:05 +02:00
|
|
|
env:
|
2021-10-05 22:20:18 +02:00
|
|
|
_PACKAGE_VERSION: ${{ needs.setup.outputs.package_version }}
|
2023-10-04 18:23:40 +02:00
|
|
|
_NODE_VERSION: ${{ needs.setup.outputs.node_version }}
|
2024-05-30 13:24:06 +02:00
|
|
|
_WIN_PKG_FETCH_VERSION: 20.11.1
|
|
|
|
_WIN_PKG_VERSION: 3.5
|
2020-12-22 00:44:29 +01:00
|
|
|
steps:
|
|
|
|
- name: Checkout repo
|
2024-10-17 16:45:49 +02:00
|
|
|
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
|
2020-12-22 00:44:29 +01:00
|
|
|
|
2023-01-27 15:52:08 +01:00
|
|
|
- name: Setup Unix Vars
|
|
|
|
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
|
|
|
|
|
2023-02-10 17:00:24 +01:00
|
|
|
- name: Set up Node
|
2024-09-24 17:35:01 +02:00
|
|
|
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
|
2023-02-10 17:00:24 +01:00
|
|
|
with:
|
|
|
|
cache: 'npm'
|
|
|
|
cache-dependency-path: '**/package-lock.json'
|
2023-10-04 18:23:40 +02:00
|
|
|
node-version: ${{ env._NODE_VERSION }}
|
2023-02-10 17:00:24 +01:00
|
|
|
|
|
|
|
- name: Install
|
|
|
|
run: npm ci
|
|
|
|
working-directory: ./
|
|
|
|
|
|
|
|
- name: Build & Package Unix
|
2024-06-27 18:47:52 +02:00
|
|
|
run: npm run dist:${{ matrix.license_type.build_prefix }}:${{ env.SHORT_RUNNER_OS }} --quiet
|
2023-02-10 17:00:24 +01:00
|
|
|
|
|
|
|
- name: Zip Unix
|
|
|
|
run: |
|
2024-06-27 18:47:52 +02:00
|
|
|
cd ./dist/${{ matrix.license_type.build_prefix }}/${{ env.LOWER_RUNNER_OS }}
|
|
|
|
zip ../../bw${{ matrix.license_type.artifact_prefix }}-${{ env.LOWER_RUNNER_OS }}-${{ env._PACKAGE_VERSION }}.zip ./bw
|
2023-02-10 17:00:24 +01:00
|
|
|
|
|
|
|
- name: Version Test
|
|
|
|
run: |
|
2024-06-27 18:47:52 +02:00
|
|
|
unzip "./dist/bw${{ matrix.license_type.artifact_prefix }}-${{ env.LOWER_RUNNER_OS }}-${{ env._PACKAGE_VERSION }}.zip" -d "./test"
|
2023-02-10 17:00:24 +01:00
|
|
|
testVersion=$(./test/bw -v)
|
|
|
|
echo "version: $_PACKAGE_VERSION"
|
|
|
|
echo "testVersion: $testVersion"
|
|
|
|
if [[ $testVersion != $_PACKAGE_VERSION ]]; then
|
|
|
|
echo "Version test failed."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
- name: Create checksums Unix
|
|
|
|
run: |
|
|
|
|
cd ./dist
|
2024-06-27 18:47:52 +02:00
|
|
|
shasum -a 256 bw${{ matrix.license_type.artifact_prefix }}-${{ env.LOWER_RUNNER_OS }}-${{ env._PACKAGE_VERSION }}.zip \
|
|
|
|
| awk '{split($0, a); print a[1]}' > bw${{
|
|
|
|
matrix.license_type.artifact_prefix }}-${{ env.LOWER_RUNNER_OS }}-sha256-${{ env._PACKAGE_VERSION }}.txt
|
2023-02-10 17:00:24 +01:00
|
|
|
|
|
|
|
- name: Upload unix zip asset
|
2024-10-17 16:45:49 +02:00
|
|
|
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
|
2023-02-10 17:00:24 +01:00
|
|
|
with:
|
2024-06-27 18:47:52 +02:00
|
|
|
name: bw${{ matrix.license_type.artifact_prefix }}-${{ env.LOWER_RUNNER_OS }}-${{ env._PACKAGE_VERSION }}.zip
|
|
|
|
path: apps/cli/dist/bw${{ matrix.license_type.artifact_prefix }}-${{ env.LOWER_RUNNER_OS }}-${{ env._PACKAGE_VERSION }}.zip
|
2023-02-10 17:00:24 +01:00
|
|
|
if-no-files-found: error
|
|
|
|
|
|
|
|
- name: Upload unix checksum asset
|
2024-10-17 16:45:49 +02:00
|
|
|
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
|
2023-02-10 17:00:24 +01:00
|
|
|
with:
|
2024-06-27 18:47:52 +02:00
|
|
|
name: bw${{ matrix.license_type.artifact_prefix }}-${{ env.LOWER_RUNNER_OS }}-sha256-${{ env._PACKAGE_VERSION }}.txt
|
|
|
|
path: apps/cli/dist/bw${{ matrix.license_type.artifact_prefix }}-${{ env.LOWER_RUNNER_OS }}-sha256-${{ env._PACKAGE_VERSION }}.txt
|
2023-02-10 17:00:24 +01:00
|
|
|
if-no-files-found: error
|
|
|
|
|
|
|
|
cli-windows:
|
2024-05-24 16:36:26 +02:00
|
|
|
name: "windows - ${{ matrix.license_type.readable }}"
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
license_type:
|
2024-08-22 16:54:23 +02:00
|
|
|
[
|
|
|
|
{ build_prefix: "oss", artifact_prefix: "-oss", readable: "open source license" },
|
|
|
|
{ build_prefix: "bit", artifact_prefix: "", readable: "commercial license" }
|
|
|
|
]
|
2024-02-08 21:33:19 +01:00
|
|
|
runs-on: windows-2022
|
2023-02-10 17:00:24 +01:00
|
|
|
needs:
|
|
|
|
- setup
|
|
|
|
env:
|
|
|
|
_PACKAGE_VERSION: ${{ needs.setup.outputs.package_version }}
|
2023-10-04 18:23:40 +02:00
|
|
|
_NODE_VERSION: ${{ needs.setup.outputs.node_version }}
|
2024-05-30 13:24:06 +02:00
|
|
|
_WIN_PKG_FETCH_VERSION: 20.11.1
|
|
|
|
_WIN_PKG_VERSION: 3.5
|
2023-02-10 17:00:24 +01:00
|
|
|
steps:
|
|
|
|
- name: Checkout repo
|
2024-10-17 16:45:49 +02:00
|
|
|
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
|
2023-02-10 17:00:24 +01:00
|
|
|
|
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
|
2022-05-31 15:20:06 +02:00
|
|
|
choco install nasm --no-progress
|
2020-12-22 23:36:37 +01:00
|
|
|
|
2020-12-22 00:44:29 +01:00
|
|
|
- name: Set up Node
|
2024-09-24 17:35:01 +02:00
|
|
|
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
|
2020-12-22 00:44:29 +01:00
|
|
|
with:
|
2022-03-16 13:33:24 +01:00
|
|
|
cache: 'npm'
|
2022-06-03 20:11:47 +02:00
|
|
|
cache-dependency-path: '**/package-lock.json'
|
2023-10-04 18:23:40 +02:00
|
|
|
node-version: ${{ env._NODE_VERSION }}
|
2022-06-13 09:59:15 +02:00
|
|
|
|
2021-07-14 20:41:05 +02:00
|
|
|
- name: Get pkg-fetch
|
2021-01-27 20:15:29 +01:00
|
|
|
shell: pwsh
|
|
|
|
run: |
|
|
|
|
cd $HOME
|
2024-05-30 13:24:06 +02:00
|
|
|
$fetchedUrl = "https://github.com/yao-pkg/pkg-fetch/releases/download/v$env:_WIN_PKG_VERSION/node-v$env:_WIN_PKG_FETCH_VERSION-win-x64"
|
2021-01-27 20:15:29 +01:00
|
|
|
New-Item -ItemType directory -Path .\.pkg-cache
|
2021-09-02 22:04:02 +02:00
|
|
|
New-Item -ItemType directory -Path .\.pkg-cache\v$env:_WIN_PKG_VERSION
|
2021-10-05 22:20:18 +02:00
|
|
|
Invoke-RestMethod -Uri $fetchedUrl `
|
|
|
|
-OutFile ".\.pkg-cache\v$env:_WIN_PKG_VERSION\fetched-v$env:_WIN_PKG_FETCH_VERSION-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-10-05 22:20:18 +02:00
|
|
|
run: |
|
|
|
|
$major,$minor,$patch = $env:_PACKAGE_VERSION.split('.')
|
|
|
|
$versionInfo = @"
|
|
|
|
1 VERSIONINFO
|
|
|
|
FILEVERSION $major,$minor,$patch,0
|
|
|
|
PRODUCTVERSION $major,$minor,$patch,0
|
|
|
|
FILEOS 0x40004
|
|
|
|
FILETYPE 0x1
|
|
|
|
{
|
|
|
|
BLOCK "StringFileInfo"
|
|
|
|
{
|
|
|
|
BLOCK "040904b0"
|
|
|
|
{
|
|
|
|
VALUE "CompanyName", "Bitwarden Inc."
|
|
|
|
VALUE "ProductName", "Bitwarden"
|
|
|
|
VALUE "FileDescription", "Bitwarden CLI"
|
|
|
|
VALUE "FileVersion", "$env:_PACKAGE_VERSION"
|
|
|
|
VALUE "ProductVersion", "$env:_PACKAGE_VERSION"
|
|
|
|
VALUE "OriginalFilename", "bw.exe"
|
|
|
|
VALUE "InternalName", "bw"
|
|
|
|
VALUE "LegalCopyright", "Copyright Bitwarden Inc."
|
|
|
|
}
|
|
|
|
}
|
|
|
|
BLOCK "VarFileInfo"
|
|
|
|
{
|
|
|
|
VALUE "Translation", 0x0409 0x04B0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"@
|
|
|
|
$versionInfo | Out-File ./version-info.rc
|
2021-07-14 20:41:05 +02:00
|
|
|
# https://github.com/vercel/pkg-fetch/issues/188
|
2022-05-31 15:20:06 +02: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
|
2021-09-02 22:04:02 +02:00
|
|
|
set WIN_PKG=C:\Users\runneradmin\.pkg-cache\v%_WIN_PKG_VERSION%\fetched-v%_WIN_PKG_FETCH_VERSION%-win-x64
|
|
|
|
set WIN_PKG_BUILT=C:\Users\runneradmin\.pkg-cache\v%_WIN_PKG_VERSION%\built-v%_WIN_PKG_FETCH_VERSION%-win-x64
|
2021-07-14 20:41:05 +02:00
|
|
|
copy %WIN_PKG% %WIN_PKG_BUILT%
|
|
|
|
ResourceHacker -open %WIN_PKG_BUILT% -save %WIN_PKG_BUILT% -action delete -mask ICONGROUP,1,
|
2021-01-27 20:15:29 +01:00
|
|
|
ResourceHacker -open version-info.rc -save version-info.res -action compile
|
2021-07-14 20:41:05 +02:00
|
|
|
ResourceHacker -open %WIN_PKG_BUILT% -save %WIN_PKG_BUILT% -action addoverwrite -resource version-info.res
|
2021-01-06 20:26:25 +01:00
|
|
|
|
2021-06-30 19:17:18 +02:00
|
|
|
- name: Install
|
2021-12-03 21:34:59 +01:00
|
|
|
run: npm ci
|
2022-06-03 20:11:47 +02:00
|
|
|
working-directory: ./
|
2021-12-03 21:34:59 +01:00
|
|
|
|
2023-01-27 15:52:08 +01:00
|
|
|
- name: Build & Package Windows
|
2024-06-27 18:47:52 +02:00
|
|
|
run: npm run dist:${{ matrix.license_type.build_prefix }}:win --quiet
|
2023-01-27 15:52:08 +01:00
|
|
|
|
2021-01-08 20:19:52 +01:00
|
|
|
- name: Package Chocolatey
|
2021-01-08 23:32:16 +01:00
|
|
|
shell: pwsh
|
2024-08-22 16:54:23 +02:00
|
|
|
if: ${{ matrix.license_type.build_prefix == 'bit' }}
|
2021-01-08 23:32:16 +01:00
|
|
|
run: |
|
2021-01-14 22:13:17 +01:00
|
|
|
Copy-Item -Path stores/chocolatey -Destination dist/chocolatey -Recurse
|
2024-06-27 18:47:52 +02:00
|
|
|
Copy-Item dist/${{ matrix.license_type.build_prefix }}/windows/bw.exe -Destination dist/chocolatey/tools
|
2022-05-31 15:20:06 +02:00
|
|
|
Copy-Item ${{ github.workspace }}/LICENSE.txt -Destination dist/chocolatey/tools
|
2021-10-05 22:20:18 +02:00
|
|
|
choco pack dist/chocolatey/bitwarden-cli.nuspec --version ${{ env._PACKAGE_VERSION }} --out dist/chocolatey
|
2021-01-08 23:32:16 +01:00
|
|
|
|
2023-01-27 15:52:08 +01:00
|
|
|
- name: Zip Windows
|
2020-12-22 00:44:29 +01:00
|
|
|
shell: cmd
|
2024-06-27 18:47:52 +02:00
|
|
|
run: 7z a ./dist/bw${{ matrix.license_type.artifact_prefix}}-windows-%_PACKAGE_VERSION%.zip ./dist/${{ matrix.license_type.build_prefix }}/windows/bw.exe
|
2023-01-27 15:52:08 +01:00
|
|
|
|
2020-12-22 00:44:29 +01:00
|
|
|
- name: Version Test
|
|
|
|
run: |
|
2020-12-22 22:45:05 +01:00
|
|
|
dir ./dist/
|
2024-06-27 18:47:52 +02:00
|
|
|
Expand-Archive -Path "./dist/bw${{ matrix.license_type.artifact_prefix }}-windows-${env:_PACKAGE_VERSION}.zip" -DestinationPath "./test/${{ matrix.license_type.build_prefix }}/windows"
|
|
|
|
$testVersion = Invoke-Expression '& ./test/${{ matrix.license_type.build_prefix }}/windows/bw.exe -v'
|
2021-10-05 22:20:18 +02:00
|
|
|
echo "version: $env:_PACKAGE_VERSION"
|
2020-12-22 23:22:51 +01:00
|
|
|
echo "testVersion: $testVersion"
|
2021-10-05 22:20:18 +02:00
|
|
|
if($testVersion -ne $env:_PACKAGE_VERSION) {
|
2020-12-22 00:44:29 +01:00
|
|
|
Throw "Version test failed."
|
|
|
|
}
|
|
|
|
|
2023-01-27 15:52:08 +01:00
|
|
|
- name: Create checksums Windows
|
2020-12-22 00:44:29 +01:00
|
|
|
run: |
|
2024-06-27 18:47:52 +02:00
|
|
|
checksum -f="./dist/bw${{ matrix.license_type.artifact_prefix }}-windows-${env:_PACKAGE_VERSION}.zip" `
|
|
|
|
-t sha256 | Out-File -Encoding ASCII ./dist/bw${{ matrix.license_type.artifact_prefix }}-windows-sha256-${env:_PACKAGE_VERSION}.txt
|
2023-01-27 15:52:08 +01:00
|
|
|
|
2021-07-14 20:41:05 +02:00
|
|
|
- name: Upload windows zip asset
|
2024-10-17 16:45:49 +02:00
|
|
|
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
|
2020-12-23 00:21:15 +01:00
|
|
|
with:
|
2024-06-27 18:47:52 +02:00
|
|
|
name: bw${{ matrix.license_type.artifact_prefix }}-windows-${{ env._PACKAGE_VERSION }}.zip
|
|
|
|
path: apps/cli/dist/bw${{ matrix.license_type.artifact_prefix }}-windows-${{ env._PACKAGE_VERSION }}.zip
|
2021-10-05 22:20:18 +02:00
|
|
|
if-no-files-found: error
|
2020-12-23 00:21:15 +01:00
|
|
|
|
2021-07-14 20:41:05 +02:00
|
|
|
- name: Upload windows checksum asset
|
2024-10-17 16:45:49 +02:00
|
|
|
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
|
2020-12-23 00:21:15 +01:00
|
|
|
with:
|
2024-06-27 18:47:52 +02:00
|
|
|
name: bw${{ matrix.license_type.artifact_prefix }}-windows-sha256-${{ env._PACKAGE_VERSION }}.txt
|
|
|
|
path: apps/cli/dist/bw${{ matrix.license_type.artifact_prefix }}-windows-sha256-${{ env._PACKAGE_VERSION }}.txt
|
2021-10-05 22:20:18 +02:00
|
|
|
if-no-files-found: error
|
2020-12-23 00:21:15 +01:00
|
|
|
|
2021-07-14 20:41:05 +02:00
|
|
|
- name: Upload Chocolatey asset
|
2024-06-27 18:47:52 +02:00
|
|
|
if: matrix.license_type.build_prefix == 'bit'
|
2024-10-17 16:45:49 +02:00
|
|
|
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
|
2021-09-02 22:04:02 +02:00
|
|
|
with:
|
2021-10-05 22:20:18 +02:00
|
|
|
name: bitwarden-cli.${{ env._PACKAGE_VERSION }}.nupkg
|
2022-05-31 15:20:06 +02:00
|
|
|
path: apps/cli/dist/chocolatey/bitwarden-cli.${{ env._PACKAGE_VERSION }}.nupkg
|
2021-10-05 22:20:18 +02:00
|
|
|
if-no-files-found: error
|
2024-10-17 20:40:42 +02:00
|
|
|
|
2024-08-27 02:05:43 +02:00
|
|
|
- name: Zip NPM Build Artifact
|
|
|
|
run: Get-ChildItem -Path .\build | Compress-Archive -DestinationPath .\bitwarden-cli-${{ env._PACKAGE_VERSION }}-npm-build.zip
|
2020-12-23 00:21:15 +01:00
|
|
|
|
2021-10-05 22:20:18 +02:00
|
|
|
- name: Upload NPM Build Directory asset
|
2024-06-27 18:47:52 +02:00
|
|
|
if: matrix.license_type.build_prefix == 'bit'
|
2024-10-17 16:45:49 +02:00
|
|
|
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
|
2021-10-05 22:20:18 +02:00
|
|
|
with:
|
|
|
|
name: bitwarden-cli-${{ env._PACKAGE_VERSION }}-npm-build.zip
|
2024-08-27 02:05:43 +02:00
|
|
|
path: apps/cli/bitwarden-cli-${{ env._PACKAGE_VERSION }}-npm-build.zip
|
2021-10-05 22:20:18 +02:00
|
|
|
if-no-files-found: error
|
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
|
2024-03-06 19:10:56 +01:00
|
|
|
# Note, before updating the ubuntu version of the workflow, ensure the snap base image
|
|
|
|
# is equal or greater than the new version. Otherwise there might be GLIBC version issues.
|
|
|
|
# The snap base for CLI is defined in `apps/cli/stores/snap/snapcraft.yaml`
|
2023-08-25 23:06:31 +02:00
|
|
|
runs-on: ubuntu-22.04
|
2021-10-05 22:20:18 +02:00
|
|
|
needs: [setup, cli]
|
|
|
|
env:
|
|
|
|
_PACKAGE_VERSION: ${{ needs.setup.outputs.package_version }}
|
2020-12-22 00:44:29 +01:00
|
|
|
steps:
|
|
|
|
- name: Checkout repo
|
2024-10-17 16:45:49 +02:00
|
|
|
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
|
2020-12-22 00:44:29 +01:00
|
|
|
|
|
|
|
- name: Print environment
|
|
|
|
run: |
|
|
|
|
whoami
|
|
|
|
echo "GitHub ref: $GITHUB_REF"
|
|
|
|
echo "GitHub event: $GITHUB_EVENT"
|
2021-10-05 22:20:18 +02:00
|
|
|
echo "BW Package Version: $_PACKAGE_VERSION"
|
2020-12-22 00:44:29 +01:00
|
|
|
|
2021-01-27 23:48:50 +01:00
|
|
|
- name: Get bw linux cli
|
2024-08-26 22:45:28 +02:00
|
|
|
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
|
2021-01-27 23:48:50 +01:00
|
|
|
with:
|
2024-06-27 18:47:52 +02:00
|
|
|
name: bw-linux-${{ env._PACKAGE_VERSION }}.zip
|
2022-05-31 15:20:06 +02:00
|
|
|
path: apps/cli/dist/snap
|
2021-01-27 23:48:50 +01:00
|
|
|
|
2021-08-12 19:04:37 +02:00
|
|
|
- name: Setup 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-10-05 22:20:18 +02:00
|
|
|
sed -i s/__version__/${{ env._PACKAGE_VERSION }}/g dist/snap/snapcraft.yaml
|
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
|
|
|
|
2021-08-12 00:38:05 +02:00
|
|
|
- name: Build snap
|
2024-08-26 22:45:28 +02:00
|
|
|
uses: snapcore/action-build@3bdaa03e1ba6bf59a65f84a751d943d549a54e79 # v1.3.0
|
2021-08-12 00:38:05 +02:00
|
|
|
with:
|
2022-05-31 15:20:06 +02:00
|
|
|
path: apps/cli/dist/snap
|
2021-08-12 00:38:05 +02:00
|
|
|
|
|
|
|
- name: Create checksum
|
|
|
|
run: |
|
|
|
|
cd dist/snap
|
|
|
|
ls -alth
|
2021-10-05 22:20:18 +02: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-09-02 22:04:02 +02: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'
|
2021-10-05 22:20:18 +02:00
|
|
|
if($testVersion -ne $env:_PACKAGE_VERSION) {
|
2020-12-22 00:44:29 +01:00
|
|
|
Throw "Version test failed."
|
|
|
|
}
|
2021-04-02 19:25:15 +02:00
|
|
|
env:
|
|
|
|
BITWARDENCLI_APPDATA_DIR: "/home/runner/snap/bw/x1/.config/Bitwarden CLI"
|
2020-12-22 00:44:29 +01:00
|
|
|
|
|
|
|
- name: Cleanup Test & Update Snap for Publish
|
|
|
|
shell: pwsh
|
2022-03-17 17:27:04 +01:00
|
|
|
run: sudo snap remove bw
|
2021-01-11 17:27:01 +01:00
|
|
|
|
2021-07-14 20:41:05 +02:00
|
|
|
- name: Upload snap asset
|
2024-10-17 16:45:49 +02:00
|
|
|
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
|
2021-01-09 00:28:32 +01:00
|
|
|
with:
|
2021-10-05 22:20:18 +02:00
|
|
|
name: bw_${{ env._PACKAGE_VERSION }}_amd64.snap
|
2022-05-31 15:20:06 +02:00
|
|
|
path: apps/cli/dist/snap/bw_${{ env._PACKAGE_VERSION }}_amd64.snap
|
2021-10-05 22:20:18 +02:00
|
|
|
if-no-files-found: error
|
2020-12-22 00:44:29 +01:00
|
|
|
|
2021-07-14 20:41:05 +02:00
|
|
|
- name: Upload snap checksum asset
|
2024-10-17 16:45:49 +02:00
|
|
|
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
|
2021-01-11 19:00:05 +01:00
|
|
|
with:
|
2021-10-05 22:20:18 +02:00
|
|
|
name: bw-snap-sha256-${{ env._PACKAGE_VERSION }}.txt
|
2022-05-31 15:20:06 +02:00
|
|
|
path: apps/cli/dist/snap/bw-snap-sha256-${{ env._PACKAGE_VERSION }}.txt
|
2021-10-05 22:20:18 +02:00
|
|
|
if-no-files-found: error
|
2021-10-14 16:38:43 +02:00
|
|
|
|
|
|
|
|
|
|
|
check-failures:
|
|
|
|
name: Check for failures
|
|
|
|
if: always()
|
2023-08-28 21:31:09 +02:00
|
|
|
runs-on: ubuntu-22.04
|
2021-10-14 16:38:43 +02:00
|
|
|
needs:
|
|
|
|
- setup
|
|
|
|
- cli
|
2023-02-10 17:00:24 +01:00
|
|
|
- cli-windows
|
2021-10-14 16:38:43 +02:00
|
|
|
- snap
|
|
|
|
steps:
|
|
|
|
- name: Check if any job failed
|
2022-05-31 17:00:32 +02:00
|
|
|
working-directory: ${{ github.workspace }}
|
2024-03-06 14:59:18 +01:00
|
|
|
if: (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/rc' || github.ref == 'refs/heads/hotfix-rc') && contains(needs.*.result, 'failure')
|
|
|
|
run: exit 1
|
2022-05-31 15:20:06 +02:00
|
|
|
|
2021-10-14 16:38:43 +02:00
|
|
|
- name: Login to Azure - Prod Subscription
|
2024-02-08 20:38:19 +01:00
|
|
|
uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0
|
2021-10-14 16:38:43 +02:00
|
|
|
if: failure()
|
|
|
|
with:
|
2023-04-11 18:37:58 +02:00
|
|
|
creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}
|
2021-10-14 16:38:43 +02:00
|
|
|
|
|
|
|
- name: Retrieve secrets
|
|
|
|
id: retrieve-secrets
|
|
|
|
if: failure()
|
2023-11-08 19:08:34 +01:00
|
|
|
uses: bitwarden/gh-actions/get-keyvault-secrets@main
|
2022-10-13 21:38:47 +02:00
|
|
|
with:
|
2023-04-11 18:37:58 +02:00
|
|
|
keyvault: "bitwarden-ci"
|
2022-10-13 21:38:47 +02:00
|
|
|
secrets: "devops-alerts-slack-webhook-url"
|
2021-10-14 16:38:43 +02:00
|
|
|
|
|
|
|
- name: Notify Slack on failure
|
2024-08-26 22:45:28 +02:00
|
|
|
uses: act10ns/slack@44541246747a30eb3102d87f7a4cc5471b0ffb7d # v2.1.0
|
2021-10-14 16:38:43 +02:00
|
|
|
if: failure()
|
|
|
|
env:
|
|
|
|
SLACK_WEBHOOK_URL: ${{ steps.retrieve-secrets.outputs.devops-alerts-slack-webhook-url }}
|
|
|
|
with:
|
|
|
|
status: ${{ job.status }}
|