Skip to content

Commit

Permalink
Add build release job in workflow action.
Browse files Browse the repository at this point in the history
  • Loading branch information
ab3masta committed Mar 21, 2023
1 parent 1d4133d commit a8b3b0a
Showing 1 changed file with 113 additions and 74 deletions.
187 changes: 113 additions & 74 deletions .github/workflows/firebase-hosting-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

0 comments on commit a8b3b0a

Please sign in to comment.