Skip to content

Commit c6a304a

Browse files
committed
Fixed injection of version number into build. Updated build steps in DART3 README. Fixed help link in About page.
1 parent b001a5b commit c6a304a

6 files changed

Lines changed: 55 additions & 120 deletions

File tree

README_Dart3.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,20 @@ Then start DART 3 in debug mode in VS Code. From there, you can use DART through
195195

196196
Also, not that a number of tests call util.ProjectRoot(), which actually comes from Dart Runner's util code and points to Dart Runner's project root. If you have installed the Dart Runner dependency (which is listed in go.mod and **should**) be installed automatically by Go, then util.ProjectRoot() will point to the root directory of your local copy of Dart Runner.
197197

198-
## Releasing
198+
## Building for Release
199199

200-
Since we're in very early alpha phase, we don't have a formal release process yet. For now, we build the app as decribed under [Building](#Building) below and then manually copy it to our S3 public download bucket.
200+
1. Run the build script from the project's top-level directory: `./scripts/build_dart.sh`
201+
2. On Mac, run the signing script from the top-level directory: `./scripts/mac_sign_and_notarize.sh`
201202

202-
Updates to the release notes are also done manually.
203+
If you're code-signing on Mac, be sure you have a signing certificate and that you have created a local file called codesign.env that is based on [codesign_example.env](codesign_example.env). Note that that file includes instructions on how to set up Mac code signing. If you have trouble running the code signing process on Mac, run `./scripts/diagnose_cert_file.sh` for diagnostics.
204+
205+
Since we're in very early alpha phase, we don't have a formal release process yet. For now, we build the app as decribed above and then manually copy it to our S3 public download bucket. Updates to the release notes are also done manually.
206+
207+
For more on Wails build options, see https://wails.io/docs/guides/manual-builds/. Also note that the build system (and many other things) will be changing in Wails 3. See https://v3alpha.wails.io/whats-new/ for details.
208+
209+
At the moment, we need to build the Wails app on each platform and architecture separately. This means we build Windows amd64 on a Windows amd64 machine, Linux amd64 on a Linux amd64 box, etc. Once we have CI/CD set up in GitLab, we should be able to do cross-platform builds using a method like the one described here: https://wails.io/docs/guides/crossplatform-build/
210+
211+
We are currently not code-signing Windows builds because the process of obtaining a Windows signing certificate is prohibitive.
203212

204213
# Note on Wails
205214

@@ -266,14 +275,6 @@ assuming that Dart Runner is one level up the file tree from DART.
266275
Note that when you build a release, you should get rid of the `replace` and point to a
267276
specific build of Dart Runner.
268277

269-
## Building
270-
271-
To build a redistributable, production mode package, use `wails build -tags release`.
272-
273-
For more on build options, see https://wails.io/docs/guides/manual-builds/. Also note that the build system (and many other things) will be changing in Wails 3. See https://v3alpha.wails.io/whats-new/ for details.
274-
275-
At the moment, we need to build the Wails app on each platform and architecture separately. This means we build Windows amd64 on a Windows amd64 machine, Linux amd64 on a Linux amd64 box, etc. Once we have CI/CD set up in GitLab, we should be able to do cross-platform builds using a method like the one described here: https://wails.io/docs/guides/crossplatform-build/
276-
277278
## Testing
278279

279280
`./scripts/run tests`

dart/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import (
1313
"github.com/APTrust/dart/v3/server"
1414
)
1515

16-
// Version value is injected at build time.
16+
// Version value is injected at build time by ./scripts/build_dart.sh
17+
// using -ldflags "-X 'main.Version=$VERSION'"
1718
var Version string
1819

1920
func main() {

main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,17 @@ var assets embed.FS
1717
//go:embed build/appicon.png
1818
var icon []byte
1919

20+
// Version value is injected at build time by ./scripts/build_dart.sh
21+
// using -ldflags "-X 'main.Version=$VERSION'"
22+
var Version string
23+
2024
func main() {
2125
// Create an instance of the app structure
2226
app := NewApp()
2327

28+
// Set the version for the server
29+
server.SetVersion(Version)
30+
2431
go server.Run(9797, true)
2532

2633
// Create application with options

scripts/build_dart.sh

Lines changed: 20 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1,126 +1,41 @@
11
#!/usr/bin/env bash
2+
#
3+
# Build the DART Wails app and stamp it with the correct tag/release number.
4+
#
5+
# ----------------------------------------------------------------------------
26

3-
# Note: CGO_ENABLED is set to zero in this script because we are
4-
# not using any CGO dependencies. If CGO happens to be enabled in
5-
# the greater environment, we want to override it here to prevent
6-
# cross compilation failures. For details on why we do this, see
7-
# https://stackoverflow.com/questions/77293369/dynamic-linked-go-program-when-cross-compile
8-
9-
# While DART does use SQLite, we're using the pure Go driver from
10-
# https://pkg.go.dev/modernc.org/sqlite. So, no C interop required.
11-
7+
# Make sure script is called from the top-level directory
128
if [ -z $(ls scripts/build_dart.sh 2> /dev/null) ]; then
139
echo "Run this script from the project root directory"
1410
exit
1511
fi
1612

13+
# Gather variables from Git and the local OS so we can tag
14+
# this release. These vars show up in the Release number
15+
# displayed on DART's About screen. They also appear if the
16+
# user runs `DART -version`.
1717
COMMIT=$(git rev-parse --short HEAD)
18-
#TAG=$(git describe --tags 2> /dev/null)
18+
TAG=$(git describe --tags 2> /dev/null)
19+
if [ -z "$TAG" ]; then
20+
TAG="undefined"
21+
fi
1922
DATE=$(date +%Y-%m-%d)
2023
OS=$(uname -s)
2124
ARCH=$(uname -m)
22-
2325
BUILD_TAGS='-tags release'
2426

27+
28+
# Special handling for the special child of the OS world.
2529
# uname returns MINGW64_NT-10.0 on Windows 10 Cygwin
2630
# and MSYS_NT-10.0 on Windows 10 cmd.
2731
if [[ "$OS" == *"_NT-"* ]]; then
2832
OS="Windows $(uname -m)"
2933
BUILD_TAGS='-tags="release windows"'
3034
fi
3135

32-
#TAG="${TAG:=Alpha-01}"
33-
34-
VERSION="DART Alpha-01 for Darwin amd64 (Build $COMMIT $DATE)"
35-
echo "Building MacOS amd64 version in ./dist/mac-amd64/dart3"
36-
mkdir -p dist/mac-amd64
37-
#mkdir -p dist/mac-amd64/dart3.app/Contents/MacOS
38-
#mkdir -p dist/mac-amd64/dart3.app/Contents/Resources
39-
#cp server/build_support/macos/Info.plist dist/mac-amd64/dart3.app/Contents/Info.plist
40-
#cp server/build_support/macos/icons/icon.icns dist/mac-amd64/dart3.app/Contents/Resources/icon.icns
41-
GOOS=darwin \
42-
GOARCH=amd64 \
43-
CGO_ENABLED=0 \
44-
go build -o dist/mac-amd64/dart3 \
45-
-ldflags "-X 'main.Version=$VERSION'" \
46-
$BUILD_TAGS dart/main.go
47-
48-
VERSION="DART Alpha-01 for Darwin arm64 (Build $COMMIT $DATE)"
49-
echo "Building MacOS arm-64 (M-chip) version in ./dist/mac-arm64/dart3"
50-
mkdir -p dist/mac-arm64
51-
#mkdir -p dist/mac-arm64/dart3.app/Contents/MacOS
52-
#mkdir -p dist/mac-arm64/dart3.app/Contents/Resources
53-
#cp server/build_support/macos/Info.plist dist/mac-arm64/dart3.app/Contents/Info.plist
54-
#cp server/build_support/macos/icons/* dist/mac-arm64/dart3.app/Contents/Resources/
55-
GOOS=darwin \
56-
GOARCH=arm64 \
57-
CGO_ENABLED=0 \
58-
go build -o dist/mac-arm64/dart3 \
59-
-ldflags "-X 'main.Version=$VERSION'" \
60-
$BUILD_TAGS dart/main.go
61-
36+
# Create the full version string.
37+
VERSION="DART $TAG for $OS $ARCH (Build $COMMIT $DATE)"
6238

63-
# Note: When running `./scripts/run tests`, post_build_test.go uses its own special build command for Windows.
64-
VERSION="DART Alpha-01 for Windows amd64 (Build $COMMIT $DATE)"
65-
echo "Building Windows amd64 version in ./dist/windows-amd64/dart3"
66-
mkdir -p dist/windows-amd64
67-
GOOS=windows \
68-
GOARCH=amd64 \
69-
CGO_ENABLED=0 \
70-
go build -o dist/windows-amd64/dart3.exe \
71-
-ldflags "-X 'main.Version=$VERSION' -H=windowsgui" \
72-
$BUILD_TAGS dart/main.go
73-
74-
VERSION="DART Alpha-01 for Windows arm64 (Build $COMMIT $DATE)"
75-
echo "Building Windows arm64 version in ./dist/windows-arm64/dart3"
76-
mkdir -p dist/windows-arm64
77-
GOOS=windows \
78-
GOARCH=arm64 \
79-
CGO_ENABLED=0 \
80-
go build -o dist/windows-arm64/dart3.exe \
81-
-ldflags "-X 'main.Version=$VERSION' -H=windowsgui" \
82-
$BUILD_TAGS dart/main.go
83-
84-
85-
VERSION="DART Alpha-01 for Linux amd64 (Build $COMMIT $DATE)"
86-
echo "Building Linux amd64 version in ./dist/linux-amd64/dart3"
87-
mkdir -p dist/linux-amd64
88-
GOOS=linux \
89-
GOARCH=amd64 \
90-
CGO_ENABLED=0 \
91-
go build -o dist/linux-amd64/dart3 \
92-
-ldflags "-X 'main.Version=$VERSION'" \
93-
$BUILD_TAGS dart/main.go
94-
95-
96-
VERSION="DART Alpha-01 for Linux arm64 (Build $COMMIT $DATE)"
97-
echo "Building Linux arm64 version in ./dist/linux-arm64/dart3"
98-
mkdir -p dist/linux-arm64
99-
GOOS=linux \
100-
GOARCH=arm64 \
101-
CGO_ENABLED=0 \
102-
go build -o dist/linux-arm64/dart3 \
103-
-ldflags "-X 'main.Version=$VERSION'" \
104-
$BUILD_TAGS dart/main.go
105-
106-
107-
echo "Version info from latest build:"
108-
if [[ "$OS" == "Darwin" ]]; then
109-
if [[ "$ARCH" == "x86_64" ]]; then
110-
dist/mac-amd64/dart3 --version
111-
else
112-
dist/mac-arm64/dart3 --version
113-
fi
114-
elif [[ "$OS" == "Linux" ]]; then
115-
if [[ "$ARCH" == "x86_64" ]]; then
116-
dist/linux-amd64/dart3 --version
117-
else
118-
dist/linux-arm64/dart3 --version
119-
fi
120-
else
121-
if [[ "$ARCH" == "x86_64" ]]; then
122-
dist/windows-amd64/dart3.exe --version
123-
else
124-
dist/windows-arm64/dart3.exe --version
125-
fi
126-
fi
39+
# Now run wails build with the proper tags and version
40+
# number.
41+
wails build $BUILD_TAGS -ldflags "-X 'main.Version=$VERSION'"

server/controllers/about_controller.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package controllers
33
import (
44
"fmt"
55
"net/http"
6+
"os"
67
"os/exec"
78
"runtime"
89
"strconv"
@@ -25,9 +26,19 @@ func AboutShow(c *gin.Context) {
2526
tailCommand = fmt.Sprintf("powershell -command Get-Content %s -Wait", logFile)
2627
}
2728

29+
appPath, err := os.Executable()
30+
if err != nil {
31+
core.Dart.Log.Warningf("Can't get app path: %v", err)
32+
appPath = "Unknown"
33+
}
34+
version := constants.Version
35+
if version == "" {
36+
version = "undefined"
37+
}
38+
2839
templateData := gin.H{
29-
"version": constants.Version,
30-
"appPath": "App path goes here",
40+
"version": version,
41+
"appPath": appPath,
3142
"userDataPath": core.Dart.Paths.DataDir,
3243
"logFilePath": logFile,
3344
"tailCommand": tailCommand,

server/views/about/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
sftp server or S3-compliant API.
1010
</p>
1111
<p>
12-
For help, see the <a href="#" onclick="openExternalUrl('https://aptrust.github.io/dart-docs/users/getting_started/')">DART User Guide.</a>
12+
For help, see the <a href="#" onclick="openExternalUrl('https://aptrust.github.io/dart-docs/dart3/users/getting_started/')">DART User Guide.</a>
1313
</p>
1414
</div>
1515

0 commit comments

Comments
 (0)