Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Git Tutorial
  • Git Exercises
  • Git Basic Commands
  • Git Cheat Sheet
  • Git Interview Questions
  • Git Bash
  • GitHub
  • Git Branch
  • Git Merge
  • Git WorkFlow
  • Git Hooks
  • Git LFS
  • Git Rebase
  • Git Cherry Pick
Open In App
Next Article:
Flutter - Building and Releasing APK using GitHub Actions
Next article icon

Flutter - Building and Releasing APK using GitHub Actions

Last Updated : 09 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Github Actions is a Github tool that allows users to create CI/CD pipelines directly in a Github project instead of going to a third-party website. It assists us in developing, testing, and releasing our project very conveniently. In this article, we're going to build a workflow for our Flutter project. We'll first build the project using the workflow and then release the APK under the artifacts section of Github Actions.

Prerequisites: Basic understanding of Github Actions and writing Workflows using Github Actions. 

So now, as we have the basic understanding of how to write a workflow, let's first create a Github project in flutter and create a .yml file named flutter-workflow.yml in .github/workflows/ directory under the project's root directory. Start writing the code in that file.

XML
name: Flutter CI  on:   push:     branches:       - master  jobs:   build:     runs-on: ubuntu-latest     steps:       - uses: actions/checkout@v1       - uses: actions/setup-java@v1         with:           java-version: '12.x'       - uses: subosito/flutter-action@v1         with:           channel: 'beta'       - run: flutter pub get       - run: flutter format --set-exit-if-changed .       - run: flutter analyze .       - run: flutter build apk       - uses: actions/upload-artifact@v1         with:           name: release-apk           path: build/app/outputs/apk/release/app-release.apk 


First of all, we give a name to our workflow, here, the name is Flutter CI. Every workflow should have an 'on' bloc,k which commands the workflow to get triggered as soon as the action defined in that block is reached. In our case, we have specified that wherever there will be a new push in the master branch, the workflow will get triggered. Jobs are the crucial part of a workflow, which will have details about the tasks that have to be done. Here we have specified only one job which is build.  Every build has to go through a setup of the virtual environment, which is specified in the runs-on section. Here, we are using the Github-hosted ubuntu-latest. 

Now comes the steps section, in which we define the steps that will be executed when the workflow gets triggered. For building our code, we have to first checkout to our repository by writing actions/checkout@v1. 

The next step would involve setting up of java by actions/setup-java@v1. As we set up the java, we have to set up flutter too to build our app. Hence, we define subosito/flutter-action@v1. When we have set up Java and Flutter, we have to get the dependencies of Flutter to build the project. So we define flutter pub get. Once we get the dependencies, we format our code, flutter format --set-exit-if-changed. Flutter analyze. Runs the static analysis of our code.

Now comes the main part to build the apk and upload the APK to the artifacts section. For that, we say flutter build apk and upload the APK using actions/upload-artifact@v1 from the directory build/app/outputs/apk/release/app-release.apk to the Artifacts section of our project. After writing the code, commit it by giving a message and go to the Actions tab to see the workflow running.



After the build that is running gets completed, click again on the Actions tab and then click on the latest workflow that just completed running. Scroll to the bottom of the page, and you'll see an apk named release-apk in the artifacts section.


In this way, we created a workflow that will let you build the artifacts every time there is a new push in the main codebase i.e. master branch, and upload the newly build APK to the artifacts section of Github Actions.


Next Article
Flutter - Building and Releasing APK using GitHub Actions

I

itsnitish22
Improve
Article Tags :
  • Git
  • Flutter
  • Geeks Premier League
  • GitHub
  • Geeks-Premier-League-2022
  • Flutter-Services

Similar Reads

    Automated Release for Android Using GitHub Actions
    Automating the release process for Android applications can significantly enhance efficiency, reduce manual errors, and ensure consistent delivery. GitHub Actions provides a powerful platform to automate workflows directly from your GitHub repository. This article will guide you through setting up a
    3 min read
    Basic CI Workflow For Android using GitHub Actions
    Continuous integration (CI) is a software development process in which the team members can integrate their work. For Android developers, setting up a CI pipeline can greatly enhance productivity and code quality. GitHub Actions, a powerful automation tool integrated into GitHub, provides an excelle
    2 min read
    REST API Endpoints For GitHub Actions Variables
    GitHub Actions is used to automate workflows, build, test, and deploy code. To make workflows more dynamic and secure, GitHub Actions allows you to use variables, which can store data like configuration values, secrets, or other necessary information. GitHub exposes a REST API to manage these variab
    5 min read
    How to Build and Release Flutter Application in Android Device?
    Flutter is Google’s Mobile SDK to build native iOS and Android, Desktop (Windows, Linux, macOS), Web apps from a single codebase. When building applications with Flutter everything towards Widgets – the blocks with which the flutter apps are built. They are structural elements that ship with a bunch
    2 min read
    Spring Boot - Continuous Integration Using GitHub Actions
    Let's say we have two or more developers who are merging code into a single repository. There can be issues in merging code from different developers. So the Continuous Integration tools help in solving not just that but many other things like: Run an automated build after successful merging (like b
    3 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences