2021-09-02 22:04:02 +02:00
|
|
|
---
|
2022-05-31 15:20:06 +02:00
|
|
|
name: Release CLI
|
2022-11-08 16:02:51 +01:00
|
|
|
run-name: Release CLI ${{ inputs.release_type }}
|
2021-01-27 20:15:29 +01:00
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_dispatch:
|
2021-12-20 21:19:31 +01:00
|
|
|
inputs:
|
|
|
|
release_type:
|
|
|
|
description: 'Release Options'
|
|
|
|
required: true
|
|
|
|
default: 'Initial Release'
|
|
|
|
type: choice
|
|
|
|
options:
|
|
|
|
- Initial Release
|
|
|
|
- Redeploy
|
2022-02-25 15:12:07 +01:00
|
|
|
- Dry Run
|
2022-07-15 15:29:56 +02:00
|
|
|
snap_publish:
|
|
|
|
description: 'Publish to snap store'
|
|
|
|
required: true
|
|
|
|
default: true
|
|
|
|
type: boolean
|
|
|
|
choco_publish:
|
|
|
|
description: 'Publish to chocolatey store'
|
|
|
|
required: true
|
|
|
|
default: true
|
|
|
|
type: boolean
|
|
|
|
npm_publish:
|
|
|
|
description: 'Publish to npm registry'
|
|
|
|
required: true
|
|
|
|
default: true
|
|
|
|
type: boolean
|
|
|
|
|
2021-01-27 20:15:29 +01:00
|
|
|
|
2022-05-31 15:20:06 +02:00
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
working-directory: apps/cli
|
|
|
|
|
2021-01-27 20:15:29 +01:00
|
|
|
jobs:
|
|
|
|
setup:
|
2021-09-02 22:04:02 +02:00
|
|
|
name: Setup
|
2021-09-21 16:23:06 +02:00
|
|
|
runs-on: ubuntu-20.04
|
2021-01-27 20:15:29 +01:00
|
|
|
outputs:
|
2022-06-01 19:03:05 +02:00
|
|
|
release-version: ${{ steps.version.outputs.version }}
|
2021-01-27 20:15:29 +01:00
|
|
|
steps:
|
2022-06-30 19:26:35 +02:00
|
|
|
- name: Checkout repo
|
2023-06-29 16:46:56 +02:00
|
|
|
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
2022-06-30 19:26:35 +02:00
|
|
|
|
2021-06-01 22:50:53 +02:00
|
|
|
- name: Branch check
|
2022-02-25 15:12:07 +01:00
|
|
|
if: ${{ github.event.inputs.release_type != 'Dry Run' }}
|
2021-06-01 22:50:53 +02:00
|
|
|
run: |
|
2022-11-16 16:48:49 +01:00
|
|
|
if [[ "$GITHUB_REF" != "refs/heads/rc" ]] && [[ "$GITHUB_REF" != "refs/heads/hotfix-rc-cli" ]]; then
|
2021-06-01 22:50:53 +02:00
|
|
|
echo "==================================="
|
2022-08-16 17:55:57 +02:00
|
|
|
echo "[!] Can only release from the 'rc' or 'hotfix-rc-cli' branches"
|
2021-06-01 22:50:53 +02:00
|
|
|
echo "==================================="
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-06-01 19:03:05 +02:00
|
|
|
- name: Check Release Version
|
|
|
|
id: version
|
2023-10-25 16:35:46 +02:00
|
|
|
uses: bitwarden/gh-actions/release-version-check@master
|
2022-06-01 19:03:05 +02:00
|
|
|
with:
|
|
|
|
release-type: ${{ github.event.inputs.release_type }}
|
|
|
|
project-type: ts
|
|
|
|
file: apps/cli/package.json
|
|
|
|
monorepo: true
|
|
|
|
monorepo-project: cli
|
2021-10-05 22:20:18 +02:00
|
|
|
|
2022-11-14 19:43:28 +01:00
|
|
|
- name: Create GitHub deployment
|
|
|
|
if: ${{ github.event.inputs.release_type != 'Dry Run' }}
|
2023-05-05 22:17:19 +02:00
|
|
|
uses: chrnorm/deployment-action@d42cde7132fcec920de534fffc3be83794335c00 # v2.0.5
|
2022-07-25 23:20:17 +02:00
|
|
|
id: deployment
|
|
|
|
with:
|
|
|
|
token: '${{ secrets.GITHUB_TOKEN }}'
|
2022-08-08 19:21:49 +02:00
|
|
|
initial-status: 'in_progress'
|
2022-07-25 23:20:17 +02:00
|
|
|
environment: 'CLI - Production'
|
|
|
|
description: 'Deployment ${{ steps.version.outputs.version }} from branch ${{ github.ref_name }}'
|
|
|
|
task: release
|
|
|
|
|
2022-07-01 17:44:20 +02:00
|
|
|
- name: Download all Release artifacts
|
|
|
|
if: ${{ github.event.inputs.release_type != 'Dry Run' }}
|
2023-10-25 16:35:46 +02:00
|
|
|
uses: bitwarden/gh-actions/download-artifacts@master
|
2021-10-05 22:20:18 +02:00
|
|
|
with:
|
2022-05-31 15:20:06 +02:00
|
|
|
workflow: build-cli.yml
|
|
|
|
path: apps/cli
|
2021-10-05 22:20:18 +02:00
|
|
|
workflow_conclusion: success
|
2022-06-22 14:32:45 +02:00
|
|
|
branch: ${{ github.ref_name }}
|
2021-10-05 22:20:18 +02:00
|
|
|
|
2022-11-14 15:35:42 +01:00
|
|
|
- name: Dry Run - Download all artifacts
|
2022-07-01 17:44:20 +02:00
|
|
|
if: ${{ github.event.inputs.release_type == 'Dry Run' }}
|
2023-10-25 16:35:46 +02:00
|
|
|
uses: bitwarden/gh-actions/download-artifacts@master
|
2022-07-01 17:44:20 +02:00
|
|
|
with:
|
|
|
|
workflow: build-cli.yml
|
|
|
|
path: apps/cli
|
|
|
|
workflow_conclusion: success
|
|
|
|
branch: master
|
|
|
|
|
2021-10-05 22:20:18 +02:00
|
|
|
- name: Create release
|
2022-06-22 14:32:45 +02:00
|
|
|
if: ${{ github.event.inputs.release_type != 'Dry Run' }}
|
2023-05-05 22:17:19 +02:00
|
|
|
uses: ncipollo/release-action@a2e71bdd4e7dab70ca26a852f29600c98b33153e # v1.12.0
|
2021-10-05 22:20:18 +02:00
|
|
|
env:
|
2022-06-01 19:03:05 +02:00
|
|
|
PKG_VERSION: ${{ steps.version.outputs.version }}
|
2021-01-27 20:15:29 +01:00
|
|
|
with:
|
2022-05-31 15:20:06 +02:00
|
|
|
artifacts: "apps/cli/bw-windows-${{ env.PKG_VERSION }}.zip,
|
|
|
|
apps/cli/bw-windows-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-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"
|
2021-10-05 22:20:18 +02:00
|
|
|
commit: ${{ github.sha }}
|
2022-05-31 15:20:06 +02:00
|
|
|
tag: cli-v${{ env.PKG_VERSION }}
|
|
|
|
name: CLI v${{ env.PKG_VERSION }}
|
2021-10-05 22:20:18 +02:00
|
|
|
body: "<insert release notes here>"
|
|
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
2021-01-27 20:15:29 +01:00
|
|
|
draft: true
|
|
|
|
|
2022-07-25 23:20:17 +02:00
|
|
|
- name: Update deployment status to Success
|
2022-11-14 19:43:28 +01:00
|
|
|
if: ${{ github.event.inputs.release_type != 'Dry Run' && success() }}
|
2023-05-05 22:17:19 +02:00
|
|
|
uses: chrnorm/deployment-status@2afb7d27101260f4a764219439564d954d10b5b0 # v2.0.1
|
2022-07-25 23:20:17 +02:00
|
|
|
with:
|
|
|
|
token: '${{ secrets.GITHUB_TOKEN }}'
|
|
|
|
state: 'success'
|
|
|
|
deployment-id: ${{ steps.deployment.outputs.deployment_id }}
|
|
|
|
|
|
|
|
- name: Update deployment status to Failure
|
2022-11-14 19:43:28 +01:00
|
|
|
if: ${{ github.event.inputs.release_type != 'Dry Run' && failure() }}
|
2023-05-05 22:17:19 +02:00
|
|
|
uses: chrnorm/deployment-status@2afb7d27101260f4a764219439564d954d10b5b0 # v2.0.1
|
2022-07-25 23:20:17 +02:00
|
|
|
with:
|
|
|
|
token: '${{ secrets.GITHUB_TOKEN }}'
|
|
|
|
state: 'failure'
|
|
|
|
deployment-id: ${{ steps.deployment.outputs.deployment_id }}
|
2021-01-27 20:15:29 +01:00
|
|
|
|
2021-10-05 22:20:18 +02:00
|
|
|
snap:
|
|
|
|
name: Deploy Snap
|
|
|
|
runs-on: ubuntu-20.04
|
2021-01-27 20:15:29 +01:00
|
|
|
needs: setup
|
2022-07-15 15:29:56 +02:00
|
|
|
if: inputs.snap_publish
|
2021-07-14 20:41:05 +02:00
|
|
|
env:
|
2022-06-01 19:03:05 +02:00
|
|
|
_PKG_VERSION: ${{ needs.setup.outputs.release-version }}
|
2021-01-27 20:15:29 +01:00
|
|
|
steps:
|
|
|
|
- name: Checkout repo
|
2023-06-29 16:46:56 +02:00
|
|
|
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
2021-01-27 20:15:29 +01:00
|
|
|
|
2022-02-10 20:34:51 +01:00
|
|
|
- name: Login to Azure
|
2023-05-09 18:38:11 +02:00
|
|
|
uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7
|
2022-02-10 20:34:51 +01:00
|
|
|
with:
|
2023-04-11 18:37:58 +02:00
|
|
|
creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}
|
2022-02-10 20:34:51 +01:00
|
|
|
|
|
|
|
- name: Retrieve secrets
|
|
|
|
id: retrieve-secrets
|
2023-10-25 16:35:46 +02:00
|
|
|
uses: bitwarden/gh-actions/get-keyvault-secrets@master
|
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: "snapcraft-store-token"
|
2022-02-10 20:34:51 +01:00
|
|
|
|
|
|
|
- name: Install Snap
|
2023-07-11 00:56:57 +02:00
|
|
|
uses: samuelmeuli/action-snapcraft@d33c176a9b784876d966f80fb1b461808edc0641 # v2.1.1
|
2021-01-28 17:42:01 +01:00
|
|
|
|
2021-10-05 22:20:18 +02:00
|
|
|
- name: Download artifacts
|
2022-07-19 21:01:14 +02:00
|
|
|
if: ${{ github.event.inputs.release_type != 'Dry Run' }}
|
2023-10-25 16:35:46 +02:00
|
|
|
uses: bitwarden/gh-actions/download-artifacts@master
|
2021-01-27 20:15:29 +01:00
|
|
|
with:
|
2022-05-31 15:20:06 +02:00
|
|
|
workflow: build-cli.yml
|
|
|
|
path: apps/cli
|
2021-10-05 22:20:18 +02:00
|
|
|
workflow_conclusion: success
|
2022-06-22 14:32:45 +02:00
|
|
|
branch: ${{ github.ref_name }}
|
2021-10-05 22:20:18 +02:00
|
|
|
artifacts: bw_${{ env._PKG_VERSION }}_amd64.snap
|
2021-01-27 20:15:29 +01:00
|
|
|
|
2022-11-14 15:35:42 +01:00
|
|
|
- name: Dry Run - Download artifacts
|
2022-07-19 21:01:14 +02:00
|
|
|
if: ${{ github.event.inputs.release_type == 'Dry Run' }}
|
2023-10-25 16:35:46 +02:00
|
|
|
uses: bitwarden/gh-actions/download-artifacts@master
|
2022-07-19 21:01:14 +02:00
|
|
|
with:
|
|
|
|
workflow: build-cli.yml
|
|
|
|
path: apps/cli
|
|
|
|
workflow_conclusion: success
|
|
|
|
branch: master
|
|
|
|
artifacts: bw_${{ env._PKG_VERSION }}_amd64.snap
|
|
|
|
|
2021-10-05 22:20:18 +02:00
|
|
|
- name: Publish Snap & logout
|
2022-02-25 15:12:07 +01:00
|
|
|
if: ${{ github.event.inputs.release_type != 'Dry Run' }}
|
2023-08-28 22:12:40 +02:00
|
|
|
env:
|
|
|
|
SNAPCRAFT_STORE_CREDENTIALS: ${{ steps.retrieve-secrets.outputs.snapcraft-store-token }}
|
2021-10-05 22:20:18 +02:00
|
|
|
run: |
|
2023-10-05 21:14:10 +02:00
|
|
|
snapcraft upload bw_${{ env._PKG_VERSION }}_amd64.snap --release stable
|
2021-10-05 22:20:18 +02:00
|
|
|
snapcraft logout
|
2021-01-27 20:15:29 +01:00
|
|
|
|
2021-10-05 22:20:18 +02:00
|
|
|
choco:
|
|
|
|
name: Deploy Choco
|
|
|
|
runs-on: windows-2019
|
|
|
|
needs: setup
|
2022-07-15 15:29:56 +02:00
|
|
|
if: inputs.choco_publish
|
2021-10-05 22:20:18 +02:00
|
|
|
env:
|
2022-06-01 19:03:05 +02:00
|
|
|
_PKG_VERSION: ${{ needs.setup.outputs.release-version }}
|
2021-10-05 22:20:18 +02:00
|
|
|
steps:
|
|
|
|
- name: Checkout repo
|
2023-06-29 16:46:56 +02:00
|
|
|
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
2021-01-27 20:15:29 +01:00
|
|
|
|
2022-06-30 18:32:03 +02:00
|
|
|
- name: Login to Azure
|
2023-05-09 18:38:11 +02:00
|
|
|
uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7
|
2022-06-30 18:32:03 +02:00
|
|
|
with:
|
2023-04-11 18:37:58 +02:00
|
|
|
creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}
|
2022-06-30 18:32:03 +02:00
|
|
|
|
|
|
|
- name: Retrieve secrets
|
|
|
|
id: retrieve-secrets
|
2023-10-25 16:35:46 +02:00
|
|
|
uses: bitwarden/gh-actions/get-keyvault-secrets@master
|
2022-10-12 17:31:20 +02:00
|
|
|
with:
|
2023-04-11 18:37:58 +02:00
|
|
|
keyvault: "bitwarden-ci"
|
2022-10-12 17:31:20 +02:00
|
|
|
secrets: "cli-choco-api-key"
|
2022-06-30 18:32:03 +02:00
|
|
|
|
2021-10-05 22:20:18 +02:00
|
|
|
- name: Setup Chocolatey
|
|
|
|
run: choco apikey --key $env:CHOCO_API_KEY --source https://push.chocolatey.org/
|
2021-01-27 20:15:29 +01:00
|
|
|
env:
|
2022-06-30 18:32:03 +02:00
|
|
|
CHOCO_API_KEY: ${{ steps.retrieve-secrets.outputs.cli-choco-api-key }}
|
2021-01-27 20:15:29 +01:00
|
|
|
|
2021-10-27 22:10:18 +02:00
|
|
|
- name: Make dist dir
|
|
|
|
shell: pwsh
|
|
|
|
run: New-Item -ItemType directory -Path ./dist
|
|
|
|
|
2021-10-05 22:20:18 +02:00
|
|
|
- name: Download artifacts
|
2022-07-19 21:01:14 +02:00
|
|
|
if: ${{ github.event.inputs.release_type != 'Dry Run' }}
|
2023-10-25 16:35:46 +02:00
|
|
|
uses: bitwarden/gh-actions/download-artifacts@master
|
2021-01-27 20:15:29 +01:00
|
|
|
with:
|
2022-05-31 15:20:06 +02:00
|
|
|
workflow: build-cli.yml
|
2022-07-05 16:42:02 +02:00
|
|
|
path: apps/cli/dist
|
2021-10-05 22:20:18 +02:00
|
|
|
workflow_conclusion: success
|
2022-06-22 14:32:45 +02:00
|
|
|
branch: ${{ github.ref_name }}
|
2021-10-05 22:20:18 +02:00
|
|
|
artifacts: bitwarden-cli.${{ env._PKG_VERSION }}.nupkg
|
|
|
|
|
2022-11-14 15:35:42 +01:00
|
|
|
- name: Dry Run - Download artifacts
|
2022-07-19 21:01:14 +02:00
|
|
|
if: ${{ github.event.inputs.release_type == 'Dry Run' }}
|
2023-10-25 16:35:46 +02:00
|
|
|
uses: bitwarden/gh-actions/download-artifacts@master
|
2022-07-19 21:01:14 +02:00
|
|
|
with:
|
|
|
|
workflow: build-cli.yml
|
|
|
|
path: apps/cli/dist
|
|
|
|
workflow_conclusion: success
|
|
|
|
branch: master
|
|
|
|
artifacts: bitwarden-cli.${{ env._PKG_VERSION }}.nupkg
|
|
|
|
|
2021-10-05 22:20:18 +02:00
|
|
|
- name: Push to Chocolatey
|
2022-02-25 15:12:07 +01:00
|
|
|
if: ${{ github.event.inputs.release_type != 'Dry Run' }}
|
2021-10-05 22:20:18 +02:00
|
|
|
shell: pwsh
|
2021-10-27 22:10:18 +02:00
|
|
|
run: |
|
|
|
|
cd dist
|
2023-07-13 16:08:36 +02:00
|
|
|
choco push --source=https://push.chocolatey.org/
|
2021-01-27 20:15:29 +01:00
|
|
|
|
2021-10-05 22:20:18 +02:00
|
|
|
npm:
|
|
|
|
name: Publish NPM
|
2021-09-21 16:23:06 +02:00
|
|
|
runs-on: ubuntu-20.04
|
2021-10-05 22:20:18 +02:00
|
|
|
needs: setup
|
2022-07-15 15:29:56 +02:00
|
|
|
if: inputs.npm_publish
|
2021-10-27 22:10:18 +02:00
|
|
|
env:
|
2022-06-01 19:03:05 +02:00
|
|
|
_PKG_VERSION: ${{ needs.setup.outputs.release-version }}
|
2021-01-27 20:15:29 +01:00
|
|
|
steps:
|
|
|
|
- name: Checkout repo
|
2023-06-29 16:46:56 +02:00
|
|
|
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
2021-01-28 17:42:01 +01:00
|
|
|
|
2022-07-05 16:42:02 +02:00
|
|
|
- name: Login to Azure
|
2023-05-09 18:38:11 +02:00
|
|
|
uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7
|
2022-07-05 16:42:02 +02:00
|
|
|
with:
|
2023-04-11 18:37:58 +02:00
|
|
|
creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}
|
2022-07-05 16:42:02 +02:00
|
|
|
|
|
|
|
- name: Retrieve secrets
|
|
|
|
id: retrieve-secrets
|
2023-10-25 16:35:46 +02:00
|
|
|
uses: bitwarden/gh-actions/get-keyvault-secrets@master
|
2022-10-13 21:38:47 +02:00
|
|
|
with:
|
2023-04-11 18:37:58 +02:00
|
|
|
keyvault: "bitwarden-ci"
|
2023-01-25 15:12:18 +01:00
|
|
|
secrets: "npm-api-key"
|
2022-07-05 16:42:02 +02:00
|
|
|
|
2021-10-05 22:20:18 +02:00
|
|
|
- name: Download artifacts
|
2022-07-19 21:01:14 +02:00
|
|
|
if: ${{ github.event.inputs.release_type != 'Dry Run' }}
|
2023-10-25 16:35:46 +02:00
|
|
|
uses: bitwarden/gh-actions/download-artifacts@master
|
2021-08-12 00:38:05 +02:00
|
|
|
with:
|
2022-05-31 15:20:06 +02:00
|
|
|
workflow: build-cli.yml
|
2022-07-05 23:03:00 +02:00
|
|
|
path: apps/cli/build
|
2021-10-05 22:20:18 +02:00
|
|
|
workflow_conclusion: success
|
2022-06-22 14:32:45 +02:00
|
|
|
branch: ${{ github.ref_name }}
|
2021-10-27 22:10:18 +02:00
|
|
|
artifacts: bitwarden-cli-${{ env._PKG_VERSION }}-npm-build.zip
|
2021-08-12 00:38:05 +02:00
|
|
|
|
2022-11-14 15:35:42 +01:00
|
|
|
- name: Dry Run - Download artifacts
|
2022-07-19 21:01:14 +02:00
|
|
|
if: ${{ github.event.inputs.release_type == 'Dry Run' }}
|
2023-10-25 16:35:46 +02:00
|
|
|
uses: bitwarden/gh-actions/download-artifacts@master
|
2022-07-19 21:01:14 +02:00
|
|
|
with:
|
|
|
|
workflow: build-cli.yml
|
|
|
|
path: apps/cli/build
|
|
|
|
workflow_conclusion: success
|
|
|
|
branch: master
|
|
|
|
artifacts: bitwarden-cli-${{ env._PKG_VERSION }}-npm-build.zip
|
|
|
|
|
2021-10-05 22:20:18 +02:00
|
|
|
- name: Setup NPM
|
2022-08-10 16:25:39 +02:00
|
|
|
run: |
|
|
|
|
echo 'registry="https://registry.npmjs.org/"' > ./.npmrc
|
|
|
|
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ./.npmrc
|
2021-05-11 22:18:27 +02:00
|
|
|
env:
|
2023-01-25 15:12:18 +01:00
|
|
|
NPM_TOKEN: ${{ steps.retrieve-secrets.outputs.npm-api-key }}
|
2021-01-27 20:15:29 +01:00
|
|
|
|
2022-02-10 23:03:09 +01:00
|
|
|
- name: Install Husky
|
|
|
|
run: npm install -g husky
|
|
|
|
|
2021-10-05 22:20:18 +02:00
|
|
|
- name: Publish NPM
|
2022-02-25 15:12:07 +01:00
|
|
|
if: ${{ github.event.inputs.release_type != 'Dry Run' }}
|
2022-08-10 16:25:39 +02:00
|
|
|
run: npm publish --access public --regsitry=https://registry.npmjs.org/ --userconfig=./.npmrc
|