Skip to content

Commit 05ea761

Browse files
aaraniMersho
andcommitted
CI: create snap pkg beta for native segwit
This commit aims to create beta snap packages to allow testing experimental features like native segwit. This commit also updates Fsdk inside our scripts because the `GatherOrGetDefaultPrefix` function in the previous version did not allow additional arguments beside --prefix. Co-authored-by: Mehrshad <[email protected]>
1 parent 02b80aa commit 05ea761

File tree

9 files changed

+90
-11
lines changed

9 files changed

+90
-11
lines changed

.github/workflows/CI.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,3 +534,48 @@ jobs:
534534
run: |
535535
sudo apt update
536536
./scripts/snap_release.sh
537+
538+
snap_pkg_beta:
539+
540+
needs:
541+
- conventions
542+
543+
runs-on: ubuntu-22.04
544+
steps:
545+
- uses: actions/checkout@v1
546+
- name: Install snap tools
547+
run: |
548+
sudo apt update
549+
./scripts/install_snapcraft.sh
550+
551+
# hack to disable msbuild detection
552+
# NOTE: you might think an easier way to do this would be use container:\nimage: ubuntu22.04 and then not install msbuild,
553+
# but that doesn't work because we get the following error when trying to install snapcraft via `snap install --classic`:
554+
# > error: cannot communicate with server: Post "http://localhost/v2/snaps/snapcraft": dial unix /run/snapd.socket: connect: no such file or directory
555+
- name: HACK to emulate msbuild uninstall
556+
run: sudo rm `which msbuild`
557+
558+
- name: Generate snap package
559+
run: |
560+
# retry 3 times because of flakey nuget; TODO: remove retry when we migrate to .NET6 (removing LEGACY_FRAMEWORK support)
561+
./scripts/snap_build.sh --native-segwit || ./scripts/snap_build.sh --native-segwit || ./scripts/snap_build.sh --native-segwit || ./scripts/snap_build.sh --native-segwit
562+
563+
- name: Install snap
564+
# dangerous because it's a local snap (not one from the SnapStore)
565+
run: sudo snap install --dangerous *.snap
566+
567+
- name: Test snap
568+
run: geewallet --version
569+
570+
- uses: actions/upload-artifact@v3
571+
name: Upload snap package as artifact
572+
with:
573+
name: snap
574+
path: ./*.snap
575+
576+
- name: Upload snap package to Snap Store
577+
env:
578+
SNAPCRAFT_LOGIN: ${{ secrets.SNAPCRAFT_LOGIN }}
579+
run: |
580+
sudo apt update
581+
./scripts/snap_release.sh beta

scripts/bump.fsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ open System
44
open System.IO
55

66
#if !LEGACY_FRAMEWORK
7-
#r "nuget: Fsdk, Version=0.6.0--date20230812-0646.git-2268d50"
7+
#r "nuget: Fsdk, Version=0.6.0--date20231031-0834.git-2737eea"
88
#else
99
#r "System.Configuration"
1010
open System.Configuration

scripts/configure.fsx

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ open System
44
open System.IO
55

66
#if !LEGACY_FRAMEWORK
7-
#r "nuget: Fsdk, Version=0.6.0--date20230812-0646.git-2268d50"
7+
#r "nuget: Fsdk, Version=0.6.0--date20231031-0834.git-2737eea"
88
#else
99
#r "System.Configuration"
1010
open System.Configuration
@@ -187,6 +187,18 @@ let fsxRunner =
187187
fsxRunnerBinText
188188
buildConfigFile.Name
189189

190+
let AddToDefinedConstants (constant: string) (configMap: Map<string, string>) =
191+
let configKey = "DefineConstants"
192+
193+
match configMap.TryFind configKey with
194+
| None ->
195+
configMap
196+
|> Map.add configKey constant
197+
| Some previousConstants ->
198+
configMap
199+
|> Map.add configKey (sprintf "%s;%s" previousConstants constant)
200+
201+
190202
let configFileToBeWritten =
191203
let initialConfigFile = Map.empty.Add("Prefix", prefix.FullName)
192204

@@ -195,11 +207,21 @@ let configFileToBeWritten =
195207
| Some theTool -> initialConfigFile.Add("LegacyBuildTool", theTool)
196208
| None -> initialConfigFile
197209

198-
let finalConfigFile =
210+
let configFileStageThree =
199211
match buildTool with
200212
| Some theTool -> configFileStageTwo.Add("BuildTool", theTool)
201213
| None -> configFileStageTwo
202214

215+
let finalConfigFile =
216+
let nativeSegwitEnabled =
217+
Misc.FsxOnlyArguments()
218+
|> List.contains "--native-segwit"
219+
if nativeSegwitEnabled then
220+
configFileStageThree
221+
|> AddToDefinedConstants "NATIVE_SEGWIT"
222+
else
223+
configFileStageThree
224+
203225
finalConfigFile
204226

205227
let lines =

scripts/find.fsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ open System.IO
55
open System.Linq
66

77
#if !LEGACY_FRAMEWORK
8-
#r "nuget: Fsdk, Version=0.6.0--date20230812-0646.git-2268d50"
8+
#r "nuget: Fsdk, Version=0.6.0--date20231031-0834.git-2737eea"
99
#else
1010
#r "System.Configuration"
1111
#load "fsx/Fsdk/Misc.fs"

scripts/sanitycheck.fsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ open System.Xml.Linq
1414
open System.Xml.XPath
1515

1616
#if !LEGACY_FRAMEWORK
17-
#r "nuget: Fsdk, Version=0.6.0--date20230812-0646.git-2268d50"
17+
#r "nuget: Fsdk, Version=0.6.0--date20231031-0834.git-2737eea"
1818
#else
1919
#r "System.Configuration"
2020
open System.Configuration

scripts/snap_build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ DEBIAN_FRONTEND=noninteractive sudo apt install -y fsharp build-essential pkg-co
88
# just in case this is a retry-run, we want to clean artifacts from previous try
99
rm -rf ./staging
1010

11-
./configure.sh --prefix=./staging
11+
./configure.sh --prefix=./staging "$@"
1212
make
1313
make install
1414

scripts/snap_release.fsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ open System.Xml.Linq
1515
open System.Xml.XPath
1616

1717
#if !LEGACY_FRAMEWORK
18-
#r "nuget: Fsdk, Version=0.6.0--date20230812-0646.git-2268d50"
18+
#r "nuget: Fsdk, Version=0.6.0--date20231031-0834.git-2737eea"
1919
#else
2020
#r "System.Configuration"
2121
open System.Configuration
@@ -149,8 +149,15 @@ Process.Execute({ Command = "snapcraft"; Arguments = "login --with snapcraft.log
149149
Console.WriteLine "Login successfull. Upload starting..."
150150

151151
let snapPush =
152-
// the 'stable' and 'candidate' channels require 'stable' grade in the yaml
153-
let channel = "stable"
152+
let channel =
153+
match Misc.FsxOnlyArguments() with
154+
| [ channel ] ->
155+
channel
156+
| [] ->
157+
// the 'stable' and 'candidate' channels require 'stable' grade in the yaml
158+
"stable"
159+
| _ ->
160+
failwith "Invalid arguments"
154161

155162
Process.Execute(
156163
{

src/GWallet.Backend/Config.fs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,12 @@ module Config =
3434
// balances, so you might find discrepancies (e.g. the donut-chart-view)
3535
let internal NoNetworkBalanceForDebuggingPurposes = false
3636

37-
let internal UseNativeSegwit = false
37+
let internal UseNativeSegwit =
38+
#if NATIVE_SEGWIT
39+
true
40+
#else
41+
false
42+
#endif
3843

3944
let IsWindowsPlatform() =
4045
RuntimeInformation.IsOSPlatform OSPlatform.Windows

0 commit comments

Comments
 (0)