-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.go
131 lines (111 loc) · 6.41 KB
/
build.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package project
import (
"fmt"
"projectforge.dev/projectforge/app/util"
)
type Build struct {
Private bool `json:"private,omitempty"`
Changelog bool `json:"changelog,omitempty"`
TestsFail bool `json:"testsFail,omitempty"`
NoScript bool `json:"noScript,omitempty"`
Simple bool `json:"simple,omitempty"`
Desktop bool `json:"desktop,omitempty"`
Notarize bool `json:"notarize,omitempty"`
Signing bool `json:"signing,omitempty"`
SafeMode bool `json:"safeMode,omitempty"`
Android bool `json:"android,omitempty"`
IOS bool `json:"iOS,omitempty"`
WASM bool `json:"wasm,omitempty"`
X86 bool `json:"x86,omitempty"`
WindowsARM bool `json:"windowsARM,omitempty"`
LinuxARM bool `json:"linuxARM,omitempty"`
LinuxMIPS bool `json:"linuxMIPS,omitempty"`
LinuxOdd bool `json:"linuxOdd,omitempty"`
AIX bool `json:"aix,omitempty"`
Dragonfly bool `json:"dragonfly,omitempty"`
Illumos bool `json:"illumos,omitempty"`
FreeBSD bool `json:"freeBSD,omitempty"`
NetBSD bool `json:"netBSD,omitempty"`
OpenBSD bool `json:"openBSD,omitempty"`
Plan9 bool `json:"plan9,omitempty"`
Solaris bool `json:"solaris,omitempty"`
Homebrew bool `json:"homebrew,omitempty"`
NFPMS bool `json:"nfpms,omitempty"`
BOM bool `json:"bom,omitempty"`
Snapcraft bool `json:"snapcraft,omitempty"`
}
func (b *Build) Mobile() bool {
return b.IOS || b.Android
}
func (b *Build) HasArm() bool {
return b.WindowsARM || b.LinuxARM || b.FreeBSD || b.OpenBSD
}
func (b *Build) Empty() bool {
return !(b.Private || b.Changelog || b.TestsFail || b.NoScript || b.Simple ||
b.Desktop || b.Notarize || b.Signing || b.SafeMode ||
b.Android || b.IOS || b.WASM || b.X86 || b.WindowsARM ||
b.LinuxARM || b.LinuxMIPS || b.LinuxOdd || b.AIX || b.Dragonfly || b.Illumos ||
b.FreeBSD || b.NetBSD || b.OpenBSD || b.Plan9 || b.Solaris ||
b.Homebrew || b.NFPMS || b.BOM || b.Snapcraft)
}
func (b *Build) ToMap() map[string]bool {
return map[string]bool{
"private": b.Private, "changelog": b.Changelog, "testsFail": b.TestsFail, "noScript": b.NoScript,
"desktop": b.Desktop, "notarize": b.Notarize, "signing": b.Signing, "safeMode": b.SafeMode,
"android": b.Android, "ios": b.IOS, "wasm": b.WASM, "x86": b.X86, "windows-arm": b.WindowsARM,
"linux-arm": b.LinuxARM, "linux-mips": b.LinuxMIPS, "linux-odd": b.LinuxOdd,
"aix": b.AIX, "dragonfly": b.Dragonfly, "illumos": b.Illumos, "freebsd": b.FreeBSD,
"netbsd": b.NetBSD, "openbsd": b.OpenBSD, "plan9": b.Plan9, "solaris": b.Solaris,
"homebrew": b.Homebrew, "nfpms": b.NFPMS, "bom": b.BOM, "snapcraft": b.Snapcraft,
}
}
func BuildFromMap(frm util.ValueMap) *Build {
x := func(k string) bool {
v := fmt.Sprint(frm["build-"+k])
return v == util.BoolTrue
}
return &Build{
Private: x("private"), Changelog: x("changelog"), TestsFail: x("testsFail"), NoScript: x("noScript"),
Desktop: x("desktop"), Notarize: x("notarize"), Signing: x("signing"), SafeMode: x("safeMode"),
Android: x("android"), IOS: x("ios"), WASM: x("wasm"), X86: x("x86"), WindowsARM: x("windows-arm"),
LinuxARM: x("linux-arm"), LinuxMIPS: x("linux-mips"), LinuxOdd: x("linux-odd"),
AIX: x("aix"), Dragonfly: x("dragonfly"), Illumos: x("illumos"), FreeBSD: x("freebsd"),
NetBSD: x("netbsd"), OpenBSD: x("openbsd"), Plan9: x("plan9"), Solaris: x("solaris"),
Homebrew: x("homebrew"), NFPMS: x("nfpms"), BOM: x("bom"), Snapcraft: x("snapcraft"),
}
}
type BuildOption struct {
Key string
Title string
Description string
}
var AllBuildOptions = []*BuildOption{
{Key: "private", Title: "Private", Description: "This project is not public (affects publishing)"},
{Key: "changelog", Title: "Changelog", Description: "Generate changelogs from GitHub commits"},
{Key: "testsFail", Title: "Tests Fail", Description: "If set, Docker build will fail unless all tests pass"},
{Key: "noScript", Title: "No Script", Description: "Prevents JavaScript from being emitted or utilized"},
{Key: "desktop", Title: "Desktop", Description: "Webview-based applications for the three major operating systems (requires \"desktop\" module)"},
{Key: "notarize", Title: "Notarize", Description: "Sends build artifacts to Apple for notarization (requires \"notarize\" module)"},
{Key: "signing", Title: "Signing", Description: "Signs the checksums using gpg"},
{Key: "safeMode", Title: "Safe Mode", Description: "Limits dangerous activities that can be performed on the server"},
{Key: "android", Title: "Android", Description: "Builds the application as an Android library and webview-based APK (requires \"android\" module)"},
{Key: "ios", Title: "iOS", Description: "Builds the application as an iOS framework and webview-based app (requires \"ios\" module)"},
{Key: "wasm", Title: "WASM", Description: "Builds the application for WebAssembly (requires the \"wasm\" module)"},
{Key: "x86", Title: "32-bit x86", Description: "Builds 32-bit versions of the products"},
{Key: "windows-arm", Title: "Windows ARM", Description: "Builds the application for Windows on ARM and ARM64 architectures"},
{Key: "linux-arm", Title: "Linux ARM", Description: "Builds the application for Linux on ARM and ARM64 architectures"},
{Key: "linux-mips", Title: "Linux MIPS", Description: "Builds the application for Linux on MIPS architectures"},
{Key: "linux-odd", Title: "Linux Odd", Description: "Builds the application for Linux using ppc64, ppc64le, riscv64, and s390x"},
{Key: "aix", Title: "AIX", Description: "Builds the application for AIX"},
{Key: "dragonfly", Title: "Dragonfly", Description: "Builds the application for Dragonfly"},
{Key: "illumos", Title: "Illumos", Description: "Builds the application for Illumos"},
{Key: "freebsd", Title: "FreeBSD", Description: "Builds the application for FreeBSD"},
{Key: "netbsd", Title: "NetBSD", Description: "Builds the application for NetBSD"},
{Key: "openbsd", Title: "OpenBSD", Description: "Builds the application for OpenBSD"},
{Key: "plan9", Title: "Plan 9", Description: "Builds the application for Plan 9"},
{Key: "solaris", Title: "Solaris", Description: "Builds the application for Solaris"},
{Key: "homebrew", Title: "Homebrew", Description: "Publishes the builds to Homebrew"},
{Key: "nfpms", Title: "NFPMS", Description: "Builds the application as RPMs, DEBs, and APKs for various Linux flavors"},
{Key: "bom", Title: "BOM", Description: "Creates a bill of materials for each binary produced by the build"},
{Key: "snapcraft", Title: "Snapcraft", Description: "Publishes the application as a Ubuntu Snap "},
}