Parse flutter version from pubspec.yml for action. #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Flutter app for an environment | ||
on: [push] | ||
permissions: | ||
contents: read | ||
jobs: | ||
deployAndroid: | ||
permissions: write-all | ||
name: 🤖📦🚀 Build & deploy Android release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set Flutter version | ||
run: | | ||
export FLUTTER_VERSION="$(sed -E -n -e 's/^.*flutter:\ ">=([0-9.]+)"/\1/p' app/pubspec.yaml)" | ||
env: FLUTTER_VERSION: ${ { env.FLUTTER_VERSION } } | ||
- name: ⬇️ Checkout repository | ||
uses: actions/checkout@v3 | ||
- name: ⚙️ Setup Java | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: "11.x" | ||
cache: 'gradle' | ||
distribution: 'adopt' | ||
id: java | ||
- name: ⚙️ Setup Flutter | ||
uses: subosito/flutter-action@v2 | ||
with: | ||
flutter-version: ${ { env.FLUTTER_VERSION } } | ||
channel: 'stable' | ||
cache: true | ||
id: flutter | ||
- name: 🔐 Retrieve base64 keystore and decode it to a file | ||
id: write_file | ||
uses: timheuer/[email protected] | ||
with: | ||
fileName: "android-keystore.jks" | ||
fileDir: "${{ github.workspace }}/" | ||
encodedString: ${{ secrets.KEYSTORE_FILE_BASE64 }} | ||
- name: 📝🔐 Create keystore.properties file | ||
env: | ||
KEYSTORE_PROPERTIES_PATH: ${{ github.workspace }}/app/android/key.properties | ||
run: | | ||
echo "storeFile=${{ github.workspace }}/android-keystore.jks" > $KEYSTORE_PROPERTIES_PATH | ||
echo "keyAlias=${{ secrets.KEYSTORE_KEY_ALIAS }}" >> $KEYSTORE_PROPERTIES_PATH | ||
echo "storePassword=${{ secrets.KEYSTORE_PASSWORD }}" >> $KEYSTORE_PROPERTIES_PATH | ||
echo "keyPassword=${{ secrets.KEYSTORE_KEY_PASSWORD }}" >> $KEYSTORE_PROPERTIES_PATH | ||
- name: Pub Get Packages | ||
run: | | ||
cd app | ||
flutter --disable-telemetry | ||
flutter pub get | ||
- name: 🤖📦 Create Android release | ||
run: | | ||
cd app | ||
flutter build apk --split-per-abi --release |