Skip to content

Android Build and Deploy to Play Store #22

Android Build and Deploy to Play Store

Android Build and Deploy to Play Store #22

name: Android Build and Deploy to Play Store
on:
workflow_dispatch:
inputs:
branch:
description: "Branch to deploy"
required: true
default: "main"
release_type:
description: "Release type"
required: true
default: "internal"
type: choice
options:
- internal
- production
permissions:
contents: write
jobs:
deploy_for_android:
runs-on: ubuntu-latest
env:
RELEASE_TYPE: ${{ github.event.inputs.release_type }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.branch }}
- name: Set up ruby env
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2.3
bundler-cache: true
- name: Get flutter version
run: echo "flutter_version=`cat open_wearable/.flutter_version`" >> $GITHUB_ENV
id: flutter_version
- name: Install flutter
uses: subosito/flutter-action@v2
with:
channel: "stable"
cache: true
flutter-version: ${{ env.flutter_version }}
- run: flutter --version
- name: Get packages
run: |
cd open_wearable
flutter clean
flutter pub get
- name: Analyze source
run: |
cd open_wearable
flutter analyze
- name: Decode and save OPEN_WEARABLE_APP_ANDROID_KEYSTORE_PATH
run: |
echo "${{ secrets.OPEN_WEARABLE_APP_ANDROID_KEYSTORE_PATH__FILE }}" | base64 --decode > android_keystore_temp.keystore
echo "OPEN_WEARABLE_APP_ANDROID_KEYSTORE_PATH=$(realpath android_keystore_temp.keystore)" >> $GITHUB_ENV
- name: Decode and save OPEN_WEARABLE_APP_ANDROID_DEPLOYMENT_KEY_PATH
run: |
echo "${{ secrets.OPEN_WEARABLE_APP_ANDROID_DEPLOYMENT_KEY_PATH__FILE }}" | base64 --decode > android_deployment_key.json
echo "OPEN_WEARABLE_APP_ANDROID_DEPLOYMENT_KEY_PATH=$(realpath android_deployment_key.json)" >> $GITHUB_ENV
- name: Set up fastlane
run: (cd open_wearable/android && bundle install)
- name: Build & deploy Android (Internal)
if: ${{ github.event.inputs.release_type == 'internal' }}
run: |
cd open_wearable/android
bundle exec fastlane internal_deploy
env:
OPEN_WEARABLE_APP_ANDROID_KEYSTORE_PASSWORD: ${{ secrets.OPEN_WEARABLE_APP_ANDROID_KEYSTORE_PASSWORD }}
- name: Build & deploy Android (Production)
if: ${{ github.event.inputs.release_type == 'production' }}
run: |
cd open_wearable/android
bundle exec fastlane production_deploy
env:
OPEN_WEARABLE_APP_ANDROID_KEYSTORE_PASSWORD: ${{ secrets.OPEN_WEARABLE_APP_ANDROID_KEYSTORE_PASSWORD }}
- name: Bump version after production release
if: ${{ github.event.inputs.release_type == 'production' }}
shell: bash
env:
VERSION_FILE: open_wearable/pubspec.yaml
run: |
# Configure Git user
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Read current version
line=$(grep '^version:' "$VERSION_FILE")
raw_version=${line#version: }
version=${raw_version//\"/}
echo "Current version: $version"
echo "old_version=$version" >> $GITHUB_OUTPUT
# Split into semver and build metadata
semver=${version%%+*}
build=${version#*+}
IFS='.' read -r major minor patch <<< "$semver"
# Increment patch
new_patch=$((patch + 1))
new_version="${major}.${minor}.${new_patch}+${build}"
# Update version in pubspec.yaml
sed -i "s|^version: .*|version: $new_version|" "$VERSION_FILE"
echo "New version set to: $new_version"
# Commit the bump
git add "$VERSION_FILE"
git commit -m "Bump version to ${major}.${minor}.${new_patch}"
git push