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

scripts,GitHubCI,Backend: add .NET6 snap #297

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
scripts,GitHubCI,Backend: add .NET6 snap
Use .NET6 to build snap package. Publish Frontend.Console as
single executable in in snap_build script.

Modified launch script to point to gwallet executable generated
with new settings.

Set InvariantGlobalization to true in Backend and
Frontend.Console projects to fix error when launching
gwallet installed by snap. Error in question was:
```
Process terminated. Couldn't find a valid ICU package installed
on the system. Please install libicu using your package manager
and try again. Alternatively you can set the configuration flag
System.Globalization.Invariant to true if you want to run with
no globalization support.
```

Set correct configPath when GWallet is in a snap package.

Build mono snap package alongside .net6. Also upload mono snap
package as artifact and test it. It is needed because the
frontend branch can't switch yet to dotnet-based snap.

When building snap package with .NET6, only include single-file
executable in package.

Added "publish" command to make.fsx and Makefile.
webwarrior-ws committed Nov 7, 2024
commit 9e6b82b9bfc4e9740cb5849ff3dd13c45152f8c3
34 changes: 32 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -516,7 +516,7 @@ jobs:
if: github.event_name == 'pull_request'
run: ./conventions/commitlint.sh --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose

snap_pkg:
snap_pkg_mono:

