Skip to content

Updated Otel Contrib Deps for mysqlreceiver + k8sclusterreceiver upda… #90

Updated Otel Contrib Deps for mysqlreceiver + k8sclusterreceiver upda…

Updated Otel Contrib Deps for mysqlreceiver + k8sclusterreceiver upda… #90

Workflow file for this run

name: Host Agent - RPM
on:
workflow_dispatch:
inputs:
release_version:
description: 'Release version for RPM package'
required: true
release_number:
description: 'Release number for RPM package'
required: true
push:
paths-ignore:
- '.github/**'
tags:
- '[0-9]+.[0-9]+.[0-9]+'
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
jobs:
build:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
arch:
- x86_64
- aarch64
max-parallel: 1
steps:
- name: Install rpm build for ACT runs
if: ${{ github.actor == 'nektos/act' }}
run: |
sudo apt-get update
sudo apt-get install -y rpm
- name: Checkout Repo
uses: actions/checkout@v4
with:
token: ${{ secrets.GHCR_TOKEN }}
ssh-key: ${{ secrets.CHECK_AGENT_ACCESS }}
submodules: 'recursive'
- name: Set Architecture Variables
run: |
if [ -n "${{ github.event.inputs.release_version }}" ]; then
echo "RELEASE_VERSION=${{ github.event.inputs.release_version }}" >> $GITHUB_ENV
else
echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
fi
echo "::set-env name=RELEASE_NUMBER::$(echo "${{ github.event.inputs.release_number || 1 }}" | tr -d '\n')"
echo "::set-env name=PACKAGE_NAME::mw-agent"
echo "::set-env name=SPEC_FILE::mw-agent.spec"
- name: Creating Required Folder Structure
run: |
mkdir -p ~/build/rpmbuild/BUILD
mkdir -p ~/build/rpmbuild/BUILDROOT
mkdir -p ~/build/rpmbuild/RPMS
mkdir -p ~/build/rpmbuild/SOURCES
mkdir -p ~/build/rpmbuild/SPECS
mkdir -p ~/build/rpmbuild/SRPMS
mkdir -p ~/build/rpmbuild/SOURCES/${{ matrix.arch }}/${PACKAGE_NAME}-${RELEASE_VERSION}/bin
echo '%_topdir %(echo $HOME)/build/rpmbuild' > ~/.rpmmacros
cp package-tooling/linux/rpm/$SPEC_FILE ~/build/rpmbuild/SPECS/$SPEC_FILE
cp package-tooling/agent-config.yaml.sample \
~/build/rpmbuild/SOURCES/${{ matrix.arch }}/${PACKAGE_NAME}-${RELEASE_VERSION}/agent-config.yaml.sample
cp package-tooling/otel-config.yaml.sample \
~/build/rpmbuild/SOURCES/${{ matrix.arch }}/${PACKAGE_NAME}-${RELEASE_VERSION}/otel-config.yaml.sample
cp package-tooling/linux/postinst ~/build/rpmbuild/SOURCES/${{ matrix.arch }}/${PACKAGE_NAME}-${RELEASE_VERSION}/postinstall.sh
cp package-tooling/linux/mw-agent.service ~/build/rpmbuild/SOURCES/${{ matrix.arch }}/${PACKAGE_NAME}-${RELEASE_VERSION}/mw-agent.service
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.22.1
cache: false
- name: Set up Git credentials for Go
run: |
git config --global url."https://${{ secrets.GHCR_TOKEN }}:@github.com/".insteadOf "https://github.com/"
env:
GITHUB_TOKEN: ${{ secrets.GHCR_TOKEN }}
# Building with CGO_ENABLED=0 so that we can build static binary which is not dependent on any external libraries
# Building with -ldflags="-s -w" to reduce the size of binary
- name: Go Build
run: |
buildarch="amd64"
if [ ${{ matrix.arch }} == "aarch64" ]
then
buildarch="arm64"
fi
if [ ${{ github.actor }} != "nektos/act" ]
then
CGO_ENABLED=0 GOPRIVATE=github.com/middleware-labs GOOS=linux GOARCH=${buildarch} go build \
-ldflags="-s -w -X main.agentVersion=${RELEASE_VERSION}" \
-v -a -o ~/build/rpmbuild/SOURCES/${{ matrix.arch }}/${PACKAGE_NAME}-${RELEASE_VERSION}/${PACKAGE_NAME} cmd/host-agent/main.go
else
cp ~/build/mw-host-agent-${buildarch} ~/build/rpmbuild/SOURCES/${{ matrix.arch }}/${PACKAGE_NAME}-${RELEASE_VERSION}/${PACKAGE_NAME}
fi
- name: Tar Building
run: |
cd ~/build/rpmbuild/SOURCES/${{ matrix.arch }}
tar czvf ~/build/rpmbuild/SOURCES/${PACKAGE_NAME}-${RELEASE_VERSION}-${{ matrix.arch }}.tar.gz \
${PACKAGE_NAME}-${RELEASE_VERSION}/
- name: Create RPM package
run: |
rpmbuild -bb --define="release_version ${RELEASE_VERSION}" \
--define="release_number ${RELEASE_NUMBER}" \
--define="arch ${{ matrix.arch }}" \
--define="package_name ${PACKAGE_NAME}" \
--target=${{ matrix.arch }} ~/build/rpmbuild/SPECS/$SPEC_FILE
- name: Acquire lock
if: ${{ github.actor != 'nektos/act' }}
run: flock upload.lock -c "echo Lock acquired"
- name: Upload artifacts to Github Pages (yum.middleware.io)
if: ${{ github.actor != 'nektos/act' }}
run: |
git clone https://.:${{ secrets.GHCR_TOKEN }}@github.com/middleware-labs/yum.middleware.io.git
cp -r ~/build/rpmbuild/RPMS/${{ matrix.arch }}/${PACKAGE_NAME}-${RELEASE_VERSION}-${RELEASE_NUMBER}.${{ matrix.arch }}.rpm \
yum.middleware.io/${{ matrix.arch }}/Packages/
cd yum.middleware.io
git config --global user.email "[email protected]"
git config --global user.name "bhogayatakb"
git add .
git commit -m "RPM added to yum.middleware.io"
git fetch origin master
git merge origin/master
git push origin master
- name: Release lock
if: ${{ github.actor != 'nektos/act' }}
run: flock upload.lock -c "echo Lock released"
- name: Delay
if: ${{ github.actor != 'nektos/act' }}
run: sleep 10