Skip to content

Commit ddc16c8

Browse files
authored
APP-7356 include windows in RDK stable release (#4750)
1 parent be31cfa commit ddc16c8

File tree

3 files changed

+56
-16
lines changed

3 files changed

+56
-16
lines changed

.github/workflows/staticbuild.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,15 @@ jobs:
4141
- arch: ubuntu-latest
4242
image: ghcr.io/viamrobotics/antique2:amd64-cache
4343
platform: linux/amd64
44+
target: static-release
4445
- arch: ubuntu-small-arm
4546
image: ghcr.io/viamrobotics/antique2:arm64-cache
4647
platform: linux/arm64
48+
target: static-release
49+
- arch: ubuntu-latest
50+
image: ghcr.io/viamrobotics/antique2:amd64-cache
51+
platform: linux/amd64
52+
target: static-release-win
4753
runs-on: ${{ matrix.arch }}
4854
container:
4955
image: ${{ matrix.image }}
@@ -89,7 +95,7 @@ jobs:
8995
- name: Build (PR)
9096
if: contains(github.event.pull_request.labels.*.name, 'static-build') || contains(github.event.pull_request.labels.*.name, 'static-ignore-tests')
9197
run: |
92-
sudo -Hu testbot bash -lc 'make BUILD_CHANNEL="pr-${{ github.event.pull_request.number }}" static-release'
98+
sudo -Hu testbot bash -lc 'make BUILD_CHANNEL="pr-${{ github.event.pull_request.number }}" ${{ matrix.target }}'
9399
94100
- name: Upload Files (PR)
95101
if: contains(github.event.pull_request.labels.*.name, 'static-build') || contains(github.event.pull_request.labels.*.name, 'static-ignore-tests')
@@ -105,12 +111,12 @@ jobs:
105111
- name: Build (Latest)
106112
if: inputs.release_type == 'latest'
107113
run: |
108-
sudo -Hu testbot bash -lc 'make RELEASE_TYPE="latest" BUILD_CHANNEL="${{needs.build_timestamp.outputs.date}}" static-release'
114+
sudo -Hu testbot bash -lc 'make RELEASE_TYPE="latest" BUILD_CHANNEL="${{needs.build_timestamp.outputs.date}}" ${{ matrix.target }}'
109115
110116
- name: Build (Tagged)
111117
if: inputs.release_type == 'stable' || inputs.release_type == 'rc'
112118
run: |
113-
sudo -Hu testbot bash -lc 'make RELEASE_TYPE="${{ inputs.release_type }}" BUILD_CHANNEL="${{ github.ref_name }}" static-release'
119+
sudo -Hu testbot bash -lc 'make RELEASE_TYPE="${{ inputs.release_type }}" BUILD_CHANNEL="${{ github.ref_name }}" ${{ matrix.target }}'
114120
115121
- name: Set Date
116122
id: build_date

etc/subsystem_manifest/main.go

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ type substemManifest struct {
4444
func main() {
4545
subsystem := flag.String("subsystem", viamServer, "subsystem type") // default to viam-server
4646
binaryPath := flag.String("binary-path", "", "path to subsystem binary")
47+
resourcesJSON := flag.String("resources-json", "", "optional pre-dumped resource json")
4748
uploadPath := flag.String("upload-path", "", "path where this binary will be stored in gcs")
4849
outputPath := flag.String("output-path", "", "path where this manifest json file will be written")
4950
version := flag.String("version", "", "version")
@@ -63,7 +64,7 @@ func main() {
6364
}
6465
var metadata *viamServerMetadata
6566
if *subsystem == viamServer {
66-
metadata, err = getViamServerMetadata(*binaryPath)
67+
metadata, err = getViamServerMetadata(*binaryPath, *resourcesJSON)
6768
if err != nil {
6869
log.Fatalf("failed to get viam-server metadata: %v", err)
6970
}
@@ -93,18 +94,24 @@ func main() {
9394
}
9495
}
9596

96-
func getViamServerMetadata(path string) (*viamServerMetadata, error) {
97-
resourcesOutputFile, err := os.CreateTemp("", "resources-")
98-
if err != nil {
99-
return nil, err
100-
}
101-
resourcesOutputFileName := resourcesOutputFile.Name()
102-
//nolint:errcheck
103-
defer os.Remove(resourcesOutputFileName)
104-
//nolint:gosec
105-
command := exec.Command(path, "--dump-resources", resourcesOutputFileName)
106-
if err := command.Run(); err != nil {
107-
return nil, err
97+
// `path` is the path to the binary.
98+
// `resourcesOutputFileName` is an optional pre-dumped resource json.
99+
// note: we pre-dump for the windows build so that we are not bound to a windows runner. (we can cross-compile,
100+
// but we can't run the cross-compiled artifact).
101+
func getViamServerMetadata(path, resourcesOutputFileName string) (*viamServerMetadata, error) {
102+
if resourcesOutputFileName == "" {
103+
resourcesOutputFile, err := os.CreateTemp("", "resources-")
104+
if err != nil {
105+
return nil, err
106+
}
107+
resourcesOutputFileName = resourcesOutputFile.Name()
108+
//nolint:errcheck
109+
defer os.Remove(resourcesOutputFileName)
110+
111+
command := exec.Command(path, "--dump-resources", resourcesOutputFileName)
112+
if err := command.Run(); err != nil {
113+
return nil, err
114+
}
108115
}
109116
//nolint:gosec
110117
resourcesBytes, err := os.ReadFile(resourcesOutputFileName)

packaging.make

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,30 @@ static-release: server-static-compressed
5454
--version ${BUILD_CHANNEL} \
5555
--arch ${UNAME_M} \
5656
--output-path etc/packaging/static/manifest/viam-server-${BUILD_CHANNEL}-${UNAME_M}.json
57+
58+
static-release-win: FILENAME_OS=-windows
59+
static-release-win:
60+
# note: FILENAME_OS will be -windows for windows builds; for backwards compatibility, we don't do this for linux.
61+
rm -f bin/static/viam-server-windows.exe
62+
GOOS=windows GOARCH=amd64 go build -tags no_cgo,osusergo,netgo -ldflags="-extldflags=-static $(COMMON_LDFLAGS)" -o bin/static/viam-server-windows.exe ./web/cmd/server
63+
upx --best --lzma bin/static/viam-server-windows.exe
64+
65+
rm -rf etc/packaging/static/deploy/
66+
mkdir -p etc/packaging/static/deploy/
67+
cp bin/static/viam-server-windows.exe etc/packaging/static/deploy/viam-server$(FILENAME_OS)-${BUILD_CHANNEL}-${UNAME_M}.exe
68+
if [ "${RELEASE_TYPE}" = "stable" ] || [ "${RELEASE_TYPE}" = "latest" ]; then \
69+
cp bin/static/viam-server-windows.exe etc/packaging/static/deploy/viam-server$(FILENAME_OS)-${RELEASE_TYPE}-${UNAME_M}.exe; \
70+
fi
71+
72+
# note: GOOS=windows would break this on a linux runner
73+
go run -tags no_cgo ./web/cmd/server --dump-resources win-resources.json
74+
75+
rm -rf etc/packaging/static/manifest/
76+
mkdir -p etc/packaging/static/manifest/
77+
go run ./etc/subsystem_manifest \
78+
--binary-path etc/packaging/static/deploy/viam-server$(FILENAME_OS)-${BUILD_CHANNEL}-${UNAME_M}.exe \
79+
--upload-path packages.viam.com/apps/viam-server/viam-server$(FILENAME_OS)-${BUILD_CHANNEL}-${UNAME_M}.exe \
80+
--version ${BUILD_CHANNEL} \
81+
--arch ${UNAME_M} \
82+
--resources-json win-resources.json \
83+
--output-path etc/packaging/static/manifest/viam-server$(FILENAME_OS)-${BUILD_CHANNEL}-${UNAME_M}.json

0 commit comments

Comments
 (0)