1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-09 09:51:02 +01:00
bitwarden-browser/.github/workflows/deploy.yml

143 lines
4.2 KiB
YAML
Raw Normal View History

name: Deploy
on:
workflow_dispatch:
inputs:
release_tag_name_input:
description: "Release Tag Name <X.X.X>"
required: true
2021-01-28 19:59:07 +01:00
release:
types:
2021-01-28 21:22:36 +01:00
- published
jobs:
setup:
runs-on: ubuntu-latest
outputs:
package_version: ${{ steps.create_tags.outputs.package_version }}
tag_version: ${{ steps.create_tags.outputs.tag_version }}
steps:
- name: Checkout Repo
uses: actions/checkout@v2
2021-01-28 19:59:07 +01:00
- name: Create Deploy version vars
id: create_tags
run: |
2021-01-28 21:49:46 +01:00
if ! [[ "${{ github.event_name }}" -eq "release" ]]; then
2021-01-28 19:59:07 +01:00
case "${RELEASE_TAG_NAME_INPUT:0:1}" in
v)
echo "RELEASE_NAME=${RELEASE_TAG_NAME_INPUT:1}" >> $GITHUB_ENV
echo "RELEASE_TAG_NAME=$RELEASE_TAG_NAME_INPUT" >> $GITHUB_ENV
echo "::set-output name=package_version::${RELEASE_TAG_NAME_INPUT:1}"
echo "::set-output name=tag_version::$RELEASE_TAG_NAME_INPUT"
;;
[0-9])
echo "RELEASE_NAME=$RELEASE_TAG_NAME_INPUT" >> $GITHUB_ENV
echo "RELEASE_TAG_NAME=v$RELEASE_TAG_NAME_INPUT" >> $GITHUB_ENV
echo "::set-output name=package_version::$RELEASE_TAG_NAME_INPUT"
echo "::set-output name=tag_version::v$RELEASE_TAG_NAME_INPUT"
;;
*)
exit 1
;;
esac
else
TAG_VERSION=$(echo ${{ github.ref }} | cut -d "/" -f 3)
PKG_VERSION=${TAG_VERSION:1}
echo "::set-output name=package_version::$PKG_VERSION"
echo "::set-output name=tag_version::$TAG_VERSION"
fi
env:
RELEASE_TAG_NAME_INPUT: ${{ github.event.inputs.release_tag_name_input }}
snap:
2021-01-28 20:22:34 +01:00
name: Deploy Snap
runs-on: ubuntu-latest
needs: setup
2021-01-28 19:04:16 +01:00
env:
2021-01-28 18:46:23 +01:00
PKG_VERSION: ${{ needs.setup.outputs.package_version }}
TAG_VERSION: ${{ needs.setup.outputs.tag_version }}
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Install Snapcraft
uses: samuelmeuli/action-snapcraft@v1
2021-01-28 22:05:17 +01:00
with:
snapcraft_token: ${{ secrets.SNAP_TOKEN }}
- name: setup
run: mkdir dist
- name: Test getting choco release asset - windows
uses: Xotl/cool-github-releases@v1
with:
mode: download
tag_name: ${{ env.TAG_VERSION }}
assets: bw_${{ env.PKG_VERSION }}_amd64.snap|./dist/bw_${{ env.PKG_VERSION }}_amd64.snap
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: test
run: ls -alht dist
2021-01-28 22:05:17 +01:00
- name: Publish Snap & logout
run: |
snapcraft push ./dist/bw_${{ env.PACKAGE_VERSION }}_amd64.snap --release stable
snapcraft logout
choco:
2021-01-28 20:22:34 +01:00
name: Deploy Choco
runs-on: windows-latest
needs: setup
2021-01-28 19:04:16 +01:00
env:
2021-01-28 18:46:23 +01:00
PKG_VERSION: ${{ needs.setup.outputs.package_version }}
TAG_VERSION: ${{ needs.setup.outputs.tag_version }}
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Setup Chocolatey
run: choco apikey --key $env:CHOCO_API_KEY --source https://push.chocolatey.org/
env:
CHOCO_API_KEY: ${{ secrets.CHOCO_API_KEY }}
2021-01-28 20:35:39 +01:00
- name: make dist dir
shell: pwsh
run: New-Item -ItemType directory -Path ./dist
- name: Test getting choco release asset - windows
uses: Xotl/cool-github-releases@v1
with:
mode: download
tag_name: ${{ env.TAG_VERSION }}
2021-01-28 20:35:39 +01:00
assets: bitwarden-cli.${{ env.PKG_VERSION }}.nupkg|./dist/bitwarden-cli.${{ env.PKG_VERSION }}.nupkg
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Push to Chocolatey
shell: pwsh
run: |
2021-01-28 20:22:34 +01:00
cd dist
2021-01-28 22:05:17 +01:00
choco push
npm:
name: Publish NPM
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Setup NPM
shell: pwsh
run: |
"//registry.npmjs.org/:_authToken=${env:NPM_TOKEN}" | Out-File ".npmrc" -Encoding UTF8
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish NPM
run: npm run publish:npm