needs:
- conventions
@@ -551,7 +551,37 @@ jobs:
- uses: actions/upload-artifact@v3
name: Upload snap package as artifact
with:
name: snap
name: snap-mono
path: ./*.snap

snap_pkg_dotnet:

needs:
- conventions

runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v1
- name: Install snap tools
run: |
sudo apt update
./scripts/install_snapcraft.sh
- name: Generate snap package
run: |
./scripts/snap_build.sh
- name: Install snap
# dangerous because it's a local snap (not one from the SnapStore)
run: sudo snap install --dangerous *.snap

- name: Test snap
run: gwallet --version

- uses: actions/upload-artifact@v3
name: Upload snap package as artifact
with:
name: snap-dotnet
path: ./*.snap

- name: Upload snap package to Snap Store
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -9,6 +9,9 @@ check:

release:
@./scripts/make.sh release

publish:
@./scripts/make.sh publish

zip:
@./scripts/make.sh zip
66 changes: 65 additions & 1 deletion scripts/make.fsx
Original file line number Diff line number Diff line change
@@ -4,6 +4,8 @@ open System
open System.IO
open System.Linq
open System.Diagnostics
open System.Runtime.InteropServices


#if !LEGACY_FRAMEWORK
#r "nuget: Fsdk, Version=0.6.0--date20230818-1152.git-83d671b"
@@ -117,6 +119,17 @@ let prefix = buildConfigContents |> GetOrExplain "Prefix"
let libPrefixDir = DirectoryInfo (Path.Combine (prefix, "lib", UNIX_NAME))
let binPrefixDir = DirectoryInfo (Path.Combine (prefix, "bin"))


let GetRuntimeId () =
let osName =
match Misc.GuessPlatform() with
| Misc.Platform.Linux -> "linux"
| Misc.Platform.Windows -> "win"
| Misc.Platform.Mac -> "osx"
let archName = RuntimeInformation.ProcessArchitecture.ToString().ToLower()
sprintf "%s-%s" osName archName

#if LEGACY_FRAMEWORK
let wrapperScript = """#!/usr/bin/env bash
set -eo pipefail
@@ -133,6 +146,19 @@ DIR_OF_THIS_SCRIPT=$(dirname "$(realpath "$0")")
FRONTEND_PATH="$DIR_OF_THIS_SCRIPT/../lib/$UNIX_NAME/$GWALLET_PROJECT.exe"
exec mono "$FRONTEND_PATH" "$@"
"""
#else
let wrapperScript = """#!/usr/bin/env bash
set -eo pipefail
DIR_OF_THIS_SCRIPT=$(dirname "$(realpath "$0")")
FRONTEND_PATH="$DIR_OF_THIS_SCRIPT/../lib/$UNIX_NAME/$GWALLET_PROJECT"
arch=$(uname -i)
if [ "$arch" != 'x86_64' ]; then
echo "$arch not supported (only x86_64 is supported for now), please file a bug"
exit 1
fi
exec "$FRONTEND_PATH" "$@"
"""
#endif

let NugetRestore (projectOrSolution: FileInfo) =
let nugetArgs =
@@ -581,6 +607,33 @@ match maybeTarget with
| _ ->
()
#endif
| Some "publish" ->
#if LEGACY_FRAMEWORK
failwith "Legacy frameworks don't support publish command"
#else
let buildConfig = BinaryConfig.Release
let frontend,_ = JustBuild buildConfig None

let projectFile =
Path.Combine (
FsxHelper.RootDir.FullName,
"src",
frontend.GetProjectName(),
frontend.GetProjectName() + ".fsproj")
|> FileInfo
let runtimeId = GetRuntimeId()
let publishCommand =
{
Command = "dotnet"
Arguments =
sprintf
"publish --configuration Release -property:PublishSingleFile=true --self-contained true --runtime %s %s"
runtimeId
projectFile.FullName
}
Process.Execute(publishCommand, Echo.All).UnwrapDefault()
|> ignore<string>
#endif

| Some("install") ->
let buildConfig = BinaryConfig.Release
@@ -608,7 +661,18 @@ match maybeTarget with

Console.WriteLine "Installing..."
Console.WriteLine ()
Misc.CopyDirectoryRecursively (mainBinariesDir buildConfig, libDestDir, [])

let publishDir =
Path.Combine ((mainBinariesDir buildConfig).FullName, "net6.0", GetRuntimeId(), "publish")
|> DirectoryInfo
if publishDir.Exists then
// single-file app
let executable = Path.Combine(publishDir.FullName, frontend.GetProjectName()) |> FileInfo
if not libDestDir.Exists then
libDestDir.Create()
executable.CopyTo(Path.Combine(libDestDir.FullName, frontend.GetProjectName()), true) |> ignore
else
Misc.CopyDirectoryRecursively (mainBinariesDir buildConfig, libDestDir, List.Empty)

let finalLauncherScriptInDestDir = Path.Combine(binDestDir.FullName, launcherScriptFile.Name) |> FileInfo
if not (Directory.Exists(finalLauncherScriptInDestDir.Directory.FullName)) then
4 changes: 4 additions & 0 deletions scripts/snap_build.sh
Original file line number Diff line number Diff line change
@@ -10,6 +10,10 @@ rm -rf ./staging

./configure.sh --prefix=./staging "$@"
make
if [ `which dotnet` ]
then
make publish
fi
make install

snapcraft --destructive-mode
22 changes: 13 additions & 9 deletions src/GWallet.Backend/Config.fs
Original file line number Diff line number Diff line change
@@ -75,15 +75,19 @@ module Config =

let internal GetConfigDirForThisProgram() =
let configPath =
(* NOTE: we used to support UWP via the Xamarin.Essentials code below, but MAUI is a higher priority than resurrecting UWP now:
if (not isWindows) || Xamarin.Essentials.DeviceInfo.Platform <> Xamarin.Essentials.DevicePlatform.UWP then
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
else //UWP
Xamarin.Essentials.FileSystem.AppDataDirectory
*)
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)

// TODO: rename to "geewallet", following a similar approach as DAI->SAI rename
match Environment.GetEnvironmentVariable "SNAP" with
| snapVar when not (String.IsNullOrEmpty snapVar) ->
match Environment.GetEnvironmentVariable "HOME" with
| homeVar when not (String.IsNullOrEmpty homeVar) ->
homeVar + snapVar + ".config"
| _ -> failwith "$HOME environment variable is absent or empty"
(* NOTE: we used to support UWP via the Xamarin.Essentials code below, but MAUI is a higher priority than resurrecting UWP now:
if (not isWindows) || Xamarin.Essentials.DeviceInfo.Platform <> Xamarin.Essentials.DevicePlatform.UWP then
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
else //UWP
Xamarin.Essentials.FileSystem.AppDataDirectory
*)
| _ -> Environment.GetFolderPath Environment.SpecialFolder.ApplicationData
let configDir = DirectoryInfo(Path.Combine(configPath, "gwallet"))
if not configDir.Exists then
configDir.Create()
1 change: 1 addition & 0 deletions src/GWallet.Backend/GWallet.Backend.fsproj
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<InvariantGlobalization>true</InvariantGlobalization>
</PropertyGroup>

<PropertyGroup>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<InvariantGlobalization>true</InvariantGlobalization>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\GWallet.Backend\Properties\CommonAssemblyInfo.fs">

Unchanged files with check annotations Beta

module Main =
[<EntryPoint>]
let main args =
UIApplication.Main(args, null, "AppDelegate")

Check warning on line 24 in src/GWallet.Frontend.XF.iOS/AppDelegate.fs

GitHub Actions / macOS--dotnet6-and-mono

This construct is deprecated. Use the overload with 'Type' instead of 'String' parameters for type safety.

Check warning on line 24 in src/GWallet.Frontend.XF.iOS/AppDelegate.fs

GitHub Actions / macOS--dotnet6-and-mono

This construct is deprecated. Use the overload with 'Type' instead of 'String' parameters for type safety.

Check warning on line 24 in src/GWallet.Frontend.XF.iOS/AppDelegate.fs

GitHub Actions / macOS--dotnet6-and-mono

This construct is deprecated. Use the overload with 'Type' instead of 'String' parameters for type safety.
0