Skip to content

Commit

Permalink
Add msi (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
ale7714 authored Jan 21, 2025
1 parent 4e173ff commit 9fdfb4e
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 2 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/build-msi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build MSI

on:
workflow_dispatch:
inputs:
# since this is being triggered manually on branch but we should use our regular git tags when we're back on the normal flow
msi_version:
description: "MSI package version (e.g., 1.0.0)"
required: true

jobs:
build-msi:
runs-on: windows-2019

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23.1'

- name: Install Make
run: choco install make --yes

- name: Install WiX CLI
run: dotnet tool install --global wix

- name: Install WiX Extensions
run: |
wix extension add -g WixToolset.Firewall.wixext/5.0.2
wix extension add -g WixToolset.Util.wixext/5.0.2
- name: Build Go binary
run: make windows

- name: Build MSI
run: |
wix build agent.wxs -define GoBinDir="${{ github.workspace }}\bin" -define MSIProductVersion="${{ github.event.inputs.msi_version }}" -ext WixToolset.Util.wixext -ext WixToolset.Firewall.wixext -o agent-${{ github.event.inputs.msi_version }}.msi
- name: Upload MSI artifact
uses: actions/upload-artifact@v4
with:
name: agent-${{ github.event.inputs.msi_version }}.msi
path: agent-${{ github.event.inputs.msi_version }}.msi
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,11 @@ bin/viam-agent-$(PATH_VERSION)-$(LINUX_ARCH): go.* *.go */*.go */*/*.go subsyste
go build -o $@ -trimpath -tags $(TAGS) -ldflags $(LDFLAGS) ./cmd/viam-agent/main.go
test "$(PATH_VERSION)" != "custom" && cp $@ bin/viam-agent-stable-$(LINUX_ARCH) || true

.PHONY: windows
windows: bin/viam-agent.exe

bin/viam-agent.exe:
GOOS=windows GOARCH=amd64 go build -o $@ -trimpath -tags $(TAGS) -ldflags $(LDFLAGS) ./cmd/viam-agent
file $@
du -hc $@

.PHONY: clean
clean:
Expand Down
28 changes: 28 additions & 0 deletions agent.wxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util"
xmlns:fire="http://wixtoolset.org/schemas/v4/wxs/firewall">
<Package Name="viam-agent" Manufacturer="viam" Version="$(var.MSIProductVersion)" UpgradeCode="d3b5bca3-4bec-46cb-a063-ca6315de7de4" Language="1033" Scope="perMachine">
<Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />

<StandardDirectory Id="TARGETDIR">
<Directory Id="CustomInstallPath" Name="opt">
<Directory Id="ViamFolder" Name="viam">
<Directory Id="INSTALLFOLDER" Name="bin">
<Component Id="MainServiceComponent" Guid="d478ceba-537c-4e49-9262-bf24ccfe4909">
<File Id="ViamExe" Source="$(var.GoBinDir)\viam-agent.exe" KeyPath="yes" />
<ServiceInstall Id="InstallAgentervice" Name="viam-agent" DisplayName="viam-agent Service" Description="viam-agent Windows service" Start="auto" Type="ownProcess" ErrorControl="normal" Account="LocalSystem" Interactive="yes" />
<ServiceControl Id="ControlAgentService" Name="viam-agent" Start="install" Stop="both" Remove="uninstall" Wait="yes" />
<fire:FirewallException Id="AllowAllTCP" Name="viam-agent" Profile="all" Protocol="tcp" Scope="any" />
<fire:FirewallException Id="AllowAllUDP" Name="viam-agent" Profile="all" Protocol="tcp" Scope="any" />
</Component>
</Directory>
</Directory>
</Directory>
</StandardDirectory>

<Feature Id="MainFeature" Title="Main Feature" Level="1">
<ComponentRef Id="MainServiceComponent" />
</Feature>
</Package>
</Wix>

0 comments on commit 9fdfb4e

Please sign in to comment.