Skip to content
This repository was archived by the owner on Apr 3, 2025. It is now read-only.

Commit b1d01e0

Browse files
committed
feat(linux): publish Linux builds as Debian archive (.deb)
[skip ci]
1 parent 3858de8 commit b1d01e0

File tree

6 files changed

+137
-11
lines changed

6 files changed

+137
-11
lines changed

.github/workflows/build.yml

+3
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ jobs:
5959
name: Build Linux
6060
needs: [ prepare ]
6161
uses: JagandeepBrar/LunaSea/.github/workflows/build_linux.yml@master
62+
with:
63+
build-number: ${{ needs.prepare.outputs.build-number }}
64+
build-version: ${{ needs.prepare.outputs.build-version }}
6265

6366
build-macos:
6467
name: Build macOS

.github/workflows/build_linux.yml

+41-11
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,34 @@ name: 'Build Linux'
22

33
on:
44
workflow_call:
5-
5+
inputs:
6+
build-number:
7+
required: true
8+
type: string
9+
build-version:
10+
required: true
11+
type: string
12+
613
jobs:
7-
build-snapcraft:
8-
name: Snapcraft
14+
build-debian:
15+
name: Debian Archive
916
runs-on: ubuntu-latest
1017
steps:
1118
- name: Setup Environment
1219
uses: JagandeepBrar/LunaSea/.github/actions/prepare_for_build@master
1320
with:
1421
platform: linux
15-
22+
1623
- name: Build LunaSea
17-
uses: snapcore/action-build@v1
18-
id: build
19-
20-
- name: Prepare Artifact
21-
run: mv ${{ steps.build.outputs.snap }} ${{ github.workspace }}/output/lunasea-linux-amd64.snap
24+
run: flutter build linux
2225

26+
- name: Prepare Artifact
27+
run: dart ${{github.workspace }}/scripts/generate_debian.dart "${{ inputs.build-version }}+${{ inputs.build-number }}"
28+
2329
- name: Upload Artifact
2430
uses: actions/upload-artifact@v3
2531
with:
26-
name: linux-snapcraft
32+
name: linux-debian
2733
path: ${{ github.workspace }}/output
2834

2935
build-tarball:
@@ -45,4 +51,28 @@ jobs:
4551
uses: actions/upload-artifact@v3
4652
with:
4753
name: linux-tarball
48-
path: ${{ github.workspace }}/output
54+
path: ${{ github.workspace }}/output
55+
56+
build-snapcraft:
57+
name: Snapcraft
58+
runs-on: ubuntu-latest
59+
steps:
60+
- name: Setup Environment
61+
uses: JagandeepBrar/LunaSea/.github/actions/prepare_for_build@master
62+
with:
63+
platform: linux
64+
65+
- name: Build LunaSea
66+
uses: snapcore/action-build@v1
67+
id: build
68+
69+
- name: Prepare Artifact
70+
run: mv ${{ steps.build.outputs.snap }} ${{ github.workspace }}/output/lunasea-linux-amd64.snap
71+
72+
- name: Upload Artifact
73+
uses: actions/upload-artifact@v3
74+
with:
75+
name: linux-snapcraft
76+
path: ${{ github.workspace }}/output
77+
78+

.github/workflows/publish_s3.yml

+6
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ jobs:
4747
name: ios-appstore-package
4848
path: ${{ github.workspace }}/output
4949

50+
- name: Download Linux Debian
51+
uses: actions/download-artifact@v3
52+
with:
53+
name: linux-debian
54+
path: ${{ github.workspace }}/output
55+
5056
- name: Download Linux Tarball
5157
uses: actions/download-artifact@v3
5258
with:

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ jspm_packages/
7878

7979
# Artifacts
8080
output/
81+
debian/
8182
*.apk
8283
*.aab
8384
*.ipa

assets/icon/icon_linux.png

58.3 KB
Loading

scripts/generate_debian.dart

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import 'dart:io';
2+
3+
void main(List<String> args) {
4+
_createSkeleton();
5+
6+
_generateControl(args[0]);
7+
_generateDesktopEntry();
8+
_copyIcon();
9+
_copyBuild();
10+
11+
_buildDebian();
12+
}
13+
14+
Future<void> _createSkeleton() async {
15+
if (Directory('debian').existsSync()) {
16+
Directory('debian').deleteSync(recursive: true);
17+
}
18+
19+
Directory('debian/DEBIAN').createSync(recursive: true);
20+
Directory('debian/usr/local/lib').createSync(recursive: true);
21+
Directory('debian/usr/share/applications').createSync(recursive: true);
22+
Directory('debian/usr/share/icons').createSync(recursive: true);
23+
}
24+
25+
void _generateControl(String version) {
26+
final control = File('debian/DEBIAN/control');
27+
28+
String data = '';
29+
data += 'Version:$version\n';
30+
data += 'Architecture:amd64\n';
31+
data += 'Package:LunaSea\n';
32+
data += 'Essential:no\n';
33+
data += 'Priority:optional\n';
34+
data += 'Maintainer:LunaSea Support <[email protected]>\n';
35+
data += 'Description:Self-hosted software controller built using Flutter\n';
36+
37+
control.writeAsStringSync(data);
38+
}
39+
40+
void _generateDesktopEntry() {
41+
final entry = File('debian/usr/share/applications/lunasea.desktop');
42+
43+
String data = '';
44+
data += '[Desktop Entry]\n';
45+
data += 'Name=LunaSea\n';
46+
data += 'Comment=Self-hosted software controller built using Flutter\n';
47+
data += 'Icon=/usr/share/icons/lunasea.png\n';
48+
data += 'Terminal=false\n';
49+
data += 'Type=Application\n';
50+
data += 'Categories=Utilities;Entertainment;\n';
51+
data += 'Exec=/usr/local/lib/LunaSea/lunasea\n';
52+
data += 'TryExec=/usr/local/lib/LunaSea/lunasea\n';
53+
54+
entry.writeAsStringSync(data);
55+
}
56+
57+
void _copyIcon() {
58+
final icon = File('assets/icon/icon_linux.png');
59+
icon.copySync('debian/usr/share/icons/lunasea.png');
60+
}
61+
62+
void _copyBuild() {
63+
Process.runSync(
64+
'cp',
65+
['-r', 'build/linux/x64/release/bundle', 'debian/usr/local/lib'],
66+
);
67+
Process.runSync(
68+
'mv',
69+
['debian/usr/local/lib/bundle', 'debian/usr/local/lib/LunaSea'],
70+
);
71+
}
72+
73+
void _buildDebian() {
74+
if (!Directory('output').existsSync()) {
75+
Directory('output').createSync(recursive: true);
76+
}
77+
78+
Process.runSync(
79+
'dpkg-deb',
80+
['--build', 'debian'],
81+
);
82+
Process.runSync('mv', [
83+
'debian.deb',
84+
'output/lunasea-linux-amd64.deb',
85+
]);
86+
}

0 commit comments

Comments
 (0)