Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve flatpak local build #473

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions flatpak/scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,25 @@ If uploading to Flathub for the first time, follow the official contributing gui

To run a local build:

1. Build the Linux release using Flutter.
1. Build the Linux release using Flutter. `flutter build linux --release`
2. Add the new release version and date to the start of the "releases" list in the "spec.json" file (and adjust other parameters in the file if needed).
3. Run "dart flatpak_packager.dart --meta ../flatpak_meta.json -n pubspec.yaml" in this folder.
4. Run "dart manifest_generator.dart --meta ../flatpak_meta.json -n pubspec.yaml" in this folder.
3. Run `dart flatpak_packager.dart --meta ../flatpak_meta.json -n pubspec.yaml` in this folder.
4. Run `dart manifest_generator.dart --meta ../flatpak_meta.json -n pubspec.yaml` in this folder.
5. Test the Flatpak using the guide at https://docs.flatpak.org/en/latest/first-build.html, using the generated json manifest as your Flatpak manifest.
```bash
cd flatpak_generator_exports
flatpak-builder --user --install flatpak-build-dir de.wger.flutter.json
```

# Builds based on data fetched from Github

To generate and publish a release on Github:

1. Create a new release on Github using the app's version name for the tag (e.g. "1.0.0"), without any assets for now.
2. Build the Linux release using Flutter.
3. Run "dart flatpak_packager.dart --meta ../flatpak_meta.json --github -n pubspec.yaml" in this folder.
3. Run `dart flatpak_packager.dart --meta ../flatpak_meta.json --github -n pubspec.yaml` in this folder.
4. Upload the generated tar.gz file as a Github release.
5. Run "dart manifest_generator.dart --meta ../flatpak_meta.json --github -n pubspec.yaml" in this folder.
5. Run `dart manifest_generator.dart --meta ../flatpak_meta.json --github -n pubspec.yaml` in this folder.
6. Upload your Flathub manifest file to your Flathub Github repo, overwriting any old manifest file you may have there. If you're building for only certain architectures and the "flathub.json" file is not in your Flathub Github repo yet, upload that too.

All of this can be automated via Github Actions.
4 changes: 4 additions & 0 deletions flatpak/scripts/flatpak_packager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ class PackageGenerator {

shaByArch.putIfAbsent(arch, () => sha256);

final localReleaseAssetsFile = await File('${outputDir.path}/local_release_assets.json')
.writeAsString('[{"arch": "${arch.flatpakArchCode}", "tarballPath": "$packagePath"}]');
print('Generated ${localReleaseAssetsFile.path}');

tempDir.deleteSync(recursive: true);
}

Expand Down
8 changes: 7 additions & 1 deletion flatpak/scripts/flatpak_shared.dart
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,12 @@ class FlatpakMeta {
static FlatpakMeta fromJson(File jsonFile) {
try {
final dynamic json = jsonDecode(jsonFile.readAsStringSync());
final localReleaseAssetsFile = File(
'${Directory.current.path}/flatpak_generator_exports/local_release_assets.json'
);
if (localReleaseAssetsFile.existsSync()) {
json['localReleaseAssets'] = jsonDecode(localReleaseAssetsFile.readAsStringSync());
}
return FlatpakMeta(
appId: json['appId'] as String,
lowercaseAppName: json['lowercaseAppName'] as String,
Expand All @@ -270,7 +276,7 @@ class FlatpakMeta {
throw Exception(
'Architecture must be either "${CPUArchitecture.x86_64.flatpakArchCode}" or "${CPUArchitecture.aarch64.flatpakArchCode}"');
}
final tarballPath = '${jsonFile.parent.path}/${raMap['tarballPath'] as String}';
final tarballPath = raMap['tarballPath'] as String;
final preShasum = Process.runSync('shasum', ['-a', '256', tarballPath]);
final shasum = preShasum.stdout.toString().split(' ').first;
if (preShasum.exitCode != 0) {
Expand Down