Skip to content

Commit

Permalink
feat: Windows installation and packaging (#1775)
Browse files Browse the repository at this point in the history
* wip

* initial testing

* add goreleaser logging

* install tools

* simplify manual msi build action

* fix supervisor binary

* polish

* change back service name

* remove goreleaser logs

* update supervisor labels field

* add supervisor_storage, rename cfg to supervisor.yaml, try removing supervisor storage on uninstall

* cleanup logging and use -r flag when removing supervisor_storage

* include supervisor_storage dir
  • Loading branch information
dpaasman00 authored Aug 26, 2024
1 parent 0346fab commit 8247b64
Show file tree
Hide file tree
Showing 22 changed files with 146 additions and 289 deletions.
24 changes: 10 additions & 14 deletions .github/workflows/manual_msi_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,22 @@ jobs:
with:
go-version: "1.21"
check-latest: true
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser-pro
version: "v2.1.0"
args: build --single-target --skip=validate --clean --snapshot
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
- name: Install tools
run: make install-tools
- name: Release Prep
run: make release-prep
- name: Build Binaries
run: make build-binaries
- name: Copy Windows Collector Binary
run: cp dist/windows_amd64/collector_windows_amd64_v1/observiq-otel-collector.exe windows/observiq-otel-collector.exe
run: cp dist/collector_windows_amd64.exe windows/observiq-otel-collector.exe
- name: Copy Windows Updater Binary
run: cp dist/windows_amd64/updater_windows_amd64_v1/updater.exe windows/updater.exe
run: cp dist/updater_windows_amd64.exe windows/updater.exe
- name: Copy Supervisor Binary
run: cp release_deps/supervisor_bin/opampsupervisor_windows_amd64.exe windows/opampsupervisor.exe
- name: Copy Plugins to MSI Build Directory
run: cp -r release_deps/plugins windows/
- name: Copy Example Config
run: cp config/example.yaml windows/config.yaml
- name: Copy Logging Config
run: cp config/logging.yaml windows/logging.yaml
- name: Copy JMX Receiver Jar
run: cp release_deps/opentelemetry-java-contrib-jmx-metrics.jar windows/opentelemetry-java-contrib-jmx-metrics.jar
- name: Copy LICENSE
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,21 @@ jobs:
with:
go-version: "1.21"
check-latest: true
# Needed until supervisor binary is released
- name: Build Supervisor Binary
run: make release-prep
- name: Build Windows Binaries
run: make build-binaries
- name: Copy Windows Collector Binary
run: cp dist/collector_windows_amd64.exe windows/observiq-otel-collector.exe
- name: Copy Windows Updater Binary
run: cp dist/updater_windows_amd64.exe windows/updater.exe
- name: Copy Supervisor Binary
run: cp release_deps/supervisor_bin/opampsupervisor_windows_amd64.exe windows/opampsupervisor.exe
- name: Copy Plugins to MSI Build Directory
run: cp -r release_deps/plugins windows/
- name: Copy Example Config
run: cp config/example.yaml windows/config.yaml
- name: Copy Logging Config
run: cp config/logging.yaml windows/logging.yaml
- name: Copy JMX Receiver Jar
run: cp release_deps/opentelemetry-java-contrib-jmx-metrics.jar windows/opentelemetry-java-contrib-jmx-metrics.jar
- name: Copy LICENSE
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ windows/*.zip
windows/**/wix.dynamic.json
windows/**/wix
windows/config.yaml
windows/logging.yaml
windows/LICENSE
windows/plugins
opentelemetry-java-contrib-jmx-metrics.jar
Expand Down
3 changes: 2 additions & 1 deletion buildscripts/download-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ for PLATFORM in "${PLATFORMS[@]}"; do
fi
echo "Building supervisor for $GOOS/$GOARCH"
GOOS="$GOOS" GOARCH="$GOARCH" go build main.go
cp main $PROJECT_BASE/$DOWNLOAD_DIR/supervisor_bin/opampsupervisor_${GOOS}_${GOARCH}${EXT}
cp main${EXT} $PROJECT_BASE/$DOWNLOAD_DIR/supervisor_bin/opampsupervisor_${GOOS}_${GOARCH}${EXT}
rm main${EXT}
done
$(cd $PROJECT_BASE/$DOWNLOAD_DIR && rm -rf opentelemetry-collector-contrib)
21 changes: 0 additions & 21 deletions windows/Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,3 @@
.PHONY: vagrant-prep
vagrant-prep:
./scripts/vagrant-prep.sh

.PHONY: fetch-dependencies
fetch-dependencies:
./scripts/fetch-dependencies.sh

.PHONY: build-msi
build-msi: fetch-dependencies
cd ..; $(MAKE) build-windows
./scripts/build-msi.sh

.PHONY: test-install-msi
test-install-msi:
./scripts/test-install-msi.sh

.PHONY: test-uninstall-msi
test-uninstall-msi:
./scripts/test-uninstall-msi.sh

.PHONY: clean
clean:
rm -rf go-msi.exe config.yaml cinc-auditor.msi observiq-otel-collector.exe observiq-otel-collector.msi \
Expand Down
12 changes: 0 additions & 12 deletions windows/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
# Windows MSI building

This directory contains sources for building the Windows MSI using [go-msi](https://github.com/observIQ/go-msi/) and the [Wix toolset](https://wixtoolset.org/).

## Building Locally with Vagrant

A local build may be performed with [vagrant](https://www.vagrantup.com/).

The following make targets are available for local development:
* `vagrant-prep`: Starts up the vagrant box and prepares it for building and testing. The vagrant box must be up in order for building or testing to work. **PLEASE NOTE** that valid Windows licensing is your responsibility.
* `fetch-dependencies`: Fetches dependencies for building the MSI.
* `build-msi`: Builds the MSI. Depends on the `fetch-dependencies` target (`fetch-dependencies` will be run every time this is run).
* `test-install-msi`: Test installing the MSI. `build-msi` should be run before this is run. **NOTE** This target is flaky, it seems like the installers just don't run sometimes, so you may need to run this a couple of times, or manually install the msi's (cinc + observiq-otel-collector).
* `test-uninstall-msi`: Test uninstalling the MSI. `build-msi` should be run before this is run, and the MSI should be installed (e.g. by running `test-install-msi`)
* `clean`: Cleans this directory of dependencies from `fetch-dependencies`, as well as of build artifacts.
18 changes: 0 additions & 18 deletions windows/Vagrantfile

This file was deleted.

35 changes: 0 additions & 35 deletions windows/install/generate-manager-yaml.bat

This file was deleted.

71 changes: 71 additions & 0 deletions windows/install/generate-supervisor-yaml.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
@echo off
setlocal

set "install_dir=%~1"
set "endpoint=%~2"
set "secret_key=%~3"
set "labels=%~4"

echo %install_dir%
echo %endpoint%
echo %secret_key%
echo %labels%

if "%endpoint%"=="" (
echo Endpoint not specified; Not writing output yaml
exit /b 0
)

if "%secret_key%"=="" (
echo Secret Key not specified; Not writing output yaml
exit /b 0
)

set "supervisorFile=%install_dir%supervisor.yaml"
set "agentBinary=%install_dir%observiq-otel-collector.exe"

echo Writing manager yaml

set "serverField=server:"
set "endpointField= endpoint: "%endpoint%""
set "headersField= headers:"
set "authorizationField= Authorization: "Secret-Key %secret_key%""
set "tlsField= tls:"
set "insecureField= insecure: true"
set "insecureSkipField= insecure_skip_verify: true"

set "capabilitiesField=capabilities:"
set "acceptsRemoteCfgField= accepts_remote_config: true"
set "reportsRemoteCfgField= reports_remote_config: true"

set "agentField=agent:"
set "executablePathField= executable: '%agentBinary%'"
set "descriptionField= description:"
set "nonIdentifyingAttributesField= non_identifying_attributes:"
set "serviceLabelsField= service.labels: "%labels%""

set "storageField=storage:"
set "directoryField= directory: '%install_dir%supervisor_storage'"

echo %serverField% >"%supervisorFile%"
echo %endpointField% >>"%supervisorFile%"
echo %headersField% >>"%supervisorFile%"
echo %authorizationField% >>"%supervisorFile%"
echo %tlsField% >>"%supervisorFile%"
echo %insecureField% >>"%supervisorFile%"
echo %insecureSkipField% >>"%supervisorFile%"

echo %capabilitiesField% >>"%supervisorFile%"
echo %acceptsRemoteCfgField% >>"%supervisorFile%"
echo %reportsRemoteCfgField% >>"%supervisorFile%"

echo %agentField% >>"%supervisorFile%"
echo %executablePathField% >>"%supervisorFile%"
echo %descriptionField% >>"%supervisorFile%"
echo %nonIdentifyingAttributesField% >>"%supervisorFile%"
echo %serviceLabelsField% >>"%supervisorFile%"

echo %storageField% >>"%supervisorFile%"
echo %directoryField% >>"%supervisorFile%"

endlocal
28 changes: 0 additions & 28 deletions windows/scripts/build-msi.sh

This file was deleted.

36 changes: 0 additions & 36 deletions windows/scripts/fetch-dependencies.sh

This file was deleted.

21 changes: 0 additions & 21 deletions windows/scripts/test-install-msi.sh

This file was deleted.

21 changes: 0 additions & 21 deletions windows/scripts/test-uninstall-msi.sh

This file was deleted.

19 changes: 0 additions & 19 deletions windows/scripts/vagrant-prep.sh

This file was deleted.

Empty file.
2 changes: 1 addition & 1 deletion windows/templates/ConfigureManagementDlg.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<Condition Action="hide"><![CDATA[NOT (ENABLEMANAGEMENT)]]></Condition>
</Control>

<Control Id="SecretKeyLabel" Type="Text" X="20" Y="145" Width="290" Height="15" Transparent="yes" NoPrefix="yes" Text="{\WixUI_Font_Title}Secret Key" Hidden="yes" >
<Control Id="SecretKeyLabel" Type="Text" X="20" Y="145" Width="290" Height="15" Transparent="yes" NoPrefix="yes" Text="{\WixUI_Font_Title}Secret Key (Required)" Hidden="yes" >
<Condition Action="show"><![CDATA[ENABLEMANAGEMENT]]></Condition>
<Condition Action="hide"><![CDATA[NOT (ENABLEMANAGEMENT)]]></Condition>
</Control>
Expand Down
Loading

0 comments on commit 8247b64

Please sign in to comment.