Skip to content

Commit

Permalink
add uploading to packagecloud
Browse files Browse the repository at this point in the history
Signed-off-by: Justin Kolberg <[email protected]>
  • Loading branch information
amdprophet committed Aug 26, 2024
1 parent 4f60759 commit a6e6ddf
Show file tree
Hide file tree
Showing 21 changed files with 882 additions and 2 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/_reusable_build_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Download packagecloud-go tool
run: |
baseURL="https://github.com/amdprophet/packagecloud-go/releases/download"
version="0.1.3"
file="packagecloud-go_${version}_linux_amd64.tar.gz"
curl -Lo /tmp/packagecloud-go.tar.gz $baseURL/$version/$file
- name: Install packagecloud-go tool
run: |
tar -C /tmp -zxf /tmp/packagecloud-go.tar.gz
sudo mv /tmp/packagecloud /usr/local/bin
- name: Workflow URL for sumologic-otel-collector
if: ${{ !inputs.use_release_artifacts && inputs.workflow_id != '' }}
run: |
Expand Down Expand Up @@ -214,6 +226,8 @@ jobs:
path: ./build/${{ steps.package.outputs.path }}
if-no-files-found: error

- name: Publish package to Packagecloud

test_package:
runs-on: ${{ inputs.runs_on }}
name: Test (CMake)
Expand Down
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Require CMake >= 3.24.1
cmake_minimum_required(VERSION 3.24.1 FATAL_ERROR)

# Required and optional programs. Attempts to find required and optional
# programs used to build the packages.
find_program(PACKAGECLOUD_PROGRAM packagecloud REQUIRED)

# Set version information
include("${CMAKE_SOURCE_DIR}/version.cmake")

Expand All @@ -11,6 +15,7 @@ include(CPackComponent)
# Set directory variables
set(ASSETS_DIR "${CMAKE_SOURCE_DIR}/assets")
set(COMPONENTS_DIR "${CMAKE_SOURCE_DIR}/components")
set(DISTRIBUTIONS_DIR "${CMAKE_SOURCE_DIR}/distributions")
set(EXTERNAL_PROJECTS_DIR "${CMAKE_SOURCE_DIR}/external_projects")
set(SETTINGS_DIR "${CMAKE_SOURCE_DIR}/settings")
set(TARGETS_DIR "${CMAKE_SOURCE_DIR}/targets")
Expand All @@ -24,6 +29,7 @@ include("${CMAKE_SOURCE_DIR}/components.cmake")
include("${CMAKE_SOURCE_DIR}/external_projects.cmake")
include("${CMAKE_SOURCE_DIR}/templates.cmake")
include("${CMAKE_SOURCE_DIR}/packages.cmake")
include("${CMAKE_SOURCE_DIR}/distributions.cmake")
include("${CMAKE_SOURCE_DIR}/settings.cmake")

# Add module paths
Expand Down
16 changes: 14 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
FROM alpine:3.17

ARG TARGETPLATFORM
ARG PACKAGECLOUDGO_VERSION=0.1.3

LABEL org.opencontainers.image.authors="Sumo Logic <[email protected]>"

RUN apk add --no-cache \
Expand All @@ -9,8 +13,16 @@ RUN apk add --no-cache \
git \
make \
rpm \
rpm-dev
rpm-dev \
curl \
bash \
tar \
gzip

COPY docker/install-deps.sh /install-deps.sh

RUN /install-deps.sh "$TARGETARCH"

COPY entrypoint.sh /entrypoint.sh
COPY docker/entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
69 changes: 69 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
mkfile_dir ?= $(patsubst %/,%,$(dir $(mkfile_path)))
build_dir ?= $(mkfile_dir)/build

OTC_ARTIFACTS_SOURCE ?= github-artifacts

ifeq ($(strip $(PACKAGECLOUD_TOKEN)),)
$(error "PACKAGECLOUD_TOKEN must be set")
endif

.PHONY: docker-image
docker-image:
docker buildx bake --load

