Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add msi #58

Open
wants to merge 5 commits into
base: aw-windows
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Loading