Skip to content

[studio] Add GitHub Action #204

[studio] Add GitHub Action

[studio] Add GitHub Action #204

name: Production Workflow
on:
push:
branches:
- main
env:
flutter_version: "3.19.3"
jobs:
build-apk:
name: "build apk 🔨"
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.PE_PRIVATE_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.PE_PRIVATE_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.PE_AWS_REGION }}
- name: Download credential files
run: |
aws s3 cp s3://${{ secrets.PE_PRIVATE_AWS_S3_BUCKET_NAME }}/credentials/client/google-services.json ./android/app/
aws s3 cp s3://${{ secrets.PE_PRIVATE_AWS_S3_BUCKET_NAME }}/credentials/client/upload-keystore.jks ./android/app/
aws s3 cp s3://${{ secrets.PE_PRIVATE_AWS_S3_BUCKET_NAME }}/credentials/client/key.properties ./android/
- name: Including Paladins Assets in this build
run: |
aws s3 sync s3://${{ secrets.PE_PRIVATE_AWS_S3_BUCKET_NAME }}/paladins_assets/ ./paladins_assets/
rm pubspec.yaml
mv pubspec.assets.yaml pubspec.yaml
- name: Install Flutter
uses: subosito/flutter-action@v2
with:
channel: "stable"
flutter-version: ${{ env.flutter_version }}
- name: Get dependencies
run: flutter pub get
- name: Flutter version
run: flutter --version
- name: Build apk
run: flutter build apk --release --build-number=${{ github.run_number }}
- name: Upload apk
uses: actions/upload-artifact@v4
with:
name: apk
path: ./build/app/outputs/flutter-apk/app-release.apk
build-bundle:
name: "build bundle 🛠️"
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.PE_PRIVATE_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.PE_PRIVATE_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.PE_AWS_REGION }}
- name: Download credential files
run: |
aws s3 cp s3://${{ secrets.PE_PRIVATE_AWS_S3_BUCKET_NAME }}/credentials/client/google-services.json ./android/app/
aws s3 cp s3://${{ secrets.PE_PRIVATE_AWS_S3_BUCKET_NAME }}/credentials/client/upload-keystore.jks ./android/app/
aws s3 cp s3://${{ secrets.PE_PRIVATE_AWS_S3_BUCKET_NAME }}/credentials/client/key.properties ./android/
- name: Including Paladins Assets in this build
run: |
aws s3 sync s3://${{ secrets.PE_PRIVATE_AWS_S3_BUCKET_NAME }}/paladins_assets/ ./paladins_assets/
rm pubspec.yaml
mv pubspec.assets.yaml pubspec.yaml
- name: Install Flutter
uses: subosito/flutter-action@v2
with:
channel: "stable"
flutter-version: ${{ env.flutter_version }}
- name: Setup properties
run: |
cat >> "./android/key.properties" <<EOF
storePassword=${{ secrets.FCI_KEYSTORE_PASSWORD }}
keyPassword=${{ secrets.FCI_KEY_PASSWORD }}
keyAlias=${{ secrets.FCI_KEY_ALIAS }}
storeFile=upload-keystore.jks
EOF
- name: Get dependencies
run: flutter pub get
- name: Flutter version
run: flutter --version
- name: Build bundle
run: flutter build appbundle --release --build-number=${{ github.run_number }}
- name: Get release notes
run: git log -1 --pretty="PRODUCTION BUILD - Commit %h%n- Date %cs%n- %s" > release_notes.txt
- name: Upload bundle to app distribution
uses: wzieba/[email protected]
with:
appId: 1:280154424805:android:06755c7776c617c0aa1b0c
serviceCredentialsFileContent: ${{ secrets.CREDENTIAL_FILE_CONTENT }}
groups: Developers
releaseNotesFile: ./release_notes.txt
file: ./build/app/outputs/bundle/release/app-release.aab
- name: Upload bundle
uses: actions/upload-artifact@v4
with:
name: aab
path: ./build/app/outputs/bundle/release/app-release.aab
build-web:
name: "build web 🌐"
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.PE_PRIVATE_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.PE_PRIVATE_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.PE_AWS_REGION }}
- name: Install Flutter
uses: subosito/flutter-action@v2
with:
channel: "stable"
flutter-version: ${{ env.flutter_version }}
- name: Get dependencies
run: flutter pub get
- name: Flutter version
run: flutter --version
- name: Build web
run: flutter build web --release --build-number=${{ github.run_number }}
- name: Deploy to S3
run: aws s3 sync ./build/web/ s3://${{ secrets.PE_WEB_BUCKET_NAME }}/ --delete
- name: Create zip archive
run: zip -r web.zip ./build/web/
- name: Upload web
uses: actions/upload-artifact@v4
with:
name: web
path: ./web.zip
create-release:
name: "create release 📦"
needs: [build-apk, build-bundle, build-web]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
- name: View files
run: ls ./artifacts
- name: Get flutter version
id: flutter_version
uses: NiklasLehnfeld/flutter-version-number-action@main
with:
file-path: ./pubspec.yaml
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/[email protected]
with:
custom_tag: ${{ steps.flutter_version.outputs.version-number }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Create a GitHub release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.tag_version.outputs.new_tag }}
name: Release ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
artifacts: |
./artifacts/apk/app-release.apk,
./artifacts/aab/app-release.aab,
./artifacts/web/web.zip