.PHONY: build
build: docker-image
build:
docker run \
-e TARGET="$(TARGET)" \
-e OTC_VERSION="$(OTC_VERSION)" \
-e OTC_SUMO_VERSION="$(OTC_SUMO_VERSION)" \
-e OTC_BUILD_NUMBER="$(OTC_BUILD_NUMBER)" \
-e OTC_ARTIFACTS_SOURCE="$(OTC_ARTIFACTS_SOURCE)" \
-v "$(mkfile_dir):/src" \
-v "$(build_dir):/build" \
otelcol-sumo/cmake \
cmake /src

.PHONY: package
package: build
package:
docker run \
-v "$(mkfile_dir):/src" \
-v "$(build_dir):/build" \
otelcol-sumo/cmake \
make package

.PHONY: publish-package
publish-package: package
publish-package:
docker run \
-v "$(mkfile_dir):/src" \
-v "$(build_dir):/build" \
-e PACKAGECLOUD_TOKEN="$(PACKAGECLOUD_TOKEN)" \
otelcol-sumo/cmake \
make publish-package

.PHONY: otc_linux_amd64_deb
otc_linux_amd64_deb: TARGET = otc_linux_amd64_deb
otc_linux_amd64_deb: publish-package

.PHONY: otc_linux_arm64_deb
otc_linux_arm64_deb: TARGET = otc_linux_arm64_deb
otc_linux_arm64_deb: publish-package

.PHONY: otc_linux_amd64_rpm
otc_linux_amd64_rpm: TARGET = otc_linux_amd64_rpm
otc_linux_amd64_rpm: publish-package

.PHONY: otc_linux_arm64_rpm
otc_linux_arm64_rpm: TARGET = otc_linux_arm64_rpm
otc_linux_arm64_rpm: publish-package

.PHONY: all-targets
all-targets:
$(MAKE) otc_linux_amd64_deb
$(MAKE) otc_linux_arm64_deb
$(MAKE) otc_linux_amd64_rpm
$(MAKE) otc_linux_arm64_rpm
24 changes: 24 additions & 0 deletions distributions.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
macro(check_architecture_support)
if(NOT ${package_arch} IN_LIST _supported_architectures)
message(FATAL_ERROR "${_distro_name} does not support architecture: ${package_arch}")
endif()
list(APPEND packagecloud_distros ${_distro_index_name})
set(packagecloud_distros ${packagecloud_distros} PARENT_SCOPE)
endmacro()

macro(print_packagecloud_distros)
message(STATUS "Packagecloud distributions for this package:")
foreach(_pc_distro ${packagecloud_distros})
message(STATUS " * ${_pc_distro}")
endforeach()
endmacro()

include("${DISTRIBUTIONS_DIR}/amazon.cmake")
include("${DISTRIBUTIONS_DIR}/debian.cmake")
include("${DISTRIBUTIONS_DIR}/el.cmake")
include("${DISTRIBUTIONS_DIR}/fedora.cmake")
include("${DISTRIBUTIONS_DIR}/ol.cmake")
include("${DISTRIBUTIONS_DIR}/opensuse.cmake")
include("${DISTRIBUTIONS_DIR}/raspbian.cmake")
include("${DISTRIBUTIONS_DIR}/sles.cmake")
include("${DISTRIBUTIONS_DIR}/ubuntu.cmake")
33 changes: 33 additions & 0 deletions distributions/amazon.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
##
# Amazon Linux releases
#
# End of Life: https://endoflife.date/amazon-linux
##

# Amazon Linux 2023
#
# End of Standard Support: March 15, 2025
# End of Security Support: March 15, 2028
function(amazon_2023)
set(_distro_name "Amazon Linux 2023")
set(_distro_index_name "amazon/2023")
set(_supported_architectures
"aarch64"
"x86_64"
)
check_architecture_support()
endfunction()

# Amazon Linux 2
#
# End of Standard Support: June 30, 2025
# End of Security Support: June 30, 2025
function(amazon_2)
set(_distro_name "Amazon Linux 2")
set(_distro_index_name "amazon/2")
set(_supported_architectures
"aarch64"
"x86_64"
)
check_architecture_support()
endfunction()
115 changes: 115 additions & 0 deletions distributions/debian.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
##
# Debian releases
#
# LTS: https://wiki.debian.org/LTS.
# Extended LTS: https://wiki.debian.org/LTS/Extended
# Debian Releases: https://www.debian.org/releases/
##

# Debian 12 Bookworm
#
# End of LTS Support: 2028-06-11
# End of Extended LTS Support: 2033-06-30
function(debian_bookworm)
set(_distro_name "Debian 12 Bookworm")
set(_distro_index_name "debian/bookworm")
set(_supported_architectures
"amd64"
"arm64"
"armel"
"armhf"
"i386"
"mipsel"
"mips64el"
"ppc64el"
"s390x"
)
check_architecture_support()
endfunction()

# Debian 11 Bullseye
#
# End of LTS Support: 2026-08-31
# End of Extended LTS Support: 2031-06-30
function(debian_bullseye)
set(_distro_name "Debian 11 Bullseye")
set(_distro_index_name "debian/bullseye")
set(_supported_architectures
"amd64"
"arm64"
"armel"
"armhf"
"i386"
"mipsel"
"mips64el"
"ppc64el"
"s390x"
)
check_architecture_support()
endfunction()

# Debian 10 Buster
#
# End of LTS Support: 2024-06-30
# End of Extended LTS Support: 2029-06-30
function(debian_buster)
set(_distro_name "Debian 10 Buster")
set(_distro_index_name "debian/buster")
set(_supported_architectures
"amd64"
"arm64"
"armel"
"armhf"
"i386"
"mips"
"mipsel"
"mips64el"
"ppc64el"
"s390x"
)
check_architecture_support()
endfunction()

# Debian 9 Stretch
#
# End of LTS Support: 2022-06-30
# End of Extended LTS Support: 2027-06-30
function(debian_stretch)
set(_distro_name "Debian 9 Stretch")
set(_distro_index_name "debian/stretch")
set(_supported_architectures
"amd64"
"arm64"
"armel"
"armhf"
"i386"
"mips"
"mips64el"
"mipsel"
"ppc64el"
"s390x"
)
check_architecture_support()
endfunction()

# Debian 8 Jessie
#
# End of LTS Support: 2020-06-30
# End of Extended LTS Support: 2025-06-30
function(debian_jessie)
set(_distro_name "Debian 8 Jessie")
set(_distro_index_name "debian/jessie")
set(_supported_architectures
"amd64"
"arm64"
"armel"
"armhf"
"i386"
"mips"
"mipsel"
"powerpc"
"ppc64el"
"s390x"
)
check_architecture_support()
endfunction()
57 changes: 57 additions & 0 deletions distributions/el.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
##
# Enterprise Linux releases
#
# Life Cycle: https://access.redhat.com/support/policy/updates/errata
# Architectures: https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/8/html/considerations_in_adopting_rhel_8/architectures_considerations-in-adopting-rhel-8
##

# Enterprise Linux 9
#
# End of Full Support: May 31, 2027
# End of Maintenance Support: May 31, 2032
# End of Extended Life Cycle Support: May 31, 2035
function(el_9)
set(_distro_name "Enterprise Linux 9.0")
set(_distro_index_name "el/9")
set(_supported_architectures
"aarch64"
"ppc64"
"s390x"
"x86_64"
)
check_architecture_support()
endfunction()

# Enterprise Linux 8
#
# End of Full Support: May 31, 2024
# End of Maintenance Support: May 31, 2029
# End of Extended Life Cycle Support: May 31, 2032
function(el_8)
set(_distro_name "Enterprise Linux 8.0")
set(_distro_index_name "el/8")
set(_supported_architectures
"aarch64"
"ppc64"
"s390x"
"x86_64"
)
check_architecture_support()
endfunction()

# Enterprise Linux 7
#
# End of Full Support: August 6, 2019
# End of Maintenance Support: June 30, 2024
# End of Extended Life Cycle Support: June 30, 2028
function(el_7)
set(_distro_name "Enterprise Linux 7.0")
set(_distro_index_name "el/7")
set(_supported_architectures
"aarch64"
"ppc64"
"s390x"
"x86_64"
)
check_architecture_support()
endfunction()
Loading

0 comments on commit a6e6ddf

Please sign in to comment.