Add code cov to test step (#898) #216
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
on: | |
push: | |
branches: [ master, develop ] | |
jobs: | |
bump_version: | |
name: "Bump pubspec version" | |
runs-on: ubuntu-latest | |
env: | |
APP_VERSION_PATH: "uni/app_version.txt" | |
PUBSPEC_PATH: "uni/pubspec.yaml" | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.NIAEFEUPBOT_PAT }} | |
- name: Bump flutter patch version | |
if: github.ref == 'refs/heads/develop' | |
run: perl -i -pe 's/^(\d+\.\d+\.)(\d+)(\+)(\d+)$/$1.($2+1).($3).($4+1)/e' ${{ env.APP_VERSION_PATH }} | |
- name: Bump flutter minor version | |
if: github.ref == 'refs/heads/master' | |
run: perl -i -pe 's/^(\d+)(\.)(\d+)(\.)(\d+)(\+)(\d+)$/$1.($2).($3+1).($4).(0).($6).($7+1)/e' ${{ env.APP_VERSION_PATH }} | |
- name: Copy app version to pubspec | |
run: cat ${{ env.APP_VERSION_PATH }} | perl -i -pe 's/^(version:\s+)(\d+\.\d+\.\d+\+\d+)$/$1.(<STDIN>)/e' ${{ env.PUBSPEC_PATH }} | |
- uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
commit_message: "Bump app version [no ci]" | |
- name: Propagate master version bump to develop | |
if: github.ref == 'refs/heads/master' | |
run: git push --force-with-lease origin HEAD:develop | |
build: | |
name: "Build App Bundle" | |
runs-on: ubuntu-latest | |
needs: [bump_version] | |
env: | |
PROPERTIES_PATH: "android/key.properties" | |
JAVA_VERSION: "11.x" | |
FLUTTER_VERSION: "3.7.2" | |
defaults: | |
run: | |
working-directory: ./uni | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-java@v3 | |
with: | |
java-version: ${{env.JAVA_VERSION}} | |
distribution: 'zulu' | |
- uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: ${{ env.FLUTTER_VERSION }} | |
- name: Setup production environment | |
run: | | |
mkdir -p assets/env | |
rm -f -- assets/env/env.json | |
echo "{\"gh_token\": \"${{ secrets.NIAEFEUPBOT_PAT }}\"}" >> assets/env/env.json | |
- name: Download Android keystore | |
run: echo "${{ secrets.ANDROID_KEYSTORE_BASE64 }}" | base64 --decode > /tmp/key.jks | |
- name: Create key.properties | |
run: | | |
rm -f -- ${{env.PROPERTIES_PATH}} | |
touch ${{env.PROPERTIES_PATH}} | |
echo "storeFile=/tmp/key.jks" >> ${{env.PROPERTIES_PATH}} | |
echo "storePassword=${{ secrets.ANDROID_KEYSTORE_PASSWORD }}" >> ${{env.PROPERTIES_PATH}} | |
echo "keyPassword=${{ secrets.ANDROID_KEY_PASSWORD }}" >> ${{env.PROPERTIES_PATH}} | |
echo "keyAlias=${{ secrets.ANDROID_KEY_ALIAS }}" >> ${{env.PROPERTIES_PATH}} | |
- name: Build Android App Bundle | |
run: | | |
flutter pub get | |
flutter build appbundle | |
- name: Upload App Bundle | |
uses: actions/upload-artifact@v3 | |
with: | |
name: appbundle | |
if-no-files-found: error | |
path: uni/build/app/outputs/bundle/release/app-release.aab | |
deploy_play_store: | |
name: "Deploy to Google Play Store" | |
runs-on: ubuntu-latest | |
needs: [build] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Get App Bundle | |
uses: actions/download-artifact@v3 | |
with: | |
name: appbundle | |
- name: Release app to beta track | |
if: github.ref == 'refs/heads/develop' | |
uses: r0adkll/upload-google-play@v1 | |
with: | |
serviceAccountJsonPlainText: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_JSON }} | |
packageName: ${{ secrets.ANDROID_PACKAGE_NAME }} | |
releaseFiles: app-release.aab | |
whatsNewDirectory: whatsnew | |
track: beta | |
status: completed | |
- name: Release app to production track | |
if: github.ref == 'refs/heads/master' | |
uses: r0adkll/upload-google-play@v1 | |
with: | |
serviceAccountJsonPlainText: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_JSON }} | |
packageName: ${{ secrets.ANDROID_PACKAGE_NAME }} | |
releaseFiles: app-release.aab | |
whatsNewDirectory: whatsnew | |
track: production | |
status: completed |