Files
workavia-mail-front/.github/workflows/release.yaml
T

142 lines
4.7 KiB
YAML

on:
push:
tags:
- "v*.*.*"
name: Release
env:
FLUTTER_VERSION: 3.32.8
XCODE_VERSION: 16.0
jobs:
release:
name: Release
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ${{ matrix.runner }}
strategy:
matrix:
include:
- os: android
runner: ubuntu-latest
- os: ios
runner: macos-14 # Use macos-14 runners because Xcode 16 only exists on macOS 14+.
fail-fast: false
environment: prod
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: "stable"
cache: true
cache-key: deps-${{ hashFiles('**/pubspec.lock') }} # optional, change this to force refresh cache
cache-path: ${{ runner.tool_cache }}/flutter # optional, change this to specify the cache path
- name: Setup Firebase env
env:
FIREBASE_ENV: ${{ secrets.FIREBASE_ENV }}
run: ./scripts/setup-firebase.sh
- name: Setup Fastlane
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.3"
bundler-cache: true
working-directory: ${{ matrix.os }}
- name: Setup Java
if: matrix.os == 'android'
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "17"
- name: Select Xcode version
if: matrix.os == 'ios'
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: ${{ env.XCODE_VERSION }}
- name: Setup Android environment
if: matrix.os == 'android'
env:
PLAY_STORE_UPLOAD_KEY_BASE64: ${{ secrets.PLAY_STORE_UPLOAD_KEY_BASE64 }}
PLAY_STORE_KEY_INFO_BASE64: ${{ secrets.PLAY_STORE_KEY_INFO_BASE64 }}
run: ../scripts/setup-android.sh
working-directory: ${{ matrix.os }}
- name: Setup iOS environment
if: matrix.os == 'ios'
run: ../scripts/setup-ios.sh
working-directory: ${{ matrix.os }}
- name: Run prebuild
run: ./scripts/prebuild.sh
- name: Build and deploy
env:
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
APPLE_CERTIFICATES_SSH_KEY: ${{ secrets.APPLE_CERTIFICATES_SSH_KEY }}
PLAY_STORE_CONFIG_JSON: ${{ secrets.PLAY_STORE_CONFIG_JSON }}
APPLE_ISSUER_ID: ${{ secrets.APPLE_ISSUER_ID }}
APPLE_KEY_ID: ${{ secrets.APPLE_KEY_ID }}
APPLE_KEY_CONTENT: ${{ secrets.APPLE_KEY_CONTENT }}
run: ../scripts/build-release.sh
working-directory: ${{ matrix.os }}
# --- UPLOAD SENTRY MAPPING AND SYMBOLS FOR ANDROID ---
- name: Upload Android ProGuard Mapping & Dart Debug Symbols to Sentry
if: matrix.os == 'android'
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
run: |
# 1. Install Sentry CLI
curl -sL https://sentry.io/get-cli/ | SENTRY_CLI_VERSION="2.42.2" bash
# 2. Validate tag version matches pubspec.yaml version
TAG_VERSION="${GITHUB_REF_NAME#v}"
TAG_VERSION="${TAG_VERSION%%-rc*}"
PUBSPEC_VERSION=$(awk '/^version:/{split($2,a,"+"); print a[1]; exit}' pubspec.yaml)
if [ "$PUBSPEC_VERSION" != "$TAG_VERSION" ]; then
echo "::error::Tag version ($TAG_VERSION) does not match pubspec version ($PUBSPEC_VERSION)."
exit 1
fi
SENTRY_RELEASE="$PUBSPEC_VERSION"
echo "Processing Sentry Release: $SENTRY_RELEASE"
# 3. Create Release
sentry-cli releases new "$SENTRY_RELEASE"
# 4. Upload ProGuard Mapping
MAPPING_FILE="build/app/outputs/mapping/release/mapping.txt"
if [ -f "$MAPPING_FILE" ]; then
echo "Found mapping.txt, uploading ProGuard mapping..."
sentry-cli upload-proguard "$MAPPING_FILE"
else
echo "::error::Could not find mapping.txt at $MAPPING_FILE."
exit 1
fi
# 5. Upload Dart Debug Symbols (Native Dart Stacktrace)
SYMBOLS_DIR="build/app/outputs/symbols"
if [ -d "$SYMBOLS_DIR" ]; then
echo "Uploading Dart debug symbols from $SYMBOLS_DIR..."
sentry-cli debug-files upload "$SYMBOLS_DIR"
else
echo "::error::Symbols directory not found at $SYMBOLS_DIR. Check your Fastfile build arguments."
exit 1
fi
# 6. Finalize
sentry-cli releases finalize "$SENTRY_RELEASE"