Skip to content

Release App

Release App #173

Workflow file for this run

name: Release App
on:
# Only publishes on main (by semantic release)
workflow_dispatch:
inputs:
track:
type: environment
description: Release environment (e.g. test, production)
default: test
force-release:
type: boolean
description: Release even if there's no new version
default: false
whats-new:
type: string
description: What's new text for Play Store (supports escape chars)
# Don't shame me, this is in case I really have nothing new to write :)
default: Nova versão com melhorias funcionais.
concurrency:
group: ${{ github.workflow }}
permissions:
contents: write
jobs:
version:
name: Get new version
runs-on: ubuntu-latest
outputs:
has-new-version: ${{ steps.semantic-release.outputs.new_release_published }}
new-version: ${{ steps.semantic-release.outputs.new_release_version }}
last-version: ${{ steps.semantic-release.outputs.last_release_version }}
steps:
- uses: actions/checkout@v4
- name: 🚚 - Semantic Release
uses: cycjimmy/semantic-release-action@v4
id: semantic-release
with:
dry_run: true
extra_plugins: |
semantic-release-replace-plugin
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build:
name: Build App
runs-on: ubuntu-latest
needs: [version]
if: needs.version.outputs.has-new-version == 'true' || ${{ inputs.force-release }}
steps:
- uses: actions/checkout@v4
- name: 📩 - Retrieve the build signature secrets
env:
KEYSTORE: ${{ secrets.KEYSTORE }}
KEY_PROPERTIES: ${{ secrets.KEY_PROPERTIES }}
run: |
echo -ne "$KEYSTORE" | base64 --decode > android/pessoa-pensadora.jks && \
echo "$KEY_PROPERTIES" > android/key.properties
- name: 💎 - Install Flutter
uses: subosito/[email protected]
with:
flutter-version: '3.x'
channel: 'stable'
- uses: actions/setup-java@v4
with:
distribution: 'corretto'
java-version: '17'
# Google Play requires version code (int) to increment on every release
- name: 🔧 - Prepare release
run: |
versionCode=$(date '+%y%m%d%H')
sed -i -e "s/version: .*/version: ${{ needs.version.outputs.new-version != '' && needs.version.outputs.new-version || needs.version.outputs.last-version }}+$versionCode/g" pubspec.yaml
- name: 🌱 - Get dependencies
run: cat pubspec.yaml && echo && flutter pub get
- name: 🔨 - Build
run: |
flutter build apk --release --flavor prod
flutter build appbundle --release --flavor prod
- name: 🧹 - Cleanup
run: |
rm android/pessoa-pensadora.jks android/key.properties
mv build/app/outputs/flutter-apk/app-prod-release.apk PessoaPensadora.apk
mv build/app/outputs/bundle/prodRelease/app-prod-release.aab PessoaPensadora.aab
- name: 📦 - Copy APK
uses: actions/upload-artifact@v4
with:
name: PessoaPensadora.apk
path: PessoaPensadora.apk
if-no-files-found: error
- name: 📦 - Copy App Bundle
uses: actions/upload-artifact@v4
with:
name: PessoaPensadora.aab
path: PessoaPensadora.aab
if-no-files-found: error
release:
name: Release
needs: [build]
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
pull-requests: write
steps:
- uses: actions/checkout@v3
- name: 📦 - Copy server artifacts
uses: actions/download-artifact@v4
with:
path: artifacts/
merge-multiple: true
- name: 🧐 - Display structure of downloaded artifacts
run: ls -R artifacts/
- name: 🚚 - Semantic Release
uses: cycjimmy/semantic-release-action@v4
with:
extra_plugins: |
semantic-release-replace-plugin
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-to-google-play:
name: Publish to Google Play
needs: [version, release]
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: 'actions/checkout@v4'
- name: 📦 - Copy server artifacts
uses: actions/download-artifact@v4
with:
path: artifacts/
merge-multiple: true
- id: auth
uses: 'google-github-actions/auth@v2'
with:
workload_identity_provider: projects/${{ vars.GCP_PROJECT_ID }}/locations/global/workloadIdentityPools/${{ vars.GCP_WORKLOAD_IDENTITY_POOL }}/providers/${{ vars.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ vars.GCP_SERVICE_ACCOUNT }}
- name: Print release notes
run: |
mkdir releaseNotes/
echo -ne "${{ inputs.whats-new }}" > releaseNotes/whatsnew-pt-PT"
- name: Upload to Google Play
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJson: ${{ steps.auth.outputs.credentials_file_path }}
packageName: me.l3n.pessoapensadora.pessoa_pensadora
releaseFiles: artifacts/PessoaPensadora.aab
track: ${{ vars.RELEASE_TRACK }}
whatsNewDirectory: releaseNotes/
status: draft