diff --git a/.github/workflows/firebase-hosting-merge.yml b/.github/workflows/firebase-hosting-merge.yml index a9e5087..5d64d3e 100644 --- a/.github/workflows/firebase-hosting-merge.yml +++ b/.github/workflows/firebase-hosting-merge.yml @@ -4,6 +4,11 @@ name: Flutter Build, Release And Deploy 'on': push: + branches: + - master + +permissions: write-all + jobs: flutter_test: name: Run flutter test and analyze @@ -18,45 +23,34 @@ jobs: flutter-version: '2.10.4' channel: "stable" - run: flutter pub get - # - run: flutter analyze - # - run: flutter test + - run: flutter analyze + - run: flutter test - generate_release_note: - name: Generate release note + build_apk: + name: Generate apk files needs: [flutter_test] runs-on: ubuntu-latest + # Steps represent a sequence of tasks that will be executed as part of the job steps: - - name: Build Changelog - id: github_release - uses: mikepenz/release-changelog-builder-action@v3 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - # build_apk: - # name: Generate apk files - # needs: [flutter_test] - # runs-on: ubuntu-latest - # # Steps represent a sequence of tasks that will be executed as part of the job - # steps: - # # Setup Java environment in order to build the Android app. - # - uses: actions/checkout@v3 - # - uses: actions/setup-java@v1 - # with: - # java-version: '11.x' - # # Setup the flutter environment. - # - uses: subosito/flutter-action@v2 - # with: - # flutter-version: '2.10.4' - # channel: "stable" - # - name: Install dependencies - # run: flutter pub get - # - name: Build apk - # run: flutter build apk - # # Upload generated apk to the artifacts. - # - uses: actions/upload-artifact@master - # with: - # name: release-apk - # path: build/app/outputs/apk/release/app-release.apk + # Setup Java environment in order to build the Android app. + - uses: actions/checkout@v3 + - uses: actions/setup-java@v1 + with: + java-version: '11.x' + # Setup the flutter environment. + - uses: subosito/flutter-action@v2 + with: + flutter-version: '2.10.4' + channel: "stable" + - name: Install dependencies + run: flutter pub get + - name: Build apk + run: flutter build apk + # Upload generated apk to the artifacts. + - uses: actions/upload-artifact@master + with: + name: app-armeabi-v7a-release + path: build/app/outputs/apk/release/app-armeabi-v7a-release.apk # build_appbundle: # name: Generate appbundle files @@ -83,44 +77,89 @@ jobs: # with: # name: release-appbundle # path: build/app/outputs/bundle/release/app-release.aab + + generate_release_note: + name: Generate release note + needs: [build_apk] + runs-on: ubuntu-latest + steps: + - name: Build Changelog + id: github_release + uses: mikepenz/release-changelog-builder-action@v3 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + release_project: + name: Create Release + needs: [generate_release_note] + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Create Release + id: create_new_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + with: + tag_name: ${{ github.run_number }} + release_name: Release ${{ github.run_number }} + body: ${{steps.github_release.outputs.changelog}} + draft: false + prerelease: false + - name: Download Artifact + uses: actions/download-artifact@master + with: + name: app-armeabi-v7a-release + path: ./ + - name: Upload Release Asset + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_new_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: app-armeabi-v7a-release.apk + asset_name: app-armeabi-v7a-release.apk + asset_content_type: application/apk - # build_web: - # name: Build Flutter (Web) - # needs: [flutter_test] - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v3 - # - uses: actions/setup-java@v1 - # with: - # java-version: "18.x" - # - uses: subosito/flutter-action@v2 - # with: - # channel: "stable" - # - run: flutter pub get - # - run: flutter config --enable-web - # - run: flutter build web - # - name: Archive Production Artifact - # uses: actions/upload-artifact@master - # with: - # name: web-build - # path: build/web + build_web: + name: Build Flutter (Web) + needs: [flutter_test] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v1 + with: + java-version: "18.x" + - uses: subosito/flutter-action@v2 + with: + channel: "stable" + - run: flutter pub get + - run: flutter config --enable-web + - run: flutter build web + - name: Archive Production Artifact + uses: actions/upload-artifact@master + with: + name: web-build + path: build/web - # deploy: - # name: Deploy to firebase hosting - # runs-on: ubuntu-latest - # needs: [build_web] - # steps: - # - uses: actions/checkout@v3 - # - name: Checkout Repo - # uses: actions/checkout@master - # - name: Download Artifact - # uses: actions/download-artifact@master - # with: - # name: web-build - # path: build/web - # - uses: FirebaseExtended/action-hosting-deploy@v0 - # with: - # repoToken: '${{ secrets.GITHUB_TOKEN }}' - # firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_PORTFOLIO_E3C04 }}' - # channelId: live - # projectId: portfolio-e3c04 + deploy: + name: Deploy to firebase hosting + runs-on: ubuntu-latest + needs: [build_web] + steps: + - uses: actions/checkout@v3 + - name: Checkout Repo + uses: actions/checkout@master + - name: Download Artifact + uses: actions/download-artifact@master + with: + name: web-build + path: build/web + - uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: '${{ secrets.GITHUB_TOKEN }}' + firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_PORTFOLIO_E3C04 }}' + channelId: live + projectId: portfolio-e3c04