BlueWallet/.github/workflows/build-release-apk.yml

135 lines
4 KiB
YAML
Raw Normal View History

2022-04-29 22:49:13 +01:00
name: BuildReleaseApk
2024-02-03 20:15:16 -04:00
on:
pull_request:
branches:
- master
2024-09-06 13:40:57 -04:00
types: [opened, synchronize, reopened]
2024-02-03 20:15:16 -04:00
push:
branches:
- master
2022-04-29 22:49:13 +01:00
jobs:
buildReleaseApk:
runs-on: ubuntu-latest
2022-04-29 22:49:13 +01:00
steps:
- name: Checkout project
uses: actions/checkout@v4
with:
fetch-depth: "0"
2022-04-29 22:49:13 +01:00
- name: Specify node version
2024-05-06 15:08:55 +01:00
uses: actions/setup-node@v4
2022-04-29 22:49:13 +01:00
with:
2024-06-19 13:18:08 -04:00
node-version: 20
2022-04-29 22:49:13 +01:00
2024-08-04 15:41:49 -04:00
- name: Use npm caches
2024-09-09 23:53:30 -04:00
uses: actions/cache@v4
2022-04-29 22:49:13 +01:00
with:
2024-08-04 15:41:49 -04:00
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
2022-04-29 22:49:13 +01:00
restore-keys: |
2024-08-04 15:41:49 -04:00
${{ runner.os }}-npm-
2022-04-29 22:49:13 +01:00
- name: Use specific Java version for sdkmanager to work
uses: actions/setup-java@v4
2022-04-29 22:49:13 +01:00
with:
distribution: 'temurin'
2024-07-21 23:32:40 -04:00
java-version: '17'
2022-04-29 22:49:13 +01:00
cache: 'gradle'
- name: Install node_modules
run: npm install --omit=dev --yes
2022-04-29 22:49:13 +01:00
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1.6
bundler-cache: true
- name: Cache Ruby Gems
2024-09-09 23:53:30 -04:00
uses: actions/cache@v4
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
2024-02-04 09:05:18 -04:00
2024-02-03 20:23:00 -04:00
- name: Generate Build Number based on timestamp
id: build_number
2024-02-03 20:23:00 -04:00
run: |
NEW_BUILD_NUMBER="$(date +%s)"
2024-02-03 20:23:00 -04:00
echo "NEW_BUILD_NUMBER=$NEW_BUILD_NUMBER" >> $GITHUB_ENV
- name: Prepare Keystore
run: bundle exec fastlane android prepare_keystore
2022-04-29 22:49:13 +01:00
env:
KEYSTORE_FILE_HEX: ${{ secrets.KEYSTORE_FILE_HEX }}
- name: Update Version Code, Build, and Sign APK
id: build_and_sign_apk
run: |
bundle exec fastlane android update_version_build_and_sign_apk
env:
2024-02-03 20:23:00 -04:00
BUILD_NUMBER: ${{ env.NEW_BUILD_NUMBER }}
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
2022-04-29 22:49:13 +01:00
- name: Determine APK Filename and Path
id: determine_apk_path
run: |
VERSION_NAME=$(grep versionName android/app/build.gradle | awk '{print $2}' | tr -d '"')
2024-09-10 18:42:20 -04:00
BRANCH_NAME=${GITHUB_HEAD_REF:-${GITHUB_REF_NAME}}
BRANCH_NAME=$(echo "$BRANCH_NAME" | sed 's/[^a-zA-Z0-9_-]/-/g')
2024-09-11 18:22:29 -04:00
if [ -n "$BRANCH_NAME" ] && [ "$BRANCH_NAME" != "master" ]; then
2024-09-01 20:42:28 -04:00
EXPECTED_FILENAME="BlueWallet-${VERSION_NAME}-${NEW_BUILD_NUMBER}-${BRANCH_NAME}.apk"
2024-09-01 20:20:42 -04:00
else
2024-09-01 20:42:28 -04:00
EXPECTED_FILENAME="BlueWallet-${VERSION_NAME}-${NEW_BUILD_NUMBER}.apk"
2024-09-01 20:20:42 -04:00
fi
2024-09-10 18:42:20 -04:00
APK_PATH="android/app/build/outputs/apk/release/${EXPECTED_FILENAME}"
echo "EXPECTED_FILENAME=${EXPECTED_FILENAME}" >> $GITHUB_ENV
echo "APK_PATH=${APK_PATH}" >> $GITHUB_ENV
- name: Upload APK as artifact
2024-09-09 23:53:30 -04:00
uses: actions/upload-artifact@v4
with:
name: signed-apk
path: ${{ env.APK_PATH }}
browserstack:
runs-on: ubuntu-latest
needs: buildReleaseApk
2024-09-06 13:40:57 -04:00
if: ${{ github.event_name == 'pull_request' }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
2022-04-29 22:49:13 +01:00
with:
ruby-version: 3.1.6
bundler-cache: true
- name: Install dependencies with Bundler
run: bundle install --jobs 4 --retry 3
- name: Download APK artifact
2024-09-09 23:53:30 -04:00
uses: actions/download-artifact@v4
with:
name: signed-apk
- name: Set APK Path
run: |
APK_PATH=$(find ${{ github.workspace }} -name '*.apk')
echo "APK_PATH=$APK_PATH" >> $GITHUB_ENV
- name: Upload APK to BrowserStack and Post PR Comment
env:
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: bundle exec fastlane upload_to_browserstack_and_comment