diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 000000000..2e2ed58c6 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,209 @@ +name: Build + +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + workflow_dispatch: + inputs: + version: + description: 'App version string (e.g. 1.2.3)' + required: true + default: '0.0.1' + build_number: + description: 'Build number (integer)' + required: true + default: '1' + +jobs: + + build-linux: + runs-on: ubuntu-24.04 + container: + image: stackwallet/stackwallet-ci:latest + credentials: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + submodules: recursive + + - name: Set version + id: ver + run: | + if [ "${{ github.ref_type }}" = "tag" ]; then + VERSION="${{ github.ref_name }}" + VERSION="${VERSION#v}" + BUILD_NUMBER="${{ github.run_number }}" + else + VERSION="${{ inputs.version }}" + BUILD_NUMBER="${{ inputs.build_number }}" + fi + echo "version=${VERSION}" >> $GITHUB_OUTPUT + echo "build_number=${BUILD_NUMBER}" >> $GITHUB_OUTPUT + + - name: Configure app + run: | + cd scripts + echo "yes" | ./build_app.sh \ + -v "${{ steps.ver.outputs.version }}" \ + -b "${{ steps.ver.outputs.build_number }}" \ + -p linux -a stack_wallet -d -s + + - name: Get dependencies + run: flutter pub get + + - name: Create git_versions.dart stubs + run: | + mkdir -p crypto_plugins/flutter_libepiccash/lib + mkdir -p crypto_plugins/flutter_libmwc/lib + + EPIC_TAG=$(git -C crypto_plugins/flutter_libepiccash describe --tags --exact-match HEAD 2>/dev/null || echo "dev") + MWC_TAG=$(git -C crypto_plugins/flutter_libmwc describe --tags --exact-match HEAD 2>/dev/null || echo "dev") + + printf 'String getPluginVersion() => "%s";\n' "$EPIC_TAG" \ + > crypto_plugins/flutter_libepiccash/lib/git_versions.dart + printf 'String getPluginVersion() => "%s";\n' "$MWC_TAG" \ + > crypto_plugins/flutter_libmwc/lib/git_versions.dart + + - name: Decode secrets + env: + CHANGE_NOW: ${{ secrets.CHANGE_NOW }} + run: echo "$CHANGE_NOW" | base64 --decode > lib/external_api_keys.dart + + - name: Generate app config + run: dart run build_runner build --delete-conflicting-outputs + + - name: Build + run: flutter build linux --release + + - name: Package + run: | + tar -czf "stack_wallet-linux-x86_64-${{ steps.ver.outputs.version }}.tar.gz" \ + -C build/linux/x64/release bundle + + - uses: actions/upload-artifact@v4 + with: + name: stack_wallet-linux-x86_64-${{ steps.ver.outputs.version }} + path: stack_wallet-linux-x86_64-${{ steps.ver.outputs.version }}.tar.gz + + build-android: + runs-on: ubuntu-24.04 + container: + image: stackwallet/stackwallet-ci:latest + credentials: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + submodules: recursive + + - name: Set version + id: ver + run: | + if [ "${{ github.ref_type }}" = "tag" ]; then + VERSION="${{ github.ref_name }}" + VERSION="${VERSION#v}" + BUILD_NUMBER="${{ github.run_number }}" + else + VERSION="${{ inputs.version }}" + BUILD_NUMBER="${{ inputs.build_number }}" + fi + echo "version=${VERSION}" >> $GITHUB_OUTPUT + echo "build_number=${BUILD_NUMBER}" >> $GITHUB_OUTPUT + + - name: Configure app + run: | + cd scripts + echo "yes" | ./build_app.sh \ + -v "${{ steps.ver.outputs.version }}" \ + -b "${{ steps.ver.outputs.build_number }}" \ + -p android -a stack_wallet -d -s + + - name: Get dependencies + run: flutter pub get + + - name: Create git_versions.dart stubs + run: | + mkdir -p crypto_plugins/flutter_libepiccash/lib + mkdir -p crypto_plugins/flutter_libmwc/lib + + EPIC_TAG=$(git -C crypto_plugins/flutter_libepiccash describe --tags --exact-match HEAD 2>/dev/null || echo "dev") + MWC_TAG=$(git -C crypto_plugins/flutter_libmwc describe --tags --exact-match HEAD 2>/dev/null || echo "dev") + + printf 'String getPluginVersion() => "%s";\n' "$EPIC_TAG" \ + > crypto_plugins/flutter_libepiccash/lib/git_versions.dart + printf 'String getPluginVersion() => "%s";\n' "$MWC_TAG" \ + > crypto_plugins/flutter_libmwc/lib/git_versions.dart + + - name: Decode secrets + env: + CHANGE_NOW: ${{ secrets.CHANGE_NOW }} + run: echo "$CHANGE_NOW" | base64 --decode > lib/external_api_keys.dart + + - name: Generate app config + run: dart run build_runner build --delete-conflicting-outputs + + - name: Set up Android local.properties + run: | + cat > android/local.properties < android/keystore.jks + cat > android/key.properties < -b -p -a [-i] [-f] [-s]" + echo "Usage: $0 -v -b -p -a [-d] [-i] [-f] [-s]" exit 1 } @@ -33,17 +33,19 @@ unset -v APP_NAMED_ID # optional args (with defaults) BUILD_CRYPTO_PLUGINS=0 +DOWNLOAD_CRYPTO_PLUGINS=0 BUILD_ISAR_FROM_SOURCE=0 USE_SYSTEM_SECURE_STORAGE_DEPS=0 # Parse command-line arguments. -while getopts "v:b:p:a:i:fs" opt; do +while getopts "v:b:p:a:idfs" opt; do case "${opt}" in v) APP_VERSION_STRING="$OPTARG" ;; b) APP_BUILD_NUMBER="$OPTARG" ;; p) APP_BUILD_PLATFORM="$OPTARG" ;; a) APP_NAMED_ID="$OPTARG" ;; i) BUILD_CRYPTO_PLUGINS=1 ;; + d) DOWNLOAD_CRYPTO_PLUGINS=1 ;; f) BUILD_ISAR_FROM_SOURCE=1 ;; s) USE_SYSTEM_SECURE_STORAGE_DEPS=1 ;; *) usage ;; @@ -114,15 +116,28 @@ else fi if [ "$BUILD_CRYPTO_PLUGINS" -eq 0 ]; then - if [[ "$APP_NAMED_ID" = "stack_wallet" ]]; then - ./build_all.sh - elif [[ "$APP_NAMED_ID" = "stack_duo" ]]; then - ./build_all_duo.sh - elif [[ "$APP_NAMED_ID" = "campfire" ]]; then - ./build_all_campfire.sh + if [ "$DOWNLOAD_CRYPTO_PLUGINS" -eq 1 ]; then + if [[ "$APP_NAMED_ID" = "stack_wallet" ]]; then + ./download_all.sh + elif [[ "$APP_NAMED_ID" = "stack_duo" ]]; then + ./build_all_duo.sh + elif [[ "$APP_NAMED_ID" = "campfire" ]]; then + ./build_all_campfire.sh + else + echo "Invalid app id: ${APP_NAMED_ID}" + exit 1 + fi else - echo "Invalid app id: ${APP_NAMED_ID}" - exit 1 + if [[ "$APP_NAMED_ID" = "stack_wallet" ]]; then + ./build_all.sh + elif [[ "$APP_NAMED_ID" = "stack_duo" ]]; then + ./build_all_duo.sh + elif [[ "$APP_NAMED_ID" = "campfire" ]]; then + ./build_all_campfire.sh + else + echo "Invalid app id: ${APP_NAMED_ID}" + exit 1 + fi fi fi diff --git a/scripts/linux/download_all.sh b/scripts/linux/download_all.sh new file mode 100755 index 000000000..5e56389d9 --- /dev/null +++ b/scripts/linux/download_all.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -x -e + +mkdir -p build +./build_secure_storage_deps.sh + +(cd ../../crypto_plugins/flutter_libepiccash/scripts/linux && ./download.sh) + +(cd ../../crypto_plugins/flutter_libmwc/scripts/linux && ./download.sh) + +(cd ../../crypto_plugins/frostdart/scripts/linux && ./download.sh) + +./build_secp256k1.sh + +wait +echo "Done"