Skip to content

Commit c2b6475

Browse files
authored
update everything (#8)
1 parent 0436a4b commit c2b6475

File tree

114 files changed

+338
-2495
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+338
-2495
lines changed

.devcontainer/Dockerfile

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
FROM mcr.microsoft.com/devcontainers/base:ubuntu-20.04
2+
3+
4+
# ------------------------ Prepare docker environment ------------------------ #
5+
6+
RUN apt-get update
7+
8+
# Install general utilities
9+
RUN apt-get -y install tree
10+
11+
# Install Flutter dependencies
12+
RUN apt-get -y install curl file git unzip xz-utils zip clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev
13+
# Install app-specific dependencies
14+
RUN apt-get -y install keybinder-3.0 appindicator3-0.1 libappindicator3-1 libappindicator3-dev
15+
16+
# Install Flutter
17+
RUN git clone https://github.com/flutter/flutter.git -b stable /home/vscode/flutter
18+
RUN git config --global --add safe.directory /home/vscode/flutter
19+
ENV PATH="$PATH:/home/vscode/flutter/bin"
20+
RUN flutter upgrade
21+
RUN chown -R vscode:vscode /home/vscode/flutter
22+
23+
# Prepare environment for building Flatpak
24+
RUN apt-get install -y flatpak flatpak-builder
25+
RUN flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
26+
RUN flatpak install -y org.freedesktop.Sdk/x86_64/22.08
27+
RUN flatpak install -y org.freedesktop.Platform/x86_64/22.08
28+
RUN flatpak install -y flathub org.freedesktop.appstream-glib

.devcontainer/devcontainer.json

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu
3+
{
4+
"name": "Ubuntu",
5+
6+
// "image": "mcr.microsoft.com/devcontainers/base:focal",
7+
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
8+
"build": {
9+
"dockerfile": "Dockerfile"
10+
},
11+
12+
// Features to add to the dev container. More info: https://containers.dev/features.
13+
"features": {
14+
"ghcr.io/rocker-org/devcontainer-features/apt-packages:1": {}
15+
},
16+
17+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
18+
// "forwardPorts": [],
19+
20+
// Use 'postCreateCommand' to run commands after the container is created.
21+
// "postCreateCommand": "",
22+
23+
// Configure tool-specific properties.
24+
// "customizations": {},
25+
26+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
27+
// "remoteUser": "root"
28+
29+
"privileged": true,
30+
31+
"remoteEnv": {
32+
// Add Flutter to the PATH variable.
33+
"PATH": "${containerEnv:PATH}:/home/vscode/flutter/bin"
34+
}
35+
}

.github/workflows/flatpak.yml

+12-23
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ env:
1111
jobs:
1212
build-flutter-app:
1313
name: Build and compressed Flutter app
14-
runs-on: ubuntu-latest
14+
runs-on: ubuntu-20.04
1515
steps:
1616
- name: Checkout code
17-
uses: actions/checkout@v2
17+
uses: actions/checkout@v3
1818

1919
- name: Install Flutter dependencies
2020
run: |
@@ -23,48 +23,37 @@ jobs:
2323
2424
- name: Setup Flutter
2525
uses: subosito/flutter-action@v2
26-
with:
27-
channel: beta
2826

2927
- name: Build Flutter linux version
28+
working-directory: ${{ github.workspace }}/counter_app
3029
run: |
31-
flutter config --enable-linux-desktop
32-
flutter pub get
33-
flutter build linux
34-
35-
- name: Compress Flutter build
36-
run: tar -C build/linux/x64/release/bundle -acvf FlutterApp-Linux-Portable.tar.gz .
30+
./build-flutter-app.sh
3731
38-
- name: Upload app archive for next steps
39-
uses: actions/upload-artifact@v2
32+
- name: Upload app archive to workflow
33+
uses: actions/upload-artifact@v3
4034
with:
4135
name: FlutterApp-Archive
42-
path: FlutterApp-Linux-Portable.tar.gz
36+
path: counter_app/FlutterApp-Linux-Portable.tar.gz
4337

4438
build-flatpak:
4539
name: Build flatpak
4640
needs: build-flutter-app
4741
runs-on: ubuntu-latest
4842
container:
49-
image: bilelmoussaoui/flatpak-github-actions:freedesktop-21.08
43+
image: bilelmoussaoui/flatpak-github-actions:freedesktop-22.08
5044
options: --privileged
5145
steps:
5246
- name: Checkout code
53-
uses: actions/checkout@v2
54-
55-
- name: Download app archive
56-
uses: actions/download-artifact@v3
57-
with:
58-
name: FlutterApp-Archive
47+
uses: actions/checkout@v3
5948

6049
- name: Build .flatpak
61-
uses: bilelmoussaoui/flatpak-github-actions/flatpak-builder@v4
50+
uses: bilelmoussaoui/flatpak-github-actions/flatpak-builder@v5
6251
with:
6352
bundle: FlutterApp.flatpak
64-
manifest-path: com.example.FlutterApp.json
53+
manifest-path: flathub_repo/com.example.FlutterApp.yml
6554

6655
- name: Upload .flatpak artifact to workflow
67-
uses: actions/upload-artifact@v2
56+
uses: actions/upload-artifact@v3
6857
with:
6958
name: Flatpak artifact
7059
path: FlutterApp.flatpak

README.md

+45-53
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
- [Flutter Flatpak Example](#flutter-flatpak-example)
2+
- [Requirements](#requirements)
3+
- [VSCode dev container](#vscode-dev-container)
4+
- [GitHub actions](#github-actions)
5+
- [Manual Requirements](#manual-requirements)
6+
- [Instructions](#instructions)
7+
8+
19
# Flutter Flatpak Example
210

311

@@ -6,33 +14,32 @@ on Linux, using the default counter example app.
614

715
[Flatpak documentation](https://docs.flatpak.org/en/latest/index.html)
816

9-
The necessary configuration files are in the root of the repository for ease of demonstration:
10-
11-
- `com.example.FlutterApp.desktop` -- desktop menu / icon integration
12-
- `icon.svg` -- app's icon
13-
- `com.example.FlutterApp.json` -- Flatpak manifest, instructions on how to build
14-
/ assemble the flatpak
15-
- `com.example.FlutterApp.metainfo.xml` -- AppStream metadata file that contains
16-
the information about the app that would be presented on an app store like Flathub
1717

1818

1919
## Requirements
2020

21-
- flatpak
22-
- flatpak-builder
21+
> Note: Building a flatpak should be done in a predictable environment or it may
22+
> fail.
2323
24-
On ubuntu:
24+
[Set up Flathub](https://flatpak.org/setup/), and choose one:
2525

26-
> sudo apt install flatpak flatpak-builder
26+
### VSCode dev container
2727

28-
Also required: [Flathub setup](https://flatpak.org/setup/)
28+
Use the VSCode dev container provided in this repo that will run everything
29+
through Docker
2930

31+
1. Install the [Dev
32+
Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)
33+
extension
34+
35+
2. Open this directory in VSCode.
3036

31-
## Instructions
37+
3. Accept the prompt to re-open in the dev container, or from the Command
38+
Palette search for `Reopen in Container`
39+
40+
41+
### GitHub actions
3242

33-
> Note: Building a flatpak should be done in a predictable environment or it may
34-
> fail.
35-
>
3643
> There is a [GitHub
3744
> action](https://github.com/bilelmoussaoui/flatpak-github-actions) for this
3845
> purpose, which is demonstrated in this repo. This action's page also lists the
@@ -42,54 +49,39 @@ Also required: [Flathub setup](https://flatpak.org/setup/)
4249
> install the `.flatpak` file it generates with `flatpak install <path-to-.flatpak>`.
4350
4451

45-
Get Flutter project dependencies:
46-
47-
```
48-
flutter pub get
49-
```
50-
51-
52-
Build linux version:
53-
54-
```
55-
flutter build linux
56-
```
52+
### Manual Requirements
5753

54+
Install flatpak and flatpak-builder
5855

59-
Compress linux build:
56+
On ubuntu:
6057

61-
```
62-
tar -C build/linux/x64/release/bundle -acvf FlutterApp-Linux-Portable.tar.gz .
58+
```bash
59+
sudo apt install flatpak flatpak-builder
6360
```
6461

62+
Add the FlatHub repo:
6563

66-
Instruct `flatpak-builder` to use the manifest to do a flatpak build:
67-
68-
```
69-
flatpak-builder --force-clean build-dir com.example.FlutterApp.json
64+
```bash
65+
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
7066
```
7167

72-
_Optional:_
68+
Install flatpak build dependencies:
7369

74-
To build and immediately install the flatpak it produces add `--user --install` to the build command, for example:
75-
76-
```
77-
flatpak-builder --force-clean build-dir com.example.FlutterApp.json --user --install
70+
```bash
71+
flatpak install -y org.freedesktop.Sdk/x86_64/22.08
72+
flatpak install -y org.freedesktop.Platform/x86_64/22.08
73+
flatpak install -y flathub org.freedesktop.appstream-glib
7874
```
7975

80-
or to create a `.flatpak` file that can later be installed on any system:
81-
82-
```
83-
flatpak-builder --force-clean build-dir com.example.FlutterApp.json --repo=repo
84-
flatpak build-bundle repo com.example.FlutterApp.flatpak com.example.FlutterApp
85-
```
8676

87-
Will generate `com.example.FlutterApp.flatpak`, which can be installed on any system with Flatpak support:
77+
## Instructions
8878

89-
```
90-
flatpak install com.example.FlutterApp.flatpak
91-
```
79+
We have two directories that each represent what would be separate git
80+
repositories for a real project:
9281

93-
## Publish to app store
82+
`counter_app` is the Flutter app, view the README there for info on
83+
configuration and building.
9484

95-
When this succeeds you can proceed to [submit to an app store like Flathub](https://github.com/flathub/flathub/wiki/App-Submission).
85+
`flathub_repo` is separate from the Flutter app and is where the Flatpak is
86+
assembled, view the README there for info on configuration, building, and
87+
publishing of the flatpak after building the `counter_app`.

android/.gitignore

-13
This file was deleted.

android/app/build.gradle

-69
This file was deleted.

android/app/src/debug/AndroidManifest.xml

-7
This file was deleted.

0 commit comments

Comments
 (0)