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

feat: Create Updater artifact #529

Merged
merged 10 commits into from
Jun 28, 2022
Merged
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,14 @@ updates:
commit-message:
prefix: "deps"
include: "scope"
- package-ecosystem: "gomod"
directory: "/updater"
schedule:
interval: "weekly"
ignore:
# Opentelemetry updates will be done manually
- dependency-name: "github.com/open-telemetry/opentelemetry-collector*"
- dependency-name: "go.opentelemetry.io/collector/*"
cpheps marked this conversation as resolved.
Show resolved Hide resolved
commit-message:
prefix: "deps"
include: "scope"
4 changes: 3 additions & 1 deletion .github/workflows/manual_msi_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ jobs:
args: build --single-target --skip-validate --rm-dist --snapshot
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Copy Windows Binary
- name: Copy Windows Collector Binary
run: cp dist/collector_windows_amd64_v1/observiq-otel-collector.exe windows/observiq-otel-collector.exe
- name: Copy Windows Updater Binary
run: cp dist/updater_windows_amd64_v1/updater.exe windows/updater.exe
- name: Copy Plugins to MSI Build Directory
run: cp -r release_deps/plugins windows/
- name: Copy Example Config
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ jobs:
args: build --single-target --skip-validate --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Copy Windows Binary
- name: Copy Windows Collector Binary
run: cp dist/collector_windows_amd64_v1/observiq-otel-collector.exe windows/observiq-otel-collector.exe
- name: Copy Windows Updater Binary
run: cp dist/updater_windows_amd64_v1/updater.exe windows/updater.exe
- name: Copy Plugins to MSI Build Directory
run: cp -r release_deps/plugins windows/
- name: Copy Example Config
Expand Down
26 changes: 26 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,32 @@ builds:
- -X github.com/observiq/observiq-otel-collector/internal/version.gitHash={{ .FullCommit }}
- -X github.com/observiq/observiq-otel-collector/internal/version.date={{ .Date }}
no_unique_dist_dir: false
- id: updater
binary: updater
dir: ./updater/
main: ./cmd/updater
env:
- CGO_ENABLED=0
mod_timestamp: "{{ .CommitTimestamp }}"
goos:
- windows
- linux
- darwin
goarch:
- amd64
- arm64
- arm
ignore:
- goos: windows
goarch: arm
- goos: windows
goarch: arm64
ldflags:
- -s -w
- -X github.com/observiq/observiq-otel-collector/internal/version.version=v{{ .Version }}
- -X github.com/observiq/observiq-otel-collector/internal/version.gitHash={{ .FullCommit }}
- -X github.com/observiq/observiq-otel-collector/internal/version.date={{ .Date }}
no_unique_dist_dir: false

# https://goreleaser.com/customization/archive/
archives:
Expand Down
26 changes: 19 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,23 @@ CURRENT_TAG := $(shell git tag --sort=v:refname --points-at HEAD | grep -E "v[0-
# Version will be the tag pointing to the current commit, or the previous version tag if there is no such tag
VERSION ?= $(if $(CURRENT_TAG),$(CURRENT_TAG),$(PREVIOUS_TAG))

# Default build target; making this should build for the current os/arch
# Build binaries for current GOOS/GOARCH by default
.DEFAULT_GOAL := build-binaries

# Builds just the collector for current GOOS/GOARCH pair
.PHONY: collector
collector:
go build -ldflags "-s -w -X github.com/observiq/observiq-otel-collector/internal/version.version=$(VERSION)" -o $(OUTDIR)/collector_$(GOOS)_$(GOARCH)$(EXT) ./cmd/collector

# Builds just the updater for current GOOS/GOARCH pair
.PHONY: updater
updater:
cd ./updater/; go build -ldflags "-s -w -X github.com/observiq/observiq-otel-collector/internal/version.version=$(VERSION)" -o ../$(OUTDIR)/updater_$(GOOS)_$(GOARCH)$(EXT) ./cmd/updater

# Builds the updater + collector for current GOOS/GOARCH pair
.PHONY: build-binaries
build-binaries: collector updater

.PHONY: build-all
build-all: build-linux build-darwin build-windows

Expand All @@ -40,27 +52,27 @@ build-windows: build-windows-amd64

.PHONY: build-linux-amd64
build-linux-amd64:
GOOS=linux GOARCH=amd64 $(MAKE) collector
GOOS=linux GOARCH=amd64 $(MAKE) build-binaries -j2
cpheps marked this conversation as resolved.
Show resolved Hide resolved

.PHONY: build-linux-arm64
build-linux-arm64:
GOOS=linux GOARCH=arm64 $(MAKE) collector
GOOS=linux GOARCH=arm64 $(MAKE) build-binaries -j2

.PHONY: build-linux-arm
build-linux-arm:
GOOS=linux GOARCH=arm $(MAKE) collector
GOOS=linux GOARCH=arm $(MAKE) build-binaries -j2

.PHONY: build-darwin-amd64
build-darwin-amd64:
GOOS=darwin GOARCH=amd64 $(MAKE) collector
GOOS=darwin GOARCH=amd64 $(MAKE) build-binaries -j2

.PHONY: build-darwin-arm64
build-darwin-arm64:
GOOS=darwin GOARCH=arm64 $(MAKE) collector
GOOS=darwin GOARCH=arm64 $(MAKE) build-binaries -j2

.PHONY: build-windows-amd64
build-windows-amd64:
GOOS=windows GOARCH=amd64 $(MAKE) collector
GOOS=windows GOARCH=amd64 $(MAKE) build-binaries -j2

# tool-related commands
.PHONY: install-tools
Expand Down
35 changes: 35 additions & 0 deletions updater/cmd/updater/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright observIQ, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package main

import (
"fmt"

"github.com/observiq/observiq-otel-collector/internal/version"
BinaryFissionGames marked this conversation as resolved.
Show resolved Hide resolved
"github.com/spf13/pflag"
)

// Unimplemented
func main() {
var showVersion = pflag.BoolP("version", "v", false, "prints the version of the collector")
pflag.Parse()

if *showVersion {
fmt.Println("observiq-otel-collector updater version", version.Version())
fmt.Println("commit:", version.GitHash())
fmt.Println("built at:", version.Date())
return
}
}
8 changes: 8 additions & 0 deletions updater/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module github.com/observiq/observiq-otel-collector/updater

go 1.17
cpheps marked this conversation as resolved.
Show resolved Hide resolved

require (
github.com/observiq/observiq-otel-collector v1.2.0
github.com/spf13/pflag v1.0.5
)
8 changes: 8 additions & 0 deletions updater/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/observiq/observiq-otel-collector v1.2.0 h1:tuCH3237U893BFPwq8Hrejt3/ofxMWYGeB+UFt1Lc48=
github.com/observiq/observiq-otel-collector v1.2.0/go.mod h1:Jj2982ObJlVuLKV5RuzuZzoBmhzk6VLQZxSOWs/dy+8=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
1 change: 1 addition & 0 deletions windows/scripts/build-msi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ mkdir -p storage
touch storage/.include

cp "$PROJECT_BASE/dist/collector_windows_amd64.exe" "observiq-otel-collector.exe"
cp "$PROJECT_BASE/dist/updater_windows_amd64.exe" "updater.exe"

vagrant winrm -c \
"cd C:/vagrant; go-msi.exe make -m observiq-otel-collector.msi --version v0.0.1 --arch amd64"
3 changes: 3 additions & 0 deletions windows/wix.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"arguments": "--config "[INSTALLDIR]config.yaml" --logging "[INSTALLDIR]logging.yaml" --manager "[INSTALLDIR]manager.yaml""
}
},
{
"path": "updater.exe"
},
{
"path": "config.yaml",
"never_overwrite": true
Expand Down