diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index fd87e050..fdfde6cb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -23,3 +23,9 @@ jobs: - name: Verify run: make build + + - name: Set up Docker + uses: docker/setup-buildx-action@v3 + + - name: Verify srpm + run: make rpm/fedora-testbuild diff --git a/Makefile b/Makefile index 23fa14f7..55b90d16 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,9 @@ GO=$(shell which go) OTELCOL_VERSION ?= 0.93.0 OTELCOL_BUILDER_DIR ?= ${PWD}/bin OTELCOL_BUILDER ?= ${OTELCOL_BUILDER_DIR}/ocb -PROJECT ?= redhat-otel-collector +PROJECT ?= redhat-opentelemetry-collector +RPM_BUILDER ?= fedpkg +RELEASE ?= epel7 build: ocb mkdir -p _build @@ -33,11 +35,11 @@ endif .PHONY: vendor vendor: @echo "Downloading dependencies of the custom collector..." - cd ./_build && $(GO) mod tidy && $(GO) mod vendor + cd ./_build && $(GO) go mod tidy && $(GO) go mod vendor # Archive the source code with all dependencies in a tarball. .PHONY: archive -archive: +archive: vendor mkdir -p dist/ @echo "Creating a tarball with the source code..." @@ -54,3 +56,15 @@ archive: @echo "The archives are available at dist/:" @find dist/*.tar.gz + +# Build the collector as RPM. +.PHONY:rpm/source +rpm/source: collector.spec archive + cp *.spec ./dist && cd dist/ && $(RPM_BUILDER) --release "$(RELEASE)" srpm + +.PHONY: collector.spec +collector.spec: collector.spec.in + sed -e "s/%%PROJECT%%/$(PROJECT)/" -e "s/%%VERSION%%/$(OTELCOL_VERSION)/" < $< > $@ + +rpm/fedora-testbuild: + docker run --rm -v ${PWD}:/src:z fedora:39 /bin/bash -c 'dnf install -y git make curl gzip tar rpm-build golang fedpkg && git config --global --add safe.directory /src && pushd src && export GOPROXY=https://proxy.golang.org,direct && make rpm/source && popd' diff --git a/collector.spec.in b/collector.spec.in new file mode 100644 index 00000000..c073e302 --- /dev/null +++ b/collector.spec.in @@ -0,0 +1,49 @@ +%global goipath github.com/os-observability/redhat-opentelemetry-collector + +Version: %%VERSION%% +ExcludeArch: %{ix86} s390 ppc ppc64 aarch64 + +%gometa + +%global common_description %{expand: +Collector with the supported components for a Red Hat build of OpenTelemetry product} + +%global golicenses LICENSE +%global godocs README.md + +Name: %%PROJECT%% +Release: 1%{?dist} +Summary: Red Hat build of OpenTelemetry + +License: Apache-2.0 + +Source0: %{name}-%{version}.tar.gz +Source1: %{name}-deps-%{version}.tar.gz + +BuildRequires: go-toolset-1.20 +BuildRequires: git + +%description +%{common_description} + +%prep +%goprep -k + +%build +go build -buildmode pie -mod vendor + +%install +install -m 0755 -vd %{buildroot}%{_bindir} +install -m 0755 -vp %{gobuilddir}/bin/* %{buildroot}%{_bindir}/ + +%check +%gocheck + +%files +%license %{golicenses} +%doc %{godocs} +%{_bindir}/* + +%changelog +* Thu Feb 1 21:59:10 CET 2024 Nina Olear - 0.93.4 +- First package for Copr