Building Flutter Android Apps With GitHub Actions
I will set up an automated build for your Flutter apps using Github actions & will also know how quickly Github Action will implement the concepts of an automated build and continuous integration.
Github actions is a framework for building custom workflows for software development processes. Creating your first automated build and continuous integration pipeline is now as simple as adding a single file to your pre-existing Github repository.
Lets create a branch (in mine case it actions branch) and checkout, Now we need to create a workflow file which is a YML file, In case of new in YML file, YML is a data-orientated human readable serialization language, and I have come across it in many projects including OpenAPI, Docker, Kubernetes and Ansible playbooks among others. You must store workflow files in the .github/workflows
directory of your repository.
Here in this yml file we need to write steps to automate our build process,
Lets give a name, we can give any name, this is name will be display in workflow list in the action tab under your GitHub repository
name: Dart CI
Next we need to define when our workflow should run, workflow can be response to a variety of event, including commits, pushes as well as on a schedule or even manually, A great place to start however for a new continue integration pipeline is to validate code changes when a new pull request is created, we can do this using following expression.
on:
pull_request:
branches: [ master ]
Now we are ready to define the task that will be run on each pull request, to do this need to create job, Job is just Environment+Tasks, but every workflow must have at least one task
jobs:
build-and-test:
Now we have to define our environment or the runner that will be used to execute all of the tasks.
runs-on: ubuntu-latest
Lets define steps that will actually run to validate our Flutter code, we will define like
steps:
- uses: actions/checkout@v1
- uses: actions/setup-java@v1
with:
java-version: '12.x'
name: Flutter Action
- uses: subosito/flutter-action@v1.3.2
with:
channel: 'stable' # or: 'dev' or 'beta'
- run: flutter pub get
- run: flutter analyze
- run: flutter build apk
Thats it , our simple flutter workflow is ready for android platform, now we are ready to go
we will push our changes on the actions branch as we created initially, once done got to github and will see our pull request something like, this
Since this is pull request, it will automatically start our workflow,
Once done successfully, we can see the log,
GitHub Actions Resources ➡️
https://help.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow