From 278815119f2a02e412167464efe45cdfae70bff6 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 6 Jul 2020 09:50:26 -0400 Subject: [PATCH] update workflow for release tasks --- .github/scripts/android/compile-fdroid.sh | 24 ++++++ .github/workflows/build.yml | 92 ++++++++++++++++++++++- 2 files changed, 114 insertions(+), 2 deletions(-) create mode 100644 .github/scripts/android/compile-fdroid.sh diff --git a/.github/scripts/android/compile-fdroid.sh b/.github/scripts/android/compile-fdroid.sh new file mode 100644 index 000000000..a30d0e896 --- /dev/null +++ b/.github/scripts/android/compile-fdroid.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +cd $GITHUB_WORKSPACE +mkdir dist +cp CNAME ./dist +cd store +chmod 600 fdroid/config.py fdroid/keystore.jks +mkdir -p temp/fdroid +TEMP_DIR="$GITHUB_WORKSPACE/store/temp/fdroid" +cd fdroid +echo "keypass=\"$FDROID_STORE_KEYSTORE_PASSWORD\"" >>config.py +echo "keystorepass=\"$FDROID_STORE_KEYSTORE_PASSWORD\"" >>config.py +echo "local_copy_dir=\"$TEMP_DIR\"" >>config.py +mkdir -p repo +curl -Lo repo/com.x8bit.bitwarden-fdroid.apk \ +https://github.com/bitwarden/mobile/releases/download/$RELEASE_TAG_NAME/com.x8bit.bitwarden-fdroid.apk +fdroid update +fdroid server update +cd .. +rm -rf temp/fdroid/archive +mv -v temp/fdroid ../dist +cd fdroid +cp index.html btn.png qr.png ../../dist/fdroid +cd $GITHUB_WORKSPACE diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 322b3debf..abb56e220 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,6 +5,9 @@ on: branches-ignore: - 'l10n_master' - 'gh-pages' + release: + types: + - published jobs: @@ -41,9 +44,11 @@ jobs: msbuild -version dotnet --info Write-Output "GitHub ref: $env:GITHUB_REF" + Write-Output "GitHub event: $env:GITHUB_EVENT" shell: pwsh env: GITHUB_REF: ${{ github.ref }} + GITHUB_EVENT: ${{ github.event_name }} - name: Checkout repo uses: actions/checkout@v2 @@ -118,10 +123,91 @@ jobs: path: ./com.x8bit.bitwarden-fdroid.apk - name: Deploy to Play Store - if: github.ref == 'refs/heads/master' + if: github.ref == 'refs/heads/master' && github.event_name == 'push' run: ./.github/scripts/android/deploy-play.ps1 shell: pwsh + - name: Upload release assets + if: github.event_name == 'release' + run: | + hub release edit ` + -a ./com.x8bit.bitwarden.aab ` + -a ./com.x8bit.bitwarden.apk ` + -a ./com.x8bit.bitwarden-fdroid.apk ` + $env:RELEASE_TAG_NAME + shell: pwsh + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + RELEASE_TAG_NAME: ${{ github.event.release.tag_name }} + + android-ubuntu: + runs-on: ubuntu-latest + needs: android + + steps: + - name: Set up Node + if: github.event_name == 'release' + uses: actions/setup-node@v1 + with: + node-version: '10.x' + + - name: Set up F-Droid server + if: github.event_name == 'release' + run: | + sudo apt-get -qq update + sudo apt-get -qqy install --no-install-recommends fdroidserver wget + + - name: Set up git credentials + if: github.event_name == 'release' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git config --global credential.helper store + echo "https://${GITHUB_TOKEN}:x-oauth-basic@github.com" >> ~/.git-credentials + git config --global user.email "ci@bitwarden.com" + git config --global user.name "Bitwarden CI" + + - name: Print environment + if: github.event_name == 'release' + run: | + node --version + npm --version + git --version + Write-Output "GitHub ref: $env:GITHUB_REF" + Write-Output "GitHub event: $env:GITHUB_EVENT" + shell: pwsh + env: + GITHUB_REF: ${{ github.ref }} + GITHUB_EVENT: ${{ github.event_name }} + + - name: Checkout repo + if: github.event_name == 'release' + uses: actions/checkout@v2 + + - name: Install Node dependencies + if: github.event_name == 'release' + run: npm install + + - name: Decrypt secrets + if: github.event_name == 'release' + run: | + ./.github/scripts/decrypt-secret.ps1 -filename store_fdroid-keystore.jks.gpg ` + -output ./store/fdroid/keystore.jks + shell: pwsh + env: + DECRYPT_FILE_PASSWORD: ${{ secrets.DECRYPT_FILE_PASSWORD }} + + - name: Compile for F-Droid Store + if: github.event_name == 'release' + run: ./.github/scripts/android/compile-fdroid.sh + env: + FDROID_STORE_KEYSTORE_PASSWORD: ${{ secrets.FDROID_STORE_KEYSTORE_PASSWORD }} + RELEASE_TAG_NAME: ${{ github.event.release.tag_name }} + + - name: Deploy to gh-pages + if: github.event_name == 'release' + run: npm run deploy + ios: runs-on: macos-latest @@ -132,9 +218,11 @@ jobs: msbuild -version dotnet --info Write-Output "GitHub ref: $env:GITHUB_REF" + Write-Output "GitHub event: $env:GITHUB_EVENT" shell: pwsh env: GITHUB_REF: ${{ github.ref }} + GITHUB_EVENT: ${{ github.event_name }} - name: Checkout repo uses: actions/checkout@v2 @@ -188,7 +276,7 @@ jobs: path: ./bitwarden-export/Bitwarden.ipa - name: Deploy to App Store - if: github.ref == 'refs/heads/master' + if: github.ref == 'refs/heads/master' && github.event_name == 'push' run: ./.github/scripts/ios/deploy-app-store.ps1 shell: pwsh env: