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 }}

Enter fullscreen mode Exit fullscreen mode

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

      - 
Enter fullscreen mode Exit fullscreen mode

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 and to push the changes to a specified reference, e.g. an already available branch:

jobs
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
      with:
        persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
        fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
    - name: Create local changes
      run: |
        ...
    - name: Commit files
      run: |
        git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
Enter fullscreen mode Exit fullscreen mode

GitHub logo subosito / flutter-action

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

flutter-action

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

Usage

Use specific version and channel:

steps
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
  with:
    flutter-version: '3.0.5'
    channel: 'stable'
- run: flutter --version
Enter fullscreen mode Exit fullscreen mode

Use latest release for particular channel:

steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
  with:
    channel: 'stable' # or: 'beta', 'dev' or 'master'
- run: flutter --version
Enter fullscreen mode Exit fullscreen mode

Use latest release for particular version and/or channel:

steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
  with:
    flutter-version: '1.22.x' # or, you can use 1.22
    channel: 'dev'
- run: flutter --version
Enter fullscreen mode Exit fullscreen mode

Use particular version on any channel:

steps
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
  with:
    flutter-version: '2.x'
    channel: 'any
Enter fullscreen mode Exit fullscreen mode

Made with ♥ by ishandeveloper

Oldest comments (0)