Skip to content

Commit

Permalink
APP-7356 include windows in RDK stable release (#4750)
Browse files Browse the repository at this point in the history
  • Loading branch information
abe-winter committed Jan 28, 2025
1 parent fe84eee commit e3f5b8d
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 16 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/staticbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,15 @@ jobs:
- arch: ubuntu-latest
image: ghcr.io/viamrobotics/antique2:amd64-cache
platform: linux/amd64
target: static-release
- arch: ubuntu-small-arm
image: ghcr.io/viamrobotics/antique2:arm64-cache
platform: linux/arm64
target: static-release
- arch: ubuntu-latest
image: ghcr.io/viamrobotics/antique2:amd64-cache
platform: linux/amd64
target: static-release-win
runs-on: ${{ matrix.arch }}
container:
image: ${{ matrix.image }}
Expand Down Expand Up @@ -89,7 +95,7 @@ jobs:
- name: Build (PR)
if: contains(github.event.pull_request.labels.*.name, 'static-build') || contains(github.event.pull_request.labels.*.name, 'static-ignore-tests')
run: |
sudo -Hu testbot bash -lc 'make BUILD_CHANNEL="pr-${{ github.event.pull_request.number }}" static-release'
sudo -Hu testbot bash -lc 'make BUILD_CHANNEL="pr-${{ github.event.pull_request.number }}" ${{ matrix.target }}'
- name: Upload Files (PR)
if: contains(github.event.pull_request.labels.*.name, 'static-build') || contains(github.event.pull_request.labels.*.name, 'static-ignore-tests')
Expand All @@ -105,12 +111,12 @@ jobs:
- name: Build (Latest)
if: inputs.release_type == 'latest'
run: |
sudo -Hu testbot bash -lc 'make RELEASE_TYPE="latest" BUILD_CHANNEL="${{needs.build_timestamp.outputs.date}}" static-release'
sudo -Hu testbot bash -lc 'make RELEASE_TYPE="latest" BUILD_CHANNEL="${{needs.build_timestamp.outputs.date}}" ${{ matrix.target }}'
- name: Build (Tagged)
if: inputs.release_type == 'stable' || inputs.release_type == 'rc'
run: |
sudo -Hu testbot bash -lc 'make RELEASE_TYPE="${{ inputs.release_type }}" BUILD_CHANNEL="${{ github.ref_name }}" static-release'
sudo -Hu testbot bash -lc 'make RELEASE_TYPE="${{ inputs.release_type }}" BUILD_CHANNEL="${{ github.ref_name }}" ${{ matrix.target }}'
- name: Set Date
id: build_date
Expand Down
33 changes: 20 additions & 13 deletions etc/subsystem_manifest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type substemManifest struct {
func main() {
subsystem := flag.String("subsystem", viamServer, "subsystem type") // default to viam-server
binaryPath := flag.String("binary-path", "", "path to subsystem binary")
resourcesJSON := flag.String("resources-json", "", "optional pre-dumped resource json")
uploadPath := flag.String("upload-path", "", "path where this binary will be stored in gcs")
outputPath := flag.String("output-path", "", "path where this manifest json file will be written")
version := flag.String("version", "", "version")
Expand All @@ -63,7 +64,7 @@ func main() {
}
var metadata *viamServerMetadata
if *subsystem == viamServer {
metadata, err = getViamServerMetadata(*binaryPath)
metadata, err = getViamServerMetadata(*binaryPath, *resourcesJSON)
if err != nil {
log.Fatalf("failed to get viam-server metadata: %v", err)
}
Expand Down Expand Up @@ -93,18 +94,24 @@ func main() {
}
}

func getViamServerMetadata(path string) (*viamServerMetadata, error) {
resourcesOutputFile, err := os.CreateTemp("", "resources-")
if err != nil {
return nil, err
}
resourcesOutputFileName := resourcesOutputFile.Name()
//nolint:errcheck
defer os.Remove(resourcesOutputFileName)
//nolint:gosec
command := exec.Command(path, "--dump-resources", resourcesOutputFileName)
if err := command.Run(); err != nil {
return nil, err
// `path` is the path to the binary.
// `resourcesOutputFileName` is an optional pre-dumped resource json.
// note: we pre-dump for the windows build so that we are not bound to a windows runner. (we can cross-compile,
// but we can't run the cross-compiled artifact).
func getViamServerMetadata(path, resourcesOutputFileName string) (*viamServerMetadata, error) {
if resourcesOutputFileName == "" {
resourcesOutputFile, err := os.CreateTemp("", "resources-")
if err != nil {
return nil, err
}
resourcesOutputFileName = resourcesOutputFile.Name()
//nolint:errcheck
defer os.Remove(resourcesOutputFileName)

command := exec.Command(path, "--dump-resources", resourcesOutputFileName)
if err := command.Run(); err != nil {
return nil, err
}
}
//nolint:gosec
resourcesBytes, err := os.ReadFile(resourcesOutputFileName)
Expand Down
27 changes: 27 additions & 0 deletions packaging.make
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,30 @@ static-release: server-static-compressed
--version ${BUILD_CHANNEL} \
--arch ${UNAME_M} \
--output-path etc/packaging/static/manifest/viam-server-${BUILD_CHANNEL}-${UNAME_M}.json

static-release-win: FILENAME_OS=-windows
static-release-win:
# note: FILENAME_OS will be -windows for windows builds; for backwards compatibility, we don't do this for linux.
rm -f bin/static/viam-server-windows.exe
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
upx --best --lzma bin/static/viam-server-windows.exe

rm -rf etc/packaging/static/deploy/
mkdir -p etc/packaging/static/deploy/
cp bin/static/viam-server-windows.exe etc/packaging/static/deploy/viam-server$(FILENAME_OS)-${BUILD_CHANNEL}-${UNAME_M}.exe
if [ "${RELEASE_TYPE}" = "stable" ] || [ "${RELEASE_TYPE}" = "latest" ]; then \
cp bin/static/viam-server-windows.exe etc/packaging/static/deploy/viam-server$(FILENAME_OS)-${RELEASE_TYPE}-${UNAME_M}.exe; \
fi

# note: GOOS=windows would break this on a linux runner
go run -tags no_cgo ./web/cmd/server --dump-resources win-resources.json

rm -rf etc/packaging/static/manifest/
mkdir -p etc/packaging/static/manifest/
go run ./etc/subsystem_manifest \
--binary-path etc/packaging/static/deploy/viam-server$(FILENAME_OS)-${BUILD_CHANNEL}-${UNAME_M}.exe \
--upload-path packages.viam.com/apps/viam-server/viam-server$(FILENAME_OS)-${BUILD_CHANNEL}-${UNAME_M}.exe \
--version ${BUILD_CHANNEL} \
--arch ${UNAME_M} \
--resources-json win-resources.json \
--output-path etc/packaging/static/manifest/viam-server$(FILENAME_OS)-${BUILD_CHANNEL}-${UNAME_M}.json

0 comments on commit e3f5b8d

Please sign in to comment.