Skip to content

Commit

Permalink
Add jobmon to CI process: DEB,RPM,MSI,SPK packages
Browse files Browse the repository at this point in the history
- Goreleaser config duplication reduced using Env variables
- All cagent binaries now have one point of information about package version and license information
- csender '--version' output updated to be similar with jobmon.
  • Loading branch information
nikita-vanyasin committed Dec 3, 2019
1 parent b9bcd4a commit d416aed
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 54 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
.idea
cmd/cagent/cagent
cmd/jobmon/jobmon
cmd/csender/csender
synology-spk/1_create_package/cagent/cagent
synology-spk/1_create_package/cagent/csender
synology-spk/1_create_package/cagent/jobmon
/cagent
/cagent.exe
/jobmon
/jobmon.exe
/csender
/csender.exe
.DS_Store
dist
config.toml
138 changes: 88 additions & 50 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
env:
- CGO_ENABLED=0
- PROJECT=github.com/cloudradar-monitoring/cagent
- LICENSE_PROPRIETARY=released under a proprietary license. See license.txt
builds:
- id: cagent
main: ./cmd/cagent
binary: cagent
goos:
- windows
- darwin
- linux
- windows
- darwin
- linux
goarch:
- 386
- amd64
- arm
- arm64
- 386
- amd64
- arm
- arm64
goarm:
- 5
- 6
- 7
- 5
- 6
- 7
# List of combinations of GOOS + GOARCH + GOARM to ignore.
ignore:
- goos: darwin
goarch: 386
- goos: windows
goarch: arm
- goos: darwin
goarch: arm
- goos: windows
goarch: arm64
- goos: darwin
goarch: arm64
- goos: darwin
goarch: 386
- goos: windows
goarch: arm
- goos: darwin
goarch: arm
- goos: windows
goarch: arm64
- goos: darwin
goarch: arm64
ldflags:
- -s -w -X github.com/cloudradar-monitoring/cagent.Version={{.Version}}
env:
- CGO_ENABLED=0
- "-s -w -X {{.Env.PROJECT}}.Version={{.Version}}"
- id: csender
main: ./cmd/csender
binary: csender
Expand Down Expand Up @@ -60,21 +62,47 @@ builds:
- goos: darwin
goarch: arm64
ldflags:
- -s -w -X main.version={{.Version}}
env:
- CGO_ENABLED=0
- "-s -w -X {{.Env.PROJECT}}.Version={{.Version}}"
- id: jobmon
main: ./cmd/jobmon
binary: jobmon
goos:
- windows
- darwin
- linux
goarch:
- 386
- amd64
- arm
- arm64
goarm:
- 5
- 6
- 7
# List of combinations of GOOS + GOARCH + GOARM to ignore.
ignore:
- goos: darwin
goarch: 386
- goos: windows
goarch: arm
- goos: darwin
goarch: arm
- goos: windows
goarch: arm64
- goos: darwin
goarch: arm64
ldflags:
- "-s -w -X {{.Env.PROJECT}}.Version={{.Version}}"
- id: cagent_proprietary
main: ./cmd/cagent
binary: cagent
goos:
- windows
- windows
goarch:
- 386
- amd64
- 386
- amd64
ldflags:
- -s -w -X github.com/cloudradar-monitoring/cagent.Version={{.Version}} -X "github.com/cloudradar-monitoring/cagent.LicenseInfo=released under a proprietary license. See license.txt"
env:
- CGO_ENABLED=0
- "-s -w -X {{.Env.PROJECT}}.Version={{.Version}} -X \"{{.Env.PROJECT}}.LicenseInfo={{.Env.LICENSE_PROPRIETARY}}\""
- id: csender_proprietary
main: ./cmd/csender
binary: csender
Expand All @@ -84,26 +112,35 @@ builds:
- 386
- amd64
ldflags:
- -s -w -X main.version={{.Version}} -X "main.licenseInfo=released under a proprietary license. See license.txt"
env:
- CGO_ENABLED=0
- "-s -w -X {{.Env.PROJECT}}.Version={{.Version}} -X \"{{.Env.PROJECT}}.LicenseInfo={{.Env.LICENSE_PROPRIETARY}}\""
- id: jobmon_proprietary
main: ./cmd/jobmon
binary: jobmon
goos:
- windows
goarch:
- 386
- amd64
ldflags:
- "-s -w -X {{.Env.PROJECT}}.Version={{.Version}} -X \"{{.Env.PROJECT}}.LicenseInfo={{.Env.LICENSE_PROPRIETARY}}\""
archives:
- id: cagent
builds:
- cagent
- csender
- jobmon
files:
- README.md
- example.config.toml
- README.md
- example.config.toml
replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
format_overrides:
- goos: windows
format: zip
- goos: windows
format: zip
checksum:
name_template: 'checksums.txt'
snapshot:
Expand All @@ -112,8 +149,8 @@ changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
- '^docs:'
- '^test:'
nfpm:
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
maintainer: CloudRadar GmbH <[email protected]>
Expand All @@ -125,25 +162,26 @@ nfpm:

# Formats to be generated.
formats:
- deb
- rpm
- deb
- rpm

dependencies:
- sudo
- sudo

recommends:
- dmidecode
- usbutils
- ca-certificates
- dbus
- dmidecode
- usbutils
- ca-certificates
- dbus

# Override default /usr/local/bin destination for binaries
bindir: /usr/bin

# Empty folders that should be created and managed by the packager implementation.
empty_folders:
- /var/log/cagent
- /etc/cagent
- /var/log/cagent
- /var/lib/cagent/jobmon
- /etc/cagent

files:
"example.config.toml": "/etc/cagent/example.config.toml"
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
BINARIES=cagent csender
BINARIES=cagent csender jobmon

all: test build

Expand Down Expand Up @@ -64,6 +64,8 @@ windows-sign:
scp ${SCP_WIN_BUILD_MACHINE_OPTIONS} ${PROJECT_DIR}/dist/cagent_windows_amd64/cagent.exe ${WIN_BUILD_MACHINE_AUTH}:${WIN_BUILD_MACHINE_CI_DIR}/dist/cagent_64.exe
scp ${SCP_WIN_BUILD_MACHINE_OPTIONS} ${PROJECT_DIR}/dist/csender_windows_386/csender.exe ${WIN_BUILD_MACHINE_AUTH}:${WIN_BUILD_MACHINE_CI_DIR}/dist/csender_386.exe
scp ${SCP_WIN_BUILD_MACHINE_OPTIONS} ${PROJECT_DIR}/dist/csender_windows_amd64/csender.exe ${WIN_BUILD_MACHINE_AUTH}:${WIN_BUILD_MACHINE_CI_DIR}/dist/csender_64.exe
scp ${SCP_WIN_BUILD_MACHINE_OPTIONS} ${PROJECT_DIR}/dist/jobmon_windows_386/jobmon.exe ${WIN_BUILD_MACHINE_AUTH}:${WIN_BUILD_MACHINE_CI_DIR}/dist/jobmon_386.exe
scp ${SCP_WIN_BUILD_MACHINE_OPTIONS} ${PROJECT_DIR}/dist/jobmon_windows_amd64/jobmon.exe ${WIN_BUILD_MACHINE_AUTH}:${WIN_BUILD_MACHINE_CI_DIR}/dist/jobmon_64.exe
# Copy other build dependencies
scp ${SCP_WIN_BUILD_MACHINE_OPTIONS} ${PROJECT_DIR}/build-win.bat ${WIN_BUILD_MACHINE_AUTH}:${WIN_BUILD_MACHINE_CI_DIR}/build-win.bat
ssh ${SSH_WIN_BUILD_MACHINE_OPTIONS} ${WIN_BUILD_MACHINE_AUTH} chmod +x ${WIN_BUILD_MACHINE_CI_DIR}/build-win.bat
Expand Down Expand Up @@ -94,6 +96,8 @@ windows-sign:
scp ${SCP_WIN_BUILD_MACHINE_OPTIONS} ${PROJECT_DIR}/dist/cagent_proprietary_windows_amd64/cagent.exe ${WIN_BUILD_MACHINE_AUTH}:${WIN_BUILD_MACHINE_CI_DIR_PROPRIETARY}/dist/cagent_64.exe
scp ${SCP_WIN_BUILD_MACHINE_OPTIONS} ${PROJECT_DIR}/dist/csender_proprietary_windows_386/csender.exe ${WIN_BUILD_MACHINE_AUTH}:${WIN_BUILD_MACHINE_CI_DIR_PROPRIETARY}/dist/csender_386.exe
scp ${SCP_WIN_BUILD_MACHINE_OPTIONS} ${PROJECT_DIR}/dist/csender_proprietary_windows_amd64/csender.exe ${WIN_BUILD_MACHINE_AUTH}:${WIN_BUILD_MACHINE_CI_DIR_PROPRIETARY}/dist/csender_64.exe
scp ${SCP_WIN_BUILD_MACHINE_OPTIONS} ${PROJECT_DIR}/dist/jobmon_proprietary_windows_386/jobmon.exe ${WIN_BUILD_MACHINE_AUTH}:${WIN_BUILD_MACHINE_CI_DIR_PROPRIETARY}/dist/jobmon_386.exe
scp ${SCP_WIN_BUILD_MACHINE_OPTIONS} ${PROJECT_DIR}/dist/jobmon_proprietary_windows_amd64/jobmon.exe ${WIN_BUILD_MACHINE_AUTH}:${WIN_BUILD_MACHINE_CI_DIR_PROPRIETARY}/dist/jobmon_64.exe
# Copy other build dependencies
scp -r ${SCP_WIN_BUILD_MACHINE_OPTIONS} ${PROJECT_DIR}/pkg-scripts/ ${WIN_BUILD_MACHINE_AUTH}:${WIN_BUILD_MACHINE_CI_DIR_PROPRIETARY}
scp -r ${SCP_WIN_BUILD_MACHINE_OPTIONS} ${PROJECT_DIR}/resources/ ${WIN_BUILD_MACHINE_AUTH}:${WIN_BUILD_MACHINE_CI_DIR_PROPRIETARY}
Expand Down
4 changes: 4 additions & 0 deletions build-mingw.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@ echo "Building version $GIT_TAG"

cp dist/cagent_windows_386/cagent.exe cagent.exe
cp dist/csender_windows_386/csender.exe csender.exe
cp dist/jobmon_windows_386/jobmon.exe jobmon.exe
go-msi make -k --src pkg-scripts/msi-templates --msi dist/_cagent_32.msi --version $GIT_TAG --arch 386
rm cagent.exe
rm csender.exe
rm jobmon.exe

cp dist/cagent_windows_amd64/cagent.exe cagent.exe
cp dist/csender_windows_amd64/csender.exe csender.exe
cp dist/jobmon_windows_amd64/jobmon.exe jobmon.exe
go-msi make --src pkg-scripts/msi-templates --msi dist/_cagent_64.msi --version $GIT_TAG --arch amd64
rm cagent.exe
rm csender.exe
rm jobmon.exe

mv dist/_cagent_32.msi dist/cagent_32.msi
mv dist/_cagent_64.msi dist/cagent_64.msi
4 changes: 4 additions & 0 deletions build-win.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@ CD %build_dir%

COPY dist\cagent_386.exe cagent.exe
COPY dist\csender_386.exe csender.exe
COPY dist\jobmon_386.exe jobmon.exe
go-msi make --src pkg-scripts\msi-templates --msi dist/_cagent_32.msi --version %cagent_version% --arch 386
DEL cagent.exe
DEL csender.exe
DEL jobmon.exe

COPY dist\cagent_64.exe cagent.exe
COPY dist\csender_64.exe csender.exe
COPY dist\jobmon_64.exe jobmon.exe
go-msi make --src pkg-scripts\msi-templates --msi dist/_cagent_64.msi --version %cagent_version% --arch amd64
DEL cagent.exe
DEL csender.exe
DEL jobmon.exe

COPY dist\_cagent_32.msi C:\Users\hero\ci\cagent_32.msi
COPY dist\_cagent_64.msi C:\Users\hero\ci\cagent_64.msi
4 changes: 4 additions & 0 deletions pkg-scripts/msi-templates/product.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes">
<RegistryValue Type="string" Value='"[INSTALLDIR]\csender.exe" "%1%"'/>
</RegistryKey>
<RegistryKey Root="HKCR" Key="jobmon\shell\open\command"
ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes">
<RegistryValue Type="string" Value='"[INSTALLDIR]\jobmon.exe" "%1%"'/>
</RegistryKey>
<RegistryKey Root="HKCR" Key="cagent"
ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes">
<RegistryValue Type="string" Name="URL Protocol" Value="" KeyPath="yes"/>
Expand Down
3 changes: 2 additions & 1 deletion synology-spk/create_spk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ sed -i.bak "s/{PKG_ARCH}/noarch/g" 2_create_project/INFO
rm 2_create_project/INFO.bak

cp -f ../dist/cagent_linux_${ARCH}/cagent 1_create_package/cagent
cp -f ../dist/csender_linux_${ARCH}/csender 1_create_package/cagent
cp -f ../dist/csender_linux_${ARCH}/csender 1_create_package/cagent/csender
cp -f ../dist/jobmon_linux_${ARCH}/jobmon 1_create_package/cagent/jobmon

cd 1_create_package
tar cvfz package.tgz *
Expand Down
3 changes: 1 addition & 2 deletions wix.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
"guid": "174d5f1a-04ae-4d99-8807-9e9ced201957",
"items": [
"cagent.exe",


"csender.exe",
"jobmon.exe",
"example.config.toml"
]
},
Expand Down

0 comments on commit d416aed

Please sign in to comment.