mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-19 05:58:50 +02:00
* add all secrets to single secret * add all secrets to single secret
239 lines
8.6 KiB
YAML
239 lines
8.6 KiB
YAML
name: Reusable Build Logic
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
ref:
|
|
required: true
|
|
type: string
|
|
pr_number:
|
|
required: true
|
|
type: string
|
|
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
jobs:
|
|
PR_test_build:
|
|
runs-on: [Linux, amd64, android]
|
|
container:
|
|
image: ghcr.io/cake-tech/cake_wallet:debian13-flutter3.32.0-ndkr28-go1.24.1-ruststablenightly
|
|
env:
|
|
STORE_PASS: test@cake_wallet
|
|
KEY_PASS: test@cake_wallet
|
|
MONEROC_CACHE_DIR_ROOT: /opt/generic_cache
|
|
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
|
|
ANDROID_AVD_HOME: /root/.android/avd
|
|
volumes:
|
|
- /opt/cw_cache_android/root/.cache:/root/.cache
|
|
- /opt/cw_cache_android/root/.android/avd/:/root/.android/avd
|
|
- /opt/cw_cache_android/root/.ccache:/root/.ccache
|
|
- /opt/cw_cache_android/root/.pub-cache/:/root/.pub-cache
|
|
- /opt/cw_cache_android/root/.gradle/:/root/.gradle
|
|
- /opt/cw_cache_android/root/.android/:/root/.android
|
|
- /opt/cw_cache_android/root/go/pkg:/root/go/pkg
|
|
- /opt/cw_cache_android/opt/generic_cache:/opt/generic_cache
|
|
- /dev/kvm:/dev/kvm
|
|
strategy:
|
|
matrix:
|
|
api-level: [29]
|
|
|
|
steps:
|
|
- name: Fix github actions messing up $HOME...
|
|
run: 'echo HOME=/root | sudo tee -a $GITHUB_ENV'
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ inputs.ref }}
|
|
- name: configure git
|
|
run: |
|
|
git config --global --add safe.directory '*'
|
|
git config --global user.email "ci@cakewallet.com"
|
|
git config --global user.name "CakeWallet CI"
|
|
- name: Get the full commit message
|
|
run: |
|
|
FULL_MESSAGE="$(git log -1 --pretty=%B)"
|
|
echo "message<<EOF" >> $GITHUB_ENV
|
|
echo "$FULL_MESSAGE" >> $GITHUB_ENV
|
|
echo "EOF" >> $GITHUB_ENV
|
|
|
|
- name: Add secrets
|
|
run: |
|
|
touch cw_evm/lib/.secrets.g.dart
|
|
touch cw_solana/lib/.secrets.g.dart
|
|
touch cw_core/lib/.secrets.g.dart
|
|
touch cw_nano/lib/.secrets.g.dart
|
|
touch cw_tron/lib/.secrets.g.dart
|
|
|
|
echo "const polygonScanApiKey = '${{ secrets.POLYGON_SCAN_API_KEY }}';" >> cw_evm/lib/.secrets.g.dart
|
|
echo "const etherScanApiKey = '${{ secrets.ETHER_SCAN_API_KEY }}';" >> cw_evm/lib/.secrets.g.dart
|
|
echo "const moralisApiKey = '${{ secrets.MORALIS_API_KEY }}';" >> cw_evm/lib/.secrets.g.dart
|
|
echo "const nowNodesApiKey = '${{ secrets.EVM_NOWNODES_API_KEY }}';" >> cw_evm/lib/.secrets.g.dart
|
|
|
|
echo "const ankrApiKey = '${{ secrets.ANKR_API_KEY }}';" >> cw_solana/lib/.secrets.g.dart
|
|
echo "const chainStackApiKey = '${{ secrets.CHAIN_STACK_API_KEY }}';" >> cw_solana/lib/.secrets.g.dart
|
|
echo "const moralisApiKey = '${{ secrets.MORALIS_API_KEY }}';" >> cw_solana/lib/.secrets.g.dart
|
|
|
|
echo "const nano2ApiKey = '${{ secrets.NANO2_API_KEY }}';" >> cw_nano/lib/.secrets.g.dart
|
|
echo "const nanoNowNodesApiKey = '${{ secrets.NANO_NOW_NODES_API_KEY }}';" >> cw_nano/lib/.secrets.g.dart
|
|
|
|
echo "const tronGridApiKey = '${{ secrets.TRON_GRID_API_KEY }}';" >> cw_tron/lib/.secrets.g.dart
|
|
echo "const tronNowNodesApiKey = '${{ secrets.TRON_NOW_NODES_API_KEY }}';" >> cw_tron/lib/.secrets.g.dart
|
|
|
|
echo "${{ secrets.MAIN_SECRETS_FILE }}" | base64 --decode > lib/.secrets.g.dart
|
|
|
|
- name: Generate KeyStore
|
|
run: |
|
|
pushd /opt/generic_cache
|
|
if [[ ! -f key.jks ]];
|
|
then
|
|
keytool -genkey -v -keystore key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias testKey -noprompt -dname "CN=CakeWallet, OU=CakeWallet, O=CakeWallet, L=Florida, S=America, C=USA" -storepass $STORE_PASS -keypass $KEY_PASS
|
|
else
|
|
echo "$PWD/key.jks exist, not generating"
|
|
fi
|
|
popd
|
|
cp /opt/generic_cache/key.jks android/app
|
|
|
|
- name: Fetch prebuilt Torch
|
|
run: |
|
|
set -x -e
|
|
pushd scripts
|
|
wget https://github.com/MrCyjaneK/torch_dart/releases/download/v1.0.17/torch_dart-v1.0.17.tar.gz -O torch_dart.tar.gz
|
|
mkdir torch_dart
|
|
pushd torch_dart
|
|
tar -xzf ../torch_dart.tar.gz
|
|
popd
|
|
rm ./torch_dart.tar.gz
|
|
popd
|
|
|
|
- name: Fetch prebuilt Reown
|
|
run: |
|
|
set -x -e
|
|
pushd scripts
|
|
# cleaning
|
|
rm -rf reown_flutter
|
|
rm -f reown_flutter.tar.gz
|
|
|
|
wget https://github.com/cake-tech/reown_flutter/releases/download/v0.0.4/reown_flutter-v0.0.4.tar.gz -O reown_flutter.tar.gz
|
|
mkdir reown_flutter
|
|
pushd reown_flutter
|
|
tar -xzf ../reown_flutter.tar.gz
|
|
popd
|
|
rm ./reown_flutter.tar.gz
|
|
popd
|
|
|
|
- name: Execute Build and Setup Commands
|
|
run: |
|
|
pushd scripts/android
|
|
source ./app_env.sh cakewallet
|
|
./app_config.sh
|
|
popd
|
|
|
|
- name: Build monero_c
|
|
run: |
|
|
mkdir -p scripts/monero_c
|
|
pushd scripts/monero_c
|
|
wget https://github.com/MrCyjaneK/monero_c/releases/download/v0.18.4.0-RC9/release-bundle.zip
|
|
unzip release-bundle.zip
|
|
rm release-bundle.zip
|
|
unxz -fv release/*/*.xz
|
|
popd
|
|
|
|
- name: Build Bitbox Flutter
|
|
run: |
|
|
set -x -e
|
|
pushd scripts
|
|
./build_bitbox_flutter.sh
|
|
popd
|
|
|
|
- name: Install Flutter dependencies
|
|
run: |
|
|
flutter pub get
|
|
|
|
- name: Build mwebd
|
|
run: |
|
|
set -x -e
|
|
export MWEBD_HASH=$(cat scripts/android/build_mwebd.sh | grep 'git reset --hard' | xargs | awk '{ print $4 }')
|
|
echo MWEBD_HASH=$MWEBD_HASH >> /etc/environment
|
|
pushd scripts/android
|
|
./build_mwebd.sh
|
|
popd
|
|
|
|
- name: Build Decred
|
|
run: |
|
|
set -x -e
|
|
pushd scripts/android
|
|
./build_decred.sh
|
|
popd
|
|
|
|
- name: Build generated code
|
|
run: |
|
|
flutter --version
|
|
flutter clean
|
|
rm -rf .dart_tool
|
|
rm pubspec.lock
|
|
flutter pub get
|
|
./model_generator.sh async
|
|
|
|
- name: Generate key properties
|
|
run: |
|
|
dart run tool/generate_android_key_properties.dart keyAlias=testKey storeFile=key.jks storePassword=$STORE_PASS keyPassword=$KEY_PASS
|
|
|
|
- name: Generate localization
|
|
run: |
|
|
dart run tool/generate_localization.dart
|
|
|
|
- name: Rename app
|
|
run: |
|
|
sanitized_branch_name=${BRANCH_NAME#origin/} # Remove 'origin/' prefix if it exists
|
|
sanitized_branch_name=${sanitized_branch_name:0:16} # Take only the first 16 characters
|
|
sanitized_branch_name=$(echo "$sanitized_branch_name" | tr '[:upper:]' '[:lower:]') # Convert to lowercase
|
|
sanitized_branch_name=$(echo "$sanitized_branch_name" | sed 's/[^a-z0-9]//g') # Remove all special characters
|
|
|
|
echo -e "id=com.cakewallet.test_${sanitized_branch_name}\nname=${BRANCH_NAME}" > android/app.properties
|
|
|
|
- name: Build
|
|
run: |
|
|
flutter build apk --dart-define=hasDevOptions=true --release --split-per-abi
|
|
|
|
- name: Rename apk file
|
|
run: |
|
|
cd build/app/outputs/flutter-apk
|
|
mkdir test-apk
|
|
cp app-arm64-v8a-release.apk test-apk/${BRANCH_NAME}.apk
|
|
cp app-x86_64-release.apk test-apk/${BRANCH_NAME}_x86.apk
|
|
|
|
- name: Find APK file
|
|
id: find_apk
|
|
run: |
|
|
set -x
|
|
apk_file=$(ls build/app/outputs/flutter-apk/test-apk/${BRANCH_NAME}.apk || exit 1)
|
|
echo "APK_FILE=$apk_file" >> $GITHUB_ENV
|
|
- name: Write BRANCH_NAME to env
|
|
run: echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV
|
|
|
|
- name: Upload to slack step
|
|
uses: vaporif/slack-file-upload-action@v1
|
|
with:
|
|
token: ${{ secrets.SLACK_APP_TOKEN }}
|
|
initial_comment: ${{ env.message }}
|
|
files: >
|
|
[
|
|
{"file": "${{ env.APK_FILE }}", "filename": "${{ env.BRANCH_NAME }}.apk"}
|
|
]
|
|
channel_id: ${{ secrets.SLACK_APK_CHANNEL }}
|
|
|
|
- name: cleanup
|
|
run: rm -rf build/app/outputs/flutter-apk/test-apk/
|
|
|
|
- name: Upload Artifact to github
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
path: ${{ github.workspace }}/build/app/outputs/flutter-apk
|
|
name: "android apk"
|
|
|
|
- name: 16KB align
|
|
run: |
|
|
cd build/app/outputs/flutter-apk
|
|
for i in arm64-v8a x86_64; do
|
|
../../../../scripts/android/check_16kb_align.sh app-$i-release.apk
|
|
done |