diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index fba5af706..6c2a93e39 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -534,3 +534,48 @@ jobs: run: | sudo apt update ./scripts/snap_release.sh + + snap_pkg_beta: + + needs: + - conventions + + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v1 + - name: Install snap tools + run: | + sudo apt update + ./scripts/install_snapcraft.sh + + # hack to disable msbuild detection + # NOTE: you might think an easier way to do this would be use container:\nimage: ubuntu22.04 and then not install msbuild, + # but that doesn't work because we get the following error when trying to install snapcraft via `snap install --classic`: + # > error: cannot communicate with server: Post "http://localhost/v2/snaps/snapcraft": dial unix /run/snapd.socket: connect: no such file or directory + - name: HACK to emulate msbuild uninstall + run: sudo rm `which msbuild` + + - name: Generate snap package + run: | + # retry 3 times because of flakey nuget; TODO: remove retry when we migrate to .NET6 (removing LEGACY_FRAMEWORK support) + ./scripts/snap_build_beta.sh || ./scripts/snap_build_beta.sh || ./scripts/snap_build_beta.sh || ./scripts/snap_build_beta.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: geewallet --version + + - uses: actions/upload-artifact@v3 + name: Upload snap package as artifact + with: + name: snap + path: ./*.snap + + - name: Upload snap package to Snap Store + env: + SNAPCRAFT_LOGIN: ${{ secrets.SNAPCRAFT_LOGIN }} + run: | + sudo apt update + ./scripts/snap_release.sh beta diff --git a/scripts/bump.fsx b/scripts/bump.fsx index e0069434c..a858815ca 100755 --- a/scripts/bump.fsx +++ b/scripts/bump.fsx @@ -4,7 +4,7 @@ open System open System.IO #if !LEGACY_FRAMEWORK -#r "nuget: Fsdk, Version=0.6.0--date20230812-0646.git-2268d50" +#r "nuget: Fsdk, Version=0.6.0--date20231031-0834.git-2737eea" #else #r "System.Configuration" open System.Configuration diff --git a/scripts/configure.fsx b/scripts/configure.fsx index 28c0ebcec..2837b571d 100644 --- a/scripts/configure.fsx +++ b/scripts/configure.fsx @@ -4,7 +4,7 @@ open System open System.IO #if !LEGACY_FRAMEWORK -#r "nuget: Fsdk, Version=0.6.0--date20230812-0646.git-2268d50" +#r "nuget: Fsdk, Version=0.6.0--date20231031-0834.git-2737eea" #else #r "System.Configuration" open System.Configuration @@ -187,6 +187,18 @@ let fsxRunner = fsxRunnerBinText buildConfigFile.Name +let addToDefinedConstants (constant: string) (configMap: Map) = + let configKey = "DefineConstants" + + match configMap.TryFind configKey with + | None -> + configMap + |> Map.add configKey constant + | Some previousConstants -> + configMap + |> Map.add configKey (sprintf "%s;%s" previousConstants constant) + + let configFileToBeWritten = let initialConfigFile = Map.empty.Add("Prefix", prefix.FullName) @@ -195,11 +207,21 @@ let configFileToBeWritten = | Some theTool -> initialConfigFile.Add("LegacyBuildTool", theTool) | None -> initialConfigFile - let finalConfigFile = + let configFileStageThree = match buildTool with | Some theTool -> configFileStageTwo.Add("BuildTool", theTool) | None -> configFileStageTwo + let finalConfigFile = + let nativeSegwitEnabled = + Misc.FsxOnlyArguments() + |> List.contains "--native-segwit" + if nativeSegwitEnabled then + configFileStageThree + |> addToDefinedConstants "NATIVE_SEGWIT" + else + configFileStageThree + finalConfigFile let lines = diff --git a/scripts/find.fsx b/scripts/find.fsx index f39abb2a6..16a16b4ec 100755 --- a/scripts/find.fsx +++ b/scripts/find.fsx @@ -5,7 +5,7 @@ open System.IO open System.Linq #if !LEGACY_FRAMEWORK -#r "nuget: Fsdk, Version=0.6.0--date20230812-0646.git-2268d50" +#r "nuget: Fsdk, Version=0.6.0--date20231031-0834.git-2737eea" #else #r "System.Configuration" #load "fsx/Fsdk/Misc.fs" diff --git a/scripts/fsx b/scripts/fsx index 5488853b1..2737eea87 160000 --- a/scripts/fsx +++ b/scripts/fsx @@ -1 +1 @@ -Subproject commit 5488853b17fedb44707e8459480297b618cffad0 +Subproject commit 2737eea87f6bd4becda5c172c208314af044184a diff --git a/scripts/make.fsx b/scripts/make.fsx index 71c9e55a1..dedf4d956 100644 --- a/scripts/make.fsx +++ b/scripts/make.fsx @@ -136,7 +136,7 @@ let GetOrExplain key map = let prefix = buildConfigContents |> GetOrExplain "Prefix" let libPrefixDir = DirectoryInfo (Path.Combine (prefix, "lib", UNIX_NAME)) let binPrefixDir = DirectoryInfo (Path.Combine (prefix, "bin")) - + let wrapperScript = """#!/usr/bin/env bash set -eo pipefail diff --git a/scripts/sanitycheck.fsx b/scripts/sanitycheck.fsx index dc990fff8..b26dc3c42 100755 --- a/scripts/sanitycheck.fsx +++ b/scripts/sanitycheck.fsx @@ -14,7 +14,7 @@ open System.Xml.Linq open System.Xml.XPath #if !LEGACY_FRAMEWORK -#r "nuget: Fsdk, Version=0.6.0--date20230812-0646.git-2268d50" +#r "nuget: Fsdk, Version=0.6.0--date20231031-0834.git-2737eea" #else #r "System.Configuration" open System.Configuration diff --git a/scripts/snap_build_beta.sh b/scripts/snap_build_beta.sh new file mode 100755 index 000000000..ce8b585b6 --- /dev/null +++ b/scripts/snap_build_beta.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +set -euxo pipefail + +# this is the equivalent of using the 'build-packages' (not stage-packages) section in snapcraft +# but as we're not using the 'make' plugin, we need to this manually now +DEBIAN_FRONTEND=noninteractive sudo apt install -y fsharp build-essential pkg-config cli-common-dev mono-devel libgtk2.0-cil-dev dotnet6 + +# just in case this is a retry-run, we want to clean artifacts from previous try +rm -rf ./staging + +./configure.sh --native-segwit --prefix=./staging +make +make install + +snapcraft --destructive-mode diff --git a/scripts/snap_release.fsx b/scripts/snap_release.fsx index 027d1af0e..5c2e10a49 100755 --- a/scripts/snap_release.fsx +++ b/scripts/snap_release.fsx @@ -15,7 +15,7 @@ open System.Xml.Linq open System.Xml.XPath #if !LEGACY_FRAMEWORK -#r "nuget: Fsdk, Version=0.6.0--date20230812-0646.git-2268d50" +#r "nuget: Fsdk, Version=0.6.0--date20231031-0834.git-2737eea" #else #r "System.Configuration" open System.Configuration @@ -150,10 +150,19 @@ Console.WriteLine "Login successfull. Upload starting..." // the 'stable' and 'candidate' channels require 'stable' grade in the yaml let snapPush = + let channel = + match Misc.FsxOnlyArguments() with + | [ channel ] -> + channel + | [] -> + "stable" + | _ -> + failwith "Invalid arguments" + Process.Execute( { Command = "snapcraft" - Arguments = sprintf "upload %s --release=stable" snapFile.FullName + Arguments = sprintf "upload %s --release=%s" snapFile.FullName channel }, Echo.All ) diff --git a/src/GWallet.Backend/Config.fs b/src/GWallet.Backend/Config.fs index 50668dcc5..17c213bd9 100644 --- a/src/GWallet.Backend/Config.fs +++ b/src/GWallet.Backend/Config.fs @@ -34,7 +34,12 @@ module Config = // balances, so you might find discrepancies (e.g. the donut-chart-view) let internal NoNetworkBalanceForDebuggingPurposes = false - let internal UseNativeSegwit = false + let internal UseNativeSegwit = +#if NATIVE_SEGWIT + true +#else + false +#endif let IsWindowsPlatform() = RuntimeInformation.IsOSPlatform OSPlatform.Windows