mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-03-13 11:09:20 +01:00
331 lines
No EOL
12 KiB
YAML
331 lines
No EOL
12 KiB
YAML
name: Build Release and Upload to TestFlight (iOS)
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
pull_request:
|
|
types: [opened, reopened, synchronize, labeled]
|
|
branches:
|
|
- master
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: macos-15
|
|
timeout-minutes: 180
|
|
outputs:
|
|
new_build_number: ${{ steps.generate_build_number.outputs.build_number }}
|
|
project_version: ${{ steps.determine_marketing_version.outputs.project_version }}
|
|
ipa_output_path: ${{ steps.build_app.outputs.ipa_output_path }}
|
|
latest_commit_message: ${{ steps.get_latest_commit_details.outputs.commit_message }}
|
|
branch_name: ${{ steps.get_latest_commit_details.outputs.branch_name }}
|
|
env:
|
|
APPLE_ID: ${{ secrets.APPLE_ID }}
|
|
MATCH_READONLY: "true"
|
|
|
|
steps:
|
|
- name: Checkout Project
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0 # Ensures the full Git history is available
|
|
|
|
- name: Setup Caching
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/Library/Caches/CocoaPods
|
|
ios/Pods
|
|
~/.npm
|
|
node_modules
|
|
vendor/bundle
|
|
key: ${{ runner.os }}-ios-${{ hashFiles('**/package-lock.json', '**/Podfile.lock', '**/Gemfile.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-ios-
|
|
|
|
- name: Clear All Caches
|
|
if: github.ref == 'refs/heads/master'
|
|
run: |
|
|
echo "Clearing Xcode DerivedData..."
|
|
rm -rf ~/Library/Developer/Xcode/DerivedData
|
|
echo "Clearing CocoaPods Cache..."
|
|
rm -rf ~/Library/Caches/CocoaPods
|
|
echo "Clearing npm Cache..."
|
|
npm cache clean --force
|
|
echo "Clearing Ruby Gems Cache..."
|
|
rm -rf ~/.gem
|
|
echo "Clearing Bundler Cache..."
|
|
rm -rf ~/.bundle/cache
|
|
|
|
- name: Ensure Correct Branch
|
|
if: github.ref != 'refs/heads/master'
|
|
run: |
|
|
if [ -n "${GITHUB_HEAD_REF}" ]; then
|
|
git fetch origin ${GITHUB_HEAD_REF}:${GITHUB_HEAD_REF}
|
|
git checkout ${GITHUB_HEAD_REF}
|
|
else
|
|
git fetch origin ${GITHUB_REF##*/}:${GITHUB_REF##*/}
|
|
git checkout ${GITHUB_REF##*/}
|
|
fi
|
|
echo "Checked out branch: $(git rev-parse --abbrev-ref HEAD)"
|
|
|
|
- name: Get Latest Commit Details
|
|
id: get_latest_commit_details
|
|
run: |
|
|
# Check if we are in a detached HEAD state
|
|
if [ "$(git rev-parse --abbrev-ref HEAD)" == "HEAD" ]; then
|
|
CURRENT_BRANCH=$(git show-ref --head -s HEAD | xargs -I {} git branch --contains {} | grep -v "detached" | head -n 1 | sed 's/^[* ]*//')
|
|
else
|
|
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
|
fi
|
|
|
|
LATEST_COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s")
|
|
|
|
echo "CURRENT_BRANCH=${CURRENT_BRANCH}" >> $GITHUB_ENV
|
|
echo "LATEST_COMMIT_MESSAGE=${LATEST_COMMIT_MESSAGE}" >> $GITHUB_ENV
|
|
echo "branch_name=${CURRENT_BRANCH}" >> $GITHUB_OUTPUT
|
|
echo "commit_message=${LATEST_COMMIT_MESSAGE}" >> $GITHUB_OUTPUT
|
|
|
|
- name: Print Commit Details
|
|
run: |
|
|
echo "Commit Message: ${{ env.LATEST_COMMIT_MESSAGE }}"
|
|
echo "Branch Name: ${{ env.CURRENT_BRANCH }}"
|
|
|
|
- name: Specify Node.js Version
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: 'npm'
|
|
|
|
- uses: maxim-lobanov/setup-xcode@v1
|
|
with:
|
|
xcode-version: latest
|
|
|
|
- name: Install iOS Simulator Runtime
|
|
run: |
|
|
echo "Available iOS simulator runtimes:"
|
|
xcrun simctl list runtimes
|
|
|
|
# Try to download the latest iOS 16.x simulator if not present
|
|
if (! xcrun simctl list runtimes | grep -q "iOS 16"); then
|
|
echo "Installing iOS 16.4 simulator..."
|
|
sudo xcode-select -s /Applications/Xcode.app
|
|
xcodebuild -downloadPlatform iOS
|
|
fi
|
|
|
|
echo "Available iOS simulator runtimes after install:"
|
|
xcrun simctl list runtimes
|
|
|
|
- name: Set Up Ruby
|
|
uses: ruby/setup-ruby@v1
|
|
with:
|
|
ruby-version: 3.1.6
|
|
bundler-cache: true
|
|
|
|
- name: Install Dependencies with Bundler
|
|
run: |
|
|
bundle config path vendor/bundle
|
|
bundle install --jobs 4 --retry 3 --quiet
|
|
|
|
- name: Install Node Modules
|
|
run: npm install --omit=dev --yes
|
|
|
|
- name: Install CocoaPods Dependencies
|
|
run: |
|
|
bundle exec fastlane ios install_pods
|
|
echo "CocoaPods dependencies installed successfully"
|
|
|
|
- name: Generate Build Number Based on Timestamp
|
|
id: generate_build_number
|
|
run: |
|
|
NEW_BUILD_NUMBER=$(date +%s)
|
|
echo "NEW_BUILD_NUMBER=$NEW_BUILD_NUMBER" >> $GITHUB_ENV
|
|
echo "build_number=$NEW_BUILD_NUMBER" >> $GITHUB_OUTPUT
|
|
|
|
- name: Set Build Number
|
|
run: bundle exec fastlane ios increment_build_number_lane
|
|
|
|
- name: Determine Marketing Version
|
|
id: determine_marketing_version
|
|
run: |
|
|
MARKETING_VERSION=$(grep MARKETING_VERSION BlueWallet.xcodeproj/project.pbxproj | awk -F '= ' '{print $2}' | tr -d ' ;' | head -1)
|
|
echo "PROJECT_VERSION=$MARKETING_VERSION" >> $GITHUB_ENV
|
|
echo "project_version=$MARKETING_VERSION" >> $GITHUB_OUTPUT
|
|
working-directory: ios
|
|
|
|
- name: Set Up Git Authentication
|
|
env:
|
|
ACCESS_TOKEN: ${{ secrets.GIT_ACCESS_TOKEN }}
|
|
run: |
|
|
git config --global credential.helper 'cache --timeout=3600'
|
|
git config --global http.https://github.com/.extraheader "AUTHORIZATION: basic $(echo -n x-access-token:${ACCESS_TOKEN} | base64)"
|
|
|
|
- name: Create Temporary Keychain
|
|
run: bundle exec fastlane ios create_temp_keychain
|
|
env:
|
|
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
|
|
|
|
- name: Setup Provisioning Profiles
|
|
env:
|
|
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
|
|
GIT_ACCESS_TOKEN: ${{ secrets.GIT_ACCESS_TOKEN }}
|
|
GIT_URL: ${{ secrets.GIT_URL }}
|
|
ITC_TEAM_ID: ${{ secrets.ITC_TEAM_ID }}
|
|
ITC_TEAM_NAME: ${{ secrets.ITC_TEAM_NAME }}
|
|
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
|
|
run: |
|
|
bundle exec fastlane ios setup_provisioning_profiles
|
|
|
|
- name: Build App
|
|
id: build_app
|
|
run: |
|
|
bundle exec fastlane ios build_app_lane
|
|
|
|
# Ensure IPA path is set for subsequent steps
|
|
if [ -f "./ios/build/ipa_path.txt" ]; then
|
|
IPA_PATH=$(cat ./ios/build/ipa_path.txt)
|
|
echo "IPA_OUTPUT_PATH=$IPA_PATH" >> $GITHUB_ENV
|
|
echo "ipa_output_path=$IPA_PATH" >> $GITHUB_OUTPUT
|
|
echo "Found IPA at: $IPA_PATH"
|
|
else
|
|
echo "Warning: ipa_path.txt not found, trying to locate IPA file manually..."
|
|
IPA_PATH=$(find ./ios -name "*.ipa" | head -n 1)
|
|
if [ -n "$IPA_PATH" ]; then
|
|
echo "IPA_OUTPUT_PATH=$IPA_PATH" >> $GITHUB_ENV
|
|
echo "ipa_output_path=$IPA_PATH" >> $GITHUB_OUTPUT
|
|
echo "Found IPA at: $IPA_PATH"
|
|
else
|
|
echo "Error: No IPA file found"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
- name: Upload Bugsnag Sourcemaps
|
|
if: success()
|
|
run: bundle exec fastlane ios upload_bugsnag_sourcemaps
|
|
env:
|
|
BUGSNAG_API_KEY: ${{ secrets.BUGSNAG_API_KEY }}
|
|
BUGSNAG_RELEASE_STAGE: production
|
|
PROJECT_VERSION: ${{ env.PROJECT_VERSION }}
|
|
NEW_BUILD_NUMBER: ${{ env.NEW_BUILD_NUMBER }}
|
|
|
|
- name: Upload Build Logs
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: build_logs
|
|
path: ./ios/build_logs/
|
|
retention-days: 7
|
|
|
|
- name: Verify IPA File Before Upload
|
|
run: |
|
|
echo "Checking IPA file at: $IPA_OUTPUT_PATH"
|
|
if [ -f "$IPA_OUTPUT_PATH" ]; then
|
|
echo "✅ IPA file exists"
|
|
ls -la "$IPA_OUTPUT_PATH"
|
|
else
|
|
echo "❌ IPA file not found at: $IPA_OUTPUT_PATH"
|
|
echo "Current directory contents:"
|
|
find ./ios -name "*.ipa"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Upload IPA as Artifact
|
|
if: success()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: BlueWallet_IPA
|
|
path: ${{ env.IPA_OUTPUT_PATH }}
|
|
retention-days: 7
|
|
|
|
- name: Delete Temporary Keychain
|
|
if: always()
|
|
run: bundle exec fastlane ios delete_temp_keychain
|
|
|
|
testflight-upload:
|
|
needs: build
|
|
runs-on: macos-15
|
|
if: github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'testflight')
|
|
env:
|
|
APPLE_ID: ${{ secrets.APPLE_ID }}
|
|
NEW_BUILD_NUMBER: ${{ needs.build.outputs.new_build_number }}
|
|
PROJECT_VERSION: ${{ needs.build.outputs.project_version }}
|
|
LATEST_COMMIT_MESSAGE: ${{ needs.build.outputs.latest_commit_message }}
|
|
BRANCH_NAME: ${{ needs.build.outputs.branch_name }}
|
|
steps:
|
|
- name: Checkout Project
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set Up Ruby
|
|
uses: ruby/setup-ruby@v1
|
|
with:
|
|
ruby-version: 3.1.6
|
|
bundler-cache: true
|
|
|
|
- name: Install Dependencies with Bundler
|
|
run: |
|
|
bundle config path vendor/bundle
|
|
bundle install --jobs 4 --retry 3 --quiet
|
|
|
|
- name: Download IPA from Artifact
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: BlueWallet_IPA
|
|
path: ./
|
|
|
|
- name: Create App Store Connect API Key JSON
|
|
run: echo '${{ secrets.APP_STORE_CONNECT_API_KEY_CONTENT }}' > ./appstore_api_key.json
|
|
|
|
- name: Set IPA Path Environment Variable
|
|
run: echo "IPA_OUTPUT_PATH=$(pwd)/BlueWallet_${{ needs.build.outputs.project_version }}_${{ needs.build.outputs.new_build_number }}.ipa" >> $GITHUB_ENV
|
|
|
|
- name: Verify IPA Path Before Upload
|
|
run: |
|
|
if [ ! -f "$IPA_OUTPUT_PATH" ]; then
|
|
echo "❌ IPA file not found at path: $IPA_OUTPUT_PATH"
|
|
ls -la $(pwd)
|
|
exit 1
|
|
else
|
|
echo "✅ Found IPA at: $IPA_OUTPUT_PATH"
|
|
fi
|
|
|
|
- name: Print Environment Variables for Debugging
|
|
run: |
|
|
echo "LATEST_COMMIT_MESSAGE: $LATEST_COMMIT_MESSAGE"
|
|
echo "BRANCH_NAME: $BRANCH_NAME"
|
|
echo "PROJECT_VERSION: $PROJECT_VERSION"
|
|
echo "NEW_BUILD_NUMBER: $NEW_BUILD_NUMBER"
|
|
echo "IPA_OUTPUT_PATH: $IPA_OUTPUT_PATH"
|
|
|
|
- name: Upload to TestFlight
|
|
run: bundle exec fastlane ios upload_to_testflight_lane
|
|
env:
|
|
APP_STORE_CONNECT_API_KEY_PATH: $(pwd)/appstore_api_key.p8
|
|
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
|
|
GIT_ACCESS_TOKEN: ${{ secrets.GIT_ACCESS_TOKEN }}
|
|
GIT_URL: ${{ secrets.GIT_URL }}
|
|
ITC_TEAM_ID: ${{ secrets.ITC_TEAM_ID }}
|
|
ITC_TEAM_NAME: ${{ secrets.ITC_TEAM_NAME }}
|
|
APP_STORE_CONNECT_API_KEY_KEY_ID: ${{ secrets.APP_STORE_CONNECT_API_KEY_KEY_ID }}
|
|
APP_STORE_CONNECT_API_KEY_ISSUER_ID: ${{ secrets.APP_STORE_CONNECT_API_KEY_ISSUER_ID }}
|
|
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
|
|
|
|
- name: Post PR Comment
|
|
if: success() && github.event_name == 'pull_request'
|
|
uses: actions/github-script@v6
|
|
env:
|
|
BUILD_NUMBER: ${{ needs.build.outputs.new_build_number }}
|
|
PROJECT_VERSION: ${{ needs.build.outputs.project_version }}
|
|
LATEST_COMMIT_MESSAGE: ${{ needs.build.outputs.latest_commit_message }}
|
|
with:
|
|
script: |
|
|
const buildNumber = process.env.BUILD_NUMBER;
|
|
const version = process.env.PROJECT_VERSION;
|
|
const message = `✅ Build ${version} (${buildNumber}) has been uploaded to TestFlight and will be available for testing soon.`;
|
|
const prNumber = context.payload.pull_request.number;
|
|
const repo = context.repo;
|
|
github.rest.issues.createComment({
|
|
...repo,
|
|
issue_number: prNumber,
|
|
body: message,
|
|
}); |