1
0
mirror of https://github.com/bitwarden/desktop.git synced 2024-11-30 12:54:31 +01:00
bitwarden-desktop/.github/workflows/deploy.yml

228 lines
8.0 KiB
YAML
Raw Normal View History

2021-01-26 23:21:24 +01:00
name: Deploy
on:
2021-01-29 20:09:59 +01:00
workflow_dispatch:
inputs:
release_tag_name_input:
description: "Release Tag Name <X.X.X>"
required: true
2021-01-26 23:21:24 +01:00
jobs:
2021-01-26 23:42:04 +01:00
setup:
name: Setup
2021-01-26 23:21:24 +01:00
runs-on: ubuntu-latest
2021-01-26 23:42:04 +01:00
outputs:
2021-01-29 20:09:59 +01:00
package_version: ${{ steps.create_tags.outputs.package_version }}
tag_version: ${{ steps.create_tags.outputs.tag_version }}
2021-01-26 23:21:24 +01:00
steps:
- name: Checkout Repo
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
2021-01-26 23:21:24 +01:00
2021-01-29 20:09:59 +01:00
- name: Create Deploy version vars
id: create_tags
2021-01-26 23:42:04 +01:00
run: |
2021-01-29 20:09:59 +01:00
if ! [[ "${{ github.event_name }}" -eq "release" ]]; then
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}
2021-01-26 23:42:04 +01:00
2021-01-29 20:09:59 +01:00
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 }}
2021-01-26 23:42:04 +01:00
2021-01-29 20:09:59 +01:00
snap:
name: Deploy Snap
2021-01-26 23:42:04 +01:00
runs-on: ubuntu-latest
2021-01-26 23:49:46 +01:00
needs: setup
2021-01-29 20:09:59 +01:00
env:
PKG_VERSION: ${{ needs.setup.outputs.package_version }}
2021-05-12 19:47:05 +02:00
TAG_VERSION: ${{ needs.setup.outputs.tag_version }}
2021-01-26 23:42:04 +01:00
steps:
- name: Checkout Repo
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
2021-01-26 23:42:04 +01:00
2021-01-29 20:09:59 +01:00
- name: Install Snap
uses: samuelmeuli/action-snapcraft@10d7d0a84d9d86098b19f872257df314b0bd8e2d # v1.2.0
with:
snapcraft_token: ${{ secrets.SNAP_TOKEN }}
2021-01-26 23:42:04 +01:00
- name: Setup
2021-01-29 20:09:59 +01:00
run: mkdir dist
- name: Get Snap package
uses: Xotl/cool-github-releases@16c58a5863d6ba9944f63ca8bb78bb3249ce1d81 # v1.1.6
2021-01-29 20:09:59 +01:00
with:
mode: download
tag_name: ${{ env.TAG_VERSION }}
assets: bitwarden_${{ env.PKG_VERSION }}_amd64.snap|./dist/bitwarden_${{ env.PKG_VERSION }}_amd64.snap
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Test
2021-01-29 20:09:59 +01:00
run: ls -alht dist
- name: Deploy to Snap Store
run: |
snapcraft upload dist/bitwarden_${{ env.PKG_VERSION }}_amd64.snap --release stable
2021-01-29 20:09:59 +01:00
snapcraft logout
choco:
name: Deploy Choco
runs-on: windows-latest
needs: setup
env:
PKG_VERSION: ${{ needs.setup.outputs.package_version }}
TAG_VERSION: ${{ needs.setup.outputs.tag_version }}
steps:
- name: Checkout Repo
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
2021-01-29 20:09:59 +01:00
- name: Get choco release asset
uses: Xotl/cool-github-releases@16c58a5863d6ba9944f63ca8bb78bb3249ce1d81 # v1.1.6
with:
2021-05-12 19:53:20 +02:00
mode: download
tag_name: ${{ env.TAG_VERSION }}
assets: bitwarden.${{ env.PKG_VERSION }}.nupkg
github_token: ${{ secrets.GITHUB_TOKEN }}
2021-01-26 23:21:24 +01:00
- name: Setup Chocolatey
run: choco apikey --key $env:CHOCO_API_KEY --source https://push.chocolatey.org/
env:
CHOCO_API_KEY: ${{ secrets.CHOCO_API_KEY }}
- name: Make dist dir
2021-01-29 20:09:59 +01:00
shell: pwsh
run: New-Item -ItemType directory -Path ./dist
2021-01-26 23:42:04 +01:00
2021-01-29 20:09:59 +01:00
- name: Get nupkg
uses: Xotl/cool-github-releases@16c58a5863d6ba9944f63ca8bb78bb3249ce1d81 # v1.1.6
2021-01-29 20:09:59 +01:00
with:
mode: download
tag_name: ${{ env.TAG_VERSION }}
assets: bitwarden.${{ env.PKG_VERSION }}.nupkg|./dist/bitwarden.${{ env.PKG_VERSION }}.nupkg
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Push to Chocolatey
shell: pwsh
run: |
cd dist
choco push
macos:
name: Deploy MacOS
2021-01-29 20:09:59 +01:00
runs-on: macos-latest
needs: setup
2021-05-12 19:47:58 +02:00
env:
PKG_VERSION: ${{ needs.setup.outputs.package_version }}
TAG_VERSION: ${{ needs.setup.outputs.tag_version }}
2021-01-29 20:09:59 +01:00
steps:
- name: Checkout repo
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
- name: Make target directory
run: mkdir -p dist/mas-universal
- name: Get Mac release asset
uses: Xotl/cool-github-releases@16c58a5863d6ba9944f63ca8bb78bb3249ce1d81 # v1.1.6
2021-01-29 20:09:59 +01:00
with:
mode: download
tag_name: ${{ env.TAG_VERSION }}
2021-05-12 19:54:20 +02:00
assets: Bitwarden-${{ env.PKG_VERSION }}-universal.pkg|./dist/mas-universal/Bitwarden-${{ env.PKG_VERSION }}-universal.pkg
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy to App Store
run: npm run upload:mas
env:
APPLE_ID_USERNAME: ${{ secrets.APPLE_ID_USERNAME }}
APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
auto-updater-deploy:
name: Release auto-updater files
runs-on: ubuntu-latest
needs:
- setup
- snap
- choco
- macos
env:
RELEASE_VERSION: ${{ needs.setup.outputs.release_version }}
TAG_VERSION: ${{ needs.setup.outputs.tag_version }}
steps:
- name: Checkout repo
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
- name: Rename publish asset
run: |
curl \
-H "Authorization:token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept:application/vnd.github.v3+json" \
https://api.github.com/repos/$GITHUB_REPOSITORY/releases \
| jq -r " .[] | select( .tag_name == \"$TAG_VERSION\")" > release.json
echo "=====RELEASE====="
echo Release:
#cat release.json
RELEASE_UPLOAD_URL=$(cat release.json | jq -r ' .upload_url ' | cut -d { -f 1)
cat release.json | jq -rc ' .assets[] | select( .name | test("prerelease-latest.*[yml|json]")) | {name: .name, url: .url, content_type: .content_type}' > release_assets.jsonl
echo "=====ASSETS====="
echo Release Upload URL: $RELEASE_UPLOAD_URL
echo Release Assets:
cat release_assets.jsonl
while read -r asset; do
FILE_NAME=$(echo $asset | jq -r '.name')
FILE_URL=$(echo $asset | jq -r '.url')
FILE_ID=$(echo $asset | jq -r '.id')
echo "Asset name: $FILE_NAME"
echo "Asset url: $FILE_URL"
echo "Grabbing asset..."
curl \
-L -H "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/octet-stream" \
$FILE_URL --output $FILE_NAME
NEW_FILE_SIZE=$(wc -c < $FILE_NAME | xargs)
NEW_FILE_NAME=$(echo $FILE_NAME | awk '{split($0,a,"prerelease-"); print a[2]}')
echo "New file size: $NEW_FILE_SIZE"
echo "New file name: $NEW_FILE_NAME"
echo "================"
echo "Deleting remote asset..."
curl \
-X DELETE \
-H "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "accept: application/vnd.github.v3+json" \
$FILE_URL
echo "Pushing updated asset..."
curl \
-X POST \
-H "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "content-type: text/yaml" \
-H "content-length: $NEW_FILE_SIZE" \
--data-binary @$FILE_NAME \
"$RELEASE_UPLOAD_URL?name=$NEW_FILE_NAME" --http1.1
done < release_assets.jsonl