feat: Refactor and rename time calculation features #45
This file contains hidden or 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 Bookify Android APK | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| env: | |
| VERSION: "" | |
| TAG_EXISTS: false | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| #1 Checkout code | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| #2 Setup Java | |
| - name: Set Up Java | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: "oracle" | |
| java-version: "17" | |
| #3 Setup Flutter | |
| - name: Set up Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| channel: "stable" | |
| - run: flutter --version | |
| #4 Install Dependencies | |
| - name: Install dependencies | |
| run: flutter pub get | |
| #5 Setup Keystore | |
| - name: Setup Keystore and Properties | |
| run: | | |
| echo "${{ secrets.ANDROID_UPLOAD_KEYSTORE }}" | base64 --decode > android/app/keystore.jks | |
| - name: Create key.properties | |
| run: | | |
| echo "storePassword=${{ secrets.KEYSTORE_PASSWORD }}" > android/key.properties | |
| echo "keyPassword=${{ secrets.KEY_PASSWORD }}" >> android/key.properties | |
| echo "keyAlias=${{ secrets.KEY_ALIAS }}" >> android/key.properties | |
| echo "storeFile=keystore.jks" >> android/key.properties | |
| #6 Setup Facebook Config | |
| - name: Setup Facebook Config | |
| run: | | |
| echo "${{ secrets.FACEBOOK_CONFIG_XML }}" | base64 --decode > android/app/src/main/res/values/facebook_config.xml | |
| #7 Setup Firebase Config | |
| - name: Setup Firebase Config | |
| run: | | |
| echo "${{ secrets.FIREBASE_GOOGLE_SERVICES_JSON }}" | base64 --decode > android/app/google-services.json | |
| echo "${{ secrets.FIREBASE_JSON }}" | base64 --decode > firebase.json | |
| echo "${{ secrets.FIREBASE_OPTIONS_DART }}" | base64 --decode > lib/firebase_options.dart | |
| #8 Install SQLite Package to linux | |
| - name: Install SQLite Package | |
| run: sudo apt-get -y install libsqlite3-0 libsqlite3-dev | |
| #9 Analyze and Test | |
| - name: Analyze and Test | |
| run: | | |
| flutter analyze | |
| flutter test | |
| #10 Building APK | |
| - name: Build APK | |
| run: flutter build apk --release | |
| #11 Extract Version | |
| - name: Extract version from pubspec.yaml | |
| id: extract_version | |
| run: | | |
| version=$(grep '^version: ' pubspec.yaml | cut -d ' ' -f 2 | tr -d '\r') | |
| echo "VERSION=$version" >> $GITHUB_ENV | |
| #12 Check if Tag Exists | |
| - name: Check if Tag Exists | |
| id: check_tag | |
| run: | | |
| if git rev-parse "v${{ env.VERSION }}" >/dev/null 2>&1; then | |
| echo "TAG_EXISTS=true" >> $GITHUB_ENV | |
| else | |
| echo "TAG_EXISTS=false" >> $GITHUB_ENV | |
| fi | |
| #13 Modify Tag if it Exists | |
| - name: Modify Tag | |
| if: env.TAG_EXISTS == true | |
| id: modify_tag | |
| run: | | |
| new_version="${{ env.VERSION }}-build-${{ github.run_number }}" | |
| echo "VERSION=$new_version" >> $GITHUB_ENV | |
| #14 Get last commit message | |
| - name: Get last commit message | |
| if: github.event_name == 'push' | |
| id: get_commit_message | |
| run: | | |
| message=$(git log -1 --pretty=format:%B) | |
| echo "message<<EOF" >> $GITHUB_OUTPUT | |
| echo "$message" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| #15 Create Release | |
| - name: Create Release | |
| if: github.event_name == 'push' | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| artifacts: "build/app/outputs/flutter-apk/app-release.apk" | |
| body: ${{ steps.get_commit_message.outputs.message }} | |
| tag: v${{ env.VERSION }} | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| allowUpdates: true |