From 3c8eeb4420d3289d90f72f045cb09ffcd25824df Mon Sep 17 00:00:00 2001 From: Addison Beck Date: Thu, 27 Jun 2024 12:47:52 -0400 Subject: [PATCH] Remove the `bit` prefix from Bitwarden License managed build artifacts (#9855) * Rename `license_type.prefix` to `license_type.build_prefix` * Introduce `license_type.artifact_prefix` * Remove the `bit` prefix from Bitwarden License managed build artifacts * Update the release job to download the correct artifacts * Update .github/workflows/build-cli.yml Co-authored-by: Joseph Flinn <58369717+joseph-flinn@users.noreply.github.com> * Update .github/workflows/build-cli.yml Co-authored-by: Joseph Flinn <58369717+joseph-flinn@users.noreply.github.com> * Update .github/workflows/build-cli.yml Co-authored-by: Joseph Flinn <58369717+joseph-flinn@users.noreply.github.com> --------- Co-authored-by: Joseph Flinn <58369717+joseph-flinn@users.noreply.github.com> --- .github/workflows/build-cli.yml | 64 +++++++++++++++---------------- .github/workflows/release-cli.yml | 12 +++--- 2 files changed, 36 insertions(+), 40 deletions(-) diff --git a/.github/workflows/build-cli.yml b/.github/workflows/build-cli.yml index 1c2693f2de..ad2ac53971 100644 --- a/.github/workflows/build-cli.yml +++ b/.github/workflows/build-cli.yml @@ -71,8 +71,8 @@ jobs: ] license_type: [ - { prefix: "oss", readable: "open source license" }, - { prefix: "bit", readable: "commercial license"} + { build_prefix: "oss", artifact_prefix: "-oss", readable: "open source license" }, + { build_prefix: "bit", artifact_prefix: "", readable: "commercial license"} ] runs-on: ${{ matrix.os.distro }} needs: @@ -104,16 +104,16 @@ jobs: working-directory: ./ - name: Build & Package Unix - run: npm run dist:${{ matrix.license_type.prefix }}:${{ env.SHORT_RUNNER_OS }} --quiet + run: npm run dist:${{ matrix.license_type.build_prefix }}:${{ env.SHORT_RUNNER_OS }} --quiet - name: Zip Unix run: | - cd ./dist/${{ matrix.license_type.prefix }}/${{ env.LOWER_RUNNER_OS }} - zip ../../bw-${{ matrix.license_type.prefix }}-${{ env.LOWER_RUNNER_OS }}-${{ env._PACKAGE_VERSION }}.zip ./bw + 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 - name: Version Test run: | - unzip "./dist/bw-${{ matrix.license_type.prefix }}-${{ env.LOWER_RUNNER_OS }}-${{ env._PACKAGE_VERSION }}.zip" -d "./test" + unzip "./dist/bw${{ matrix.license_type.artifact_prefix }}-${{ env.LOWER_RUNNER_OS }}-${{ env._PACKAGE_VERSION }}.zip" -d "./test" testVersion=$(./test/bw -v) echo "version: $_PACKAGE_VERSION" echo "testVersion: $testVersion" @@ -125,21 +125,22 @@ jobs: - name: Create checksums Unix run: | cd ./dist - shasum -a 256 bw-${{ matrix.license_type.prefix }}-${{ env.LOWER_RUNNER_OS }}-${{ env._PACKAGE_VERSION }}.zip \ - | awk '{split($0, a); print a[1]}' > bw-${{ matrix.license_type.prefix }}-${{ env.LOWER_RUNNER_OS }}-sha256-${{ env._PACKAGE_VERSION }}.txt + 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 - name: Upload unix zip asset uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 with: - name: bw-${{ matrix.license_type.prefix }}-${{ env.LOWER_RUNNER_OS }}-${{ env._PACKAGE_VERSION }}.zip - path: apps/cli/dist/bw-${{ matrix.license_type.prefix }}-${{ env.LOWER_RUNNER_OS }}-${{ env._PACKAGE_VERSION }}.zip + 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 if-no-files-found: error - name: Upload unix checksum asset uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 with: - name: bw-${{ matrix.license_type.prefix }}-${{ env.LOWER_RUNNER_OS }}-sha256-${{ env._PACKAGE_VERSION }}.txt - path: apps/cli/dist/bw-${{ matrix.license_type.prefix }}-${{ env.LOWER_RUNNER_OS }}-sha256-${{ env._PACKAGE_VERSION }}.txt + 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 if-no-files-found: error cli-windows: @@ -148,8 +149,8 @@ jobs: matrix: license_type: [ - { prefix: "oss", readable: "open source license" }, - { prefix: "bit", readable: "commercial license"} + { build_prefix: "oss", artifact_prefix: "-oss", readable: "open source license" }, + { build_prefix: "bit", artifact_prefix: "", readable: "commercial license"} ] runs-on: windows-2022 needs: @@ -236,26 +237,26 @@ jobs: working-directory: ./ - name: Build & Package Windows - run: npm run dist:${{ matrix.license_type.prefix }}:win --quiet + run: npm run dist:${{ matrix.license_type.build_prefix }}:win --quiet - name: Package Chocolatey shell: pwsh - if: ${{ matrix.license_type.prefix }} == 'bit' + if: ${{ matrix.license_type.build_prefix }} == 'bit' run: | Copy-Item -Path stores/chocolatey -Destination dist/chocolatey -Recurse - Copy-Item dist/${{ matrix.license_type.prefix }}/windows/bw.exe -Destination dist/chocolatey/tools + Copy-Item dist/${{ matrix.license_type.build_prefix }}/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 Windows shell: cmd - run: 7z a ./dist/bw-${{ matrix.license_type.prefix }}-windows-%_PACKAGE_VERSION%.zip ./dist/${{ matrix.license_type.prefix }}/windows/bw.exe + run: 7z a ./dist/bw${{ matrix.license_type.artifact_prefix}}-windows-%_PACKAGE_VERSION%.zip ./dist/${{ matrix.license_type.build_prefix }}/windows/bw.exe - name: Version Test run: | dir ./dist/ - Expand-Archive -Path "./dist/bw-${{ matrix.license_type.prefix }}-windows-${env:_PACKAGE_VERSION}.zip" -DestinationPath "./test/${{ matrix.license_type.prefix }}/windows" - $testVersion = Invoke-Expression '& ./test/${{ matrix.license_type.prefix }}/windows/bw.exe -v' + 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' echo "version: $env:_PACKAGE_VERSION" echo "testVersion: $testVersion" if($testVersion -ne $env:_PACKAGE_VERSION) { @@ -264,25 +265,25 @@ jobs: - name: Create checksums Windows run: | - checksum -f="./dist/bw-${{ matrix.license_type.prefix }}-windows-${env:_PACKAGE_VERSION}.zip" ` - -t sha256 | Out-File -Encoding ASCII ./dist/bw-${{ matrix.license_type.prefix }}-windows-sha256-${env:_PACKAGE_VERSION}.txt + 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 - name: Upload windows zip asset uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 with: - name: bw-${{ matrix.license_type.prefix }}-windows-${{ env._PACKAGE_VERSION }}.zip - path: apps/cli/dist/bw-${{ matrix.license_type.prefix }}-windows-${{ env._PACKAGE_VERSION }}.zip + 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 if-no-files-found: error - name: Upload windows checksum asset uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 with: - name: bw-${{ matrix.license_type.prefix }}-windows-sha256-${{ env._PACKAGE_VERSION }}.txt - path: apps/cli/dist/bw-${{ matrix.license_type.prefix }}-windows-sha256-${{ env._PACKAGE_VERSION }}.txt + 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 if-no-files-found: error - name: Upload Chocolatey asset - if: matrix.license_type.prefix == 'bit' + if: matrix.license_type.build_prefix == 'bit' uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 with: name: bitwarden-cli.${{ env._PACKAGE_VERSION }}.nupkg @@ -290,7 +291,7 @@ jobs: if-no-files-found: error - name: Upload NPM Build Directory asset - if: matrix.license_type.prefix == 'bit' + if: matrix.license_type.build_prefix == 'bit' uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 with: name: bitwarden-cli-${{ env._PACKAGE_VERSION }}-npm-build.zip @@ -320,14 +321,9 @@ jobs: - name: Get bw linux cli uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4 with: - name: bw-bit-linux-${{ env._PACKAGE_VERSION }}.zip + name: bw-linux-${{ env._PACKAGE_VERSION }}.zip path: apps/cli/dist/snap - - name: Rename snap artifact - run: | - cd dist/snap - mv bw-bit-linux-${{ env._PACKAGE_VERSION }}.zip bw-linux-${{ env._PACKAGE_VERSION }}.zip - - name: Setup Snap Package run: | cp -r stores/snap/* -t dist/snap diff --git a/.github/workflows/release-cli.yml b/.github/workflows/release-cli.yml index 5b511cd1d9..6d56c3be83 100644 --- a/.github/workflows/release-cli.yml +++ b/.github/workflows/release-cli.yml @@ -102,16 +102,16 @@ jobs: with: artifacts: "apps/cli/bw-oss-windows-${{ env.PKG_VERSION }}.zip, apps/cli/bw-oss-windows-sha256-${{ env.PKG_VERSION }}.txt, - apps/cli/bw-bit-windows-${{ env.PKG_VERSION }}.zip, - apps/cli/bw-bit-windows-sha256-${{ env.PKG_VERSION }}.txt, + apps/cli/bw-windows-${{ env.PKG_VERSION }}.zip, + apps/cli/bw-windows-sha256-${{ env.PKG_VERSION }}.txt, apps/cli/bw-oss-macos-${{ env.PKG_VERSION }}.zip, apps/cli/bw-oss-macos-sha256-${{ env.PKG_VERSION }}.txt, - apps/cli/bw-bit-macos-${{ env.PKG_VERSION }}.zip, - apps/cli/bw-bit-macos-sha256-${{ env.PKG_VERSION }}.txt, + apps/cli/bw-macos-${{ env.PKG_VERSION }}.zip, + apps/cli/bw-macos-sha256-${{ env.PKG_VERSION }}.txt, apps/cli/bw-oss-linux-${{ env.PKG_VERSION }}.zip, apps/cli/bw-oss-linux-sha256-${{ env.PKG_VERSION }}.txt, - apps/cli/bw-bit-linux-${{ env.PKG_VERSION }}.zip, - apps/cli/bw-bit-linux-sha256-${{ env.PKG_VERSION }}.txt, + apps/cli/bw-linux-${{ env.PKG_VERSION }}.zip, + apps/cli/bw-linux-sha256-${{ env.PKG_VERSION }}.txt, apps/cli/bitwarden-cli.${{ env.PKG_VERSION }}.nupkg, apps/cli/bw_${{ env.PKG_VERSION }}_amd64.snap, apps/cli/bw-snap-sha256-${{ env.PKG_VERSION }}.txt"