DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Cover image for Flutter APK Generator Action
Ishan Sharma
Ishan Sharma

Posted on • Updated on

Flutter APK Generator Action

My Workflow

I have made a GitHub Action named 'APK Generator' for flutter projects to help in generating a new apk and pushing it to the repository, whenever changes are made in master branch.

With ease:

  • Generate new release apk's whenever changes are pushed
  • distribute and test your apps quickly among all collaborators
  • keep a track of every apk release version.

Submission Category:

Maintainer Must-Haves , DIY Deployments

Yaml File or Link to Code

An example workflow to set up your flutter apk generator action quickly.

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - name: Setting up Flutter SDK
        uses: subosito/flutter-action@v1
        with:
          channel: stable

      - name: Fetch Packages
        run: flutter pub get

      - name: Build APK
        run: flutter build apk

      - name: Copy APK To Parent Directory
        run: cp ./build/app/outputs/flutter-apk/app-release.apk ./app.apk

      - name: Commit APK
        run: git add ./app.apk

      - name: Configure Github
        run: |
          git config --local user.email "you@email.com"
          git config --local user.name "yourusername"
          git commit -m "Generated APK" -a

      - name: Push changes
        uses: ad-m/github-push-action@master
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}

GitHub logo ishandeveloper / flutter-action-example

GitHub Action for generating a new apk and pushing it to the repository, whenever changes are made in master branch.


Flutter APK Generator Action


This repository is dedicated to a GitHub Action for generating a new apk and pushing it to the repository, whenever changes are made in master branch.

With ease:

  • Generate new release apk's whenever changes are pushed
  • distribute and test your apps quickly among all collaborators
  • keep a track of every apk release version.
THIS REPOSITORY WAS CREATED AS A PART OF ACTIONS HACKATHON HOSTED BY DEV.TO AND GITHUB

Usage

Example Workflow file

An example workflow to set up your flutter apk generator action quickly.

jobs
  build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - name: Setting up Flutter SDK
        uses: subosito/flutter-action@v1
        with:
          channel: stable

      - name: Fetch Packages
        run: flutter pub get

      - name: Build APK
        run: flutter build apk

      - name: Copy APK To Parent Directory
        run: cp ./build/app/outputs/flutter-apk/app-release.apk ./app.apk

      - 
…

Additional Resources / Info

This action uses following two open-source actions under the hood to set up things easily.

GitHub logo ad-m / github-push-action

GitHub actions to push back to repository eg. updated code

GitHub Action for GitHub Push

The GitHub Actions for pushing to GitHub repository local changes authorizing using GitHub token.

With ease:

  • update new code placed in the repository, e.g. by running a linter on it,
  • track changes in script results using Git as archive,
  • publish page using GitHub-Pages,
  • mirror changes to a separate repository.

Usage

Example Workflow file

An example workflow to authenticate with GitHub Platform:

jobs
  build
    runs-on: ubuntu-latest
    steps
    - uses: actions/checkout@master
      with
        persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
        fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
    - name: Create local changes
      run: |
        ...
    - name: Commit files
      run: |
        git config --local user.email "action@github.com"
        git config --local user.name "GitHub Action"
        git commit -m "Add changes" -a
    - name: Push
…

GitHub logo subosito / flutter-action

Flutter environment for use in actions. It works on Linux, Windows, and macOS.

flutter-action

This action sets up a flutter environment for use in actions. It works on Linux, Windows, and macOS.

Usage

steps
- uses: actions/checkout@v1
- uses: actions/setup-java@v1
  with
    java-version: '12.x'
- uses: subosito/flutter-action@v1
  with
    flutter-version: '1.9.1+hotfix.6'
- run: flutter pub get
- run: flutter test
- run: flutter build apk

Build for iOS too (macOS only):

jobs:
  build:
    runs-on: macos-latest
    steps:
    - uses: actions/checkout@v1
    - uses: actions/setup-java@v1
      with:
        java-version: '12.x'
    - uses: subosito/flutter-action@v1
      with:
        flutter-version: '1.9.1+hotfix.6'
    - run: flutter pub get
    - run: flutter test
    - run: flutter build apk
    - run: flutter build ios --release --no-codesign

Use app bundle, instead of APK:

steps
- uses: actions/checkout@v1
- uses: actions/setup-java@v1
  with:
    java-version
…

Made with β™₯ by ishandeveloper

Top comments (0)

🌚 Friends don't let friends browse without dark mode.

Sorry, it's true.