1+ open Fake.Core
12open Fake.IO
3+ open System.IO
4+ open System.Net .Http
25
36open RunHelpers
7+ open RunHelpers.BasicShortcuts
48open RunHelpers.Templates
59
610[<RequireQualifiedAccess>]
@@ -17,6 +21,11 @@ module Config =
1721
1822 let publishPath = " ./publish"
1923
24+ let framework = " net6.0"
25+ let appimagetoolVersion = " continuous"
26+
27+ let httpClient = new HttpClient()
28+
2029module Task =
2130 let restore () =
2231 job {
@@ -43,6 +52,84 @@ module Task =
4352 DotNet.run proj
4453 }
4554
55+ let publishAsAppImage () =
56+ let result =
57+ job {
58+ dotnet [
59+ " publish"
60+ " -v"
61+ " m"
62+ " -c"
63+ " Release"
64+ " -f"
65+ Config.framework
66+ " -r"
67+ " linux-x64"
68+ " --self-contained"
69+ " -p:PublishTrimmed=true"
70+ " -p:DebugType=None"
71+ Config.mainProject
72+ ]
73+
74+ Shell.mkdir " AppDir/usr"
75+
76+ Shell.mv
77+ $" src/Andromeda/AvaloniaApp/bin/Release/{Config.framework}/linux-x64/publish"
78+ " AppDir/usr/bin"
79+
80+ Internal.basicCommand
81+ " cp"
82+ [ " -a"
83+ " assets/build/appimage/."
84+ " AppDir" ]
85+
86+ if not ( File.exists " appimagetool-x86_64.AppImage" ) then
87+ do
88+ task {
89+ let! response =
90+ httpClient.GetAsync(
91+ $" https://github.com/AppImage/AppImageKit/releases/download/{Config.appimagetoolVersion}/appimagetool-x86_64.AppImage" ,
92+ HttpCompletionOption.ResponseHeadersRead
93+ )
94+
95+ use file = File.OpenWrite " ./appimagetool-x86_64.AppImage"
96+ do ! response.Content.CopyToAsync file
97+ }
98+ |> Async.AwaitTask
99+ |> Async.RunSynchronously
100+
101+ Internal.basicCommand
102+ " chmod"
103+ [ " a+x"
104+ " appimagetool-x86_64.AppImage" ]
105+
106+ Internal.basicCommand
107+ " ./appimagetool-x86_64.AppImage"
108+ [ " --appimage-extract-and-run"
109+ " --no-appstream"
110+ " AppDir"
111+ " -u"
112+ " gh-releases-zsync|NicoVIII|Andromeda-for-GOG|latest|Andromeda-*.AppImage.zsync" ]
113+
114+ Internal.basicCommand
115+ " mv"
116+ [ " Andromeda-x86_64.AppImage"
117+ " ./publish/Andromeda-x86_64.AppImage" ]
118+
119+ Internal.basicCommand
120+ " mv"
121+ [ " Andromeda-x86_64.AppImage.zsync"
122+ " ./publish/Andromeda-x86_64.AppImage.zsync" ]
123+
124+ printfn " Finished publishing as AppImage"
125+
126+ // Clean up
127+ Internal.basicCommand " rm" [ " -rf" ; " AppDir" ]
128+ |> ignore
129+ }
130+
131+ result
132+
46133 let publish () =
47134 let publish = DotNet.publishSelfContained Config.publishPath Config.mainProject
48135
@@ -56,6 +143,9 @@ module Task =
56143 $" %s {Config.publishPath}/%s {Config.projectName}"
57144 $" %s {Config.publishPath}/%s {Config.artifactName}-linux-x64"
58145
146+ // Publish as AppImage
147+ publishAsAppImage ()
148+
59149 publish WindowsX64
60150
61151 Shell.mv
0 commit comments