mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
* add compile script * merge * move to CakeImageWidget * add precompiled .vec * fix double declaration * move .svg * add to ci * add svgs
218 lines
8.0 KiB
YAML
218 lines
8.0 KiB
YAML
name: Reusable Build Logic
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
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
|
|
- /var/run/docker.sock:/var/run/docker.sock
|
|
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: Log in to GitHub Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- 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_bitcoin/lib/.secrets.g.dart
|
|
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 blinkApiKey = '${{ secrets.BLINK_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 "const breezApiKey = '${{ secrets.BREEZ_API_KEY }}';" >> cw_bitcoin/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: Build dependencies utilizing ghcr cache
|
|
run: |
|
|
env \
|
|
CW_DOCKER_REGISTRY=ghcr.io/cake-tech/cake_wallet \
|
|
CW_DOCKER_USE_CLOUD=true \
|
|
./scripts/android/docker/build.sh
|
|
|
|
- name: Execute Build and Setup Commands
|
|
run: |
|
|
pushd scripts/android
|
|
source ./app_env.sh cakewallet
|
|
./app_config.sh
|
|
popd
|
|
|
|
- name: Install Flutter dependencies
|
|
run: |
|
|
flutter pub get
|
|
|
|
- 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: Compile graphics
|
|
run: |
|
|
./compile_graphics.sh
|
|
|
|
- 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: Replace email address
|
|
run: |
|
|
PATTERN1="support@cakewallet.com"
|
|
PATTERN1REP="dev.testflight.cakewallet@mrcyjanek.net"
|
|
echo lib/utils/exception_handler.dart \
|
|
lib/view_model/support_view_model.dart \
|
|
| while IFS= read -r -d '' file; do
|
|
sed -i.bak \
|
|
-e "s|$PATTERN1|$PATTERN1REP|g" \
|
|
"$file"
|
|
done
|
|
|
|
- name: Build
|
|
run: |
|
|
export ANDROID_NDK_HOME="$ANDROID_SDK_ROOT/ndk/$ANDROID_NDK_VERSION"
|
|
export ANDROID_NDK="$ANDROID_NDK_HOME"
|
|
pushd $ANDROID_SDK_ROOT/ndk
|
|
ln -s 28.2.13676358 25.1.8937393
|
|
popd
|
|
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
|