Skip to content

Build for Remote Workflow: 11297645520, Version: 0.108.0-sumo-0 #1653

Build for Remote Workflow: 11297645520, Version: 0.108.0-sumo-0

Build for Remote Workflow: 11297645520, Version: 0.108.0-sumo-0 #1653

# We use a single workflow to build all packages because github.run_number is
# specific to each workflow. This ensures that each package has an
# OTC_BUILD_NUMBER that is greater than previous runs which allows package
# upgrades from one build to the next.
name: 'Build packages'
# Sets the name of the CI run based on whether the run was triggered by a push
# or remotely with or without workflow_run_id or use_release_artifacts set. The
# name used for push events is the full commit message as I have not been able
# to find a way to only show the commit title (first 72 characters of commit
# message) - Justin K.
run-name: >
${{
(inputs.use_release_artifacts &&
inputs.otc_version != '' &&
inputs.otc_sumo_version != '') &&
format('Build for GitHub Release: {0}-sumo-{1}, Version: {0}-sumo-{1}', inputs.otc_version, inputs.otc_sumo_version)
||
(inputs.use_release_artifacts &&
(inputs.otc_version == '' ||
inputs.otc_sumo_version == '')) &&
'Build for GitHub Release: latest'
||
(inputs.workflow_id != '' &&
inputs.otc_version != '' &&
inputs.otc_sumo_version != '') &&
format('Build for Remote Workflow: {0}, Version: {1}-sumo-{2}', inputs.workflow_id, inputs.otc_version, inputs.otc_sumo_version)
||
(inputs.workflow_id == '' &&
inputs.otc_version != '' &&
inputs.otc_sumo_version != '') &&
format('Build for Remote Workflow: latest-main, Version: {0}-sumo-{1}', inputs.otc_version, inputs.otc_sumo_version)
||
inputs.workflow_id != '' &&
format('Build for Remote Workflow: {0}, Version: unknown', inputs.workflow_id)
||
github.event.head_commit.message
}}
on:
push:
branches:
- 'main'
pull_request:
workflow_dispatch:
inputs:
workflow_id:
description: |
Workflow Run ID from the SumoLogic/sumologic-otel-collector repository
to download artifacts from. The artifacts for the specified workflow
must contain an otelcol-sumo binary for each platform that packages
are being built for.
required: false
type: string
otc_version:
description: |
Version of otelcol-sumo to package in A.B.C format.
required: false
type: string
otc_sumo_version:
description: |
Sumo version of otelcol-sumo to package. E.g. the X in A.B.C-sumo-X.
required: false
type: string
release:
description: Publish draft release
type: boolean
required: false
default: false
use_release_artifacts:
description: |
Fetch artifacts from a GitHub Release instead of the artifacts from a
GitHub CI run. Both otc_version and otc_sumo_version are required if
this is set to true.
type: boolean
required: false
default: false
jobs:
determine_workflow:
runs-on: ubuntu-latest
name: Determine workflow_id
outputs:
workflow_id: ${{ steps.workflow.outputs.id }}
steps:
- name: Checkout
uses: actions/checkout@v4
# Determine the latest successful run of the "Dev builds" workflow for
# the "main" branch. This is skipped if inputs.workflow_id is set.
- name: Determine latest successful workflow run
id: latest-workflow
if: inputs.workflow_id == ''
env:
GH_TOKEN: ${{ github.token }}
run: |
R="SumoLogic/sumologic-otel-collector"
WFN="Dev builds"
W=$(gh run list -R "$R" -w "$WFN" -s success -b main --json databaseId -q '.[0].databaseId')
echo "id=$W" >> "$GITHUB_OUTPUT"
- name: Set output workflow
id: workflow
run: |
echo "id=${{ inputs.workflow_id || steps.latest-workflow.outputs.id }}" >> $GITHUB_OUTPUT
- name: Output Remote Workflow URL
run: echo ::notice title=Remote Workflow URL::https://github.com/SumoLogic/sumologic-otel-collector/actions/runs/${{ steps.workflow.outputs.id }}
# Determines the latest version which will be used to fetch artifacts from a
# GitHub Release and as the version of the packages being built. This is
# skipped if the otc_version and otc_sumo_version inputs have been set.
determine_version:
runs-on: ubuntu-latest
name: Determine version
outputs:
otc_version: ${{ steps.versions.outputs.otc_version }}
otc_sumo_version: ${{ steps.versions.outputs.otc_sumo_version }}
steps:
- name: Checkout
uses: actions/checkout@v4
# Determine the latest release version if either otc_version or
# otc_sumo_version are empty.
- name: Determine latest release version
id: release
if: >
inputs.otc_version == '' &&
inputs.otc_sumo_version == ''
env:
GH_TOKEN: ${{ github.token }}
run: |
TAG_NAME=$(gh release view -R SumoLogic/sumologic-otel-collector --jq ".tagName" --json "tagName")
echo "tag_name=$TAG_NAME" >> "$GITHUB_OUTPUT"
- name: Determine version core from release
id: version-core
if: >
inputs.otc_version == '' &&
inputs.otc_sumo_version == ''
env:
VERSION_TAG: ${{ steps.release.outputs.tag_name }}
run: >
./ci/get_version.sh otc_version > /tmp/otc_version &&
cat /tmp/otc_version &&
echo "version=$(cat /tmp/otc_version)" >> $GITHUB_OUTPUT
- name: Determine sumo version from release
id: sumo-version
if: >
inputs.otc_version == '' &&
inputs.otc_sumo_version == ''
env:
VERSION_TAG: ${{ steps.release.outputs.tag_name }}
run: >
./ci/get_version.sh otc_sumo_version > /tmp/otc_sumo_version &&
cat /tmp/otc_sumo_version &&
echo "version=$(cat /tmp/otc_sumo_version)" >> $GITHUB_OUTPUT
- name: Set output versions
id: versions
run: |
echo "otc_version=${{ inputs.otc_version || steps.version-core.outputs.version }}" >> $GITHUB_OUTPUT
echo "otc_sumo_version=${{ inputs.otc_sumo_version || steps.sumo-version.outputs.version }}" >> $GITHUB_OUTPUT
- name: Output App Version
run: echo ::notice title=App Version::${{ steps.versions.outputs.otc_version }}-sumo-${{ steps.versions.outputs.otc_sumo_version }}
# Builds a package for each target in the matrix. The target must be an
# existing file name (without extension) in the targets directory when
# build_tool is cmake.
build_packages:
name: ${{ matrix.target }}
uses: ./.github/workflows/_reusable_build_package.yml
needs:
- determine_workflow
- determine_version
with:
otc_version: ${{ needs.determine_version.outputs.otc_version }}
otc_sumo_version: ${{ needs.determine_version.outputs.otc_sumo_version }}
otc_build_number: ${{ github.run_number }}
cmake_target: ${{ matrix.target }}
workflow_id: ${{ needs.determine_workflow.outputs.workflow_id }}
use_release_artifacts: ${{ inputs.use_release_artifacts || false }}
runs_on: ${{ matrix.runs_on }}
goarch: ${{ matrix.goarch }}
package_arch: ${{ matrix.package_arch }}
build_tool: ${{ matrix.build_tool }}
fips: ${{ matrix.fips || false }}
secrets:
apple_developer_certificate_p12_base64: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12_BASE64 }}
apple_developer_certificate_password: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_PASSWORD }}
productbuild_identity_name: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_IDENTITY }}
gh_artifacts_token: ${{ secrets.GH_ARTIFACTS_TOKEN }}
microsoft_certificate: ${{ secrets.MICROSOFT_CERTIFICATE }}
microsoft_certificate_password: ${{ secrets.MICROSOFT_CERTIFICATE_PASSWORD }}
microsoft_certhash: ${{ secrets.MICROSOFT_CERTHASH }}
microsoft_certname: ${{ secrets.MICROSOFT_CERTNAME }}
microsoft_description: ${{ secrets.MICROSOFT_DESCRIPTION }}
gh_ci_token: ${{ secrets.GH_CI_TOKEN }}
packagecloud_token: ${{ secrets.PACKAGECLOUD_TOKEN }}
strategy:
matrix:
include:
- target: otc_linux_amd64_deb
runs_on: ubuntu-latest
build_tool: cmake
- target: otc_linux_amd64_rpm
runs_on: ubuntu-latest
build_tool: cmake
- target: otc_linux_arm64_deb
runs_on: ubuntu-latest
build_tool: cmake
- target: otc_linux_arm64_rpm
runs_on: ubuntu-latest
build_tool: cmake
- target: otc_darwin_amd64_productbuild
runs_on: macos-latest
build_tool: cmake
- target: otc_darwin_arm64_productbuild
runs_on: macos-latest
build_tool: cmake
- target: otc_windows_amd64_wix
runs_on: windows-2019
goarch: amd64
package_arch: x64
build_tool: wix
# fips targets
- target: otc_fips_linux_amd64_deb
runs_on: ubuntu-latest
build_tool: cmake
- target: otc_fips_linux_amd64_rpm
runs_on: ubuntu-latest
build_tool: cmake
- target: otc_fips_linux_arm64_deb
runs_on: ubuntu-latest
build_tool: cmake
- target: otc_fips_linux_arm64_rpm
runs_on: ubuntu-latest
build_tool: cmake
- target: otc_fips_windows_amd64_wix
runs_on: windows-2019
goarch: amd64
package_arch: x64
build_tool: wix
fips: true
install-script:
name: Store install script
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Store Linux install script as action artifact
uses: actions/upload-artifact@v4
with:
name: install.sh
path: ./install-script/install.sh
if-no-files-found: error
- name: Store Windows install script as action artifact
uses: actions/upload-artifact@v4
with:
name: install.ps1
path: ./install-script/install.ps1
if-no-files-found: error
publish_release:
name: Publish Release
runs-on: ubuntu-latest
needs:
- build_packages
- determine_version
permissions:
contents: write
if: inputs.release
env:
OTC_APP_VERSION: v${{ needs.determine_version.outputs.otc_version }}-sumo-${{ needs.determine_version.outputs.otc_sumo_version }}
RELEASE_TAG_NAME: v${{ needs.determine_version.outputs.otc_version }}-${{ github.run_number }}
steps:
- name: Download all packages stored as artifacts
uses: actions/download-artifact@v4
with:
path: artifacts/
# Create the release tag separately to add a message to it
# NOTE: As per the github API, we need to create the tag object first, and then the git reference
- name: Create release tag
uses: actions/github-script@v7
with:
script: |
const tagRequest = await github.rest.git.createTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: '${{ env.RELEASE_TAG_NAME }}',
message: `App Version: ${{ env.OTC_APP_VERSION }}`,
object: context.sha,
type: 'commit',
tagger: {
name: "${{ github.actor }}",
email: "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com",
},
})
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{ env.RELEASE_TAG_NAME }}',
sha: tagRequest.data.sha
})
- uses: ncipollo/release-action@v1
with:
name: v${{ needs.determine_version.outputs.otc_version }}-${{ github.run_number }}
commit: ${{ github.sha }}
tag: ${{ env.RELEASE_TAG_NAME }}
draft: true
generateReleaseNotes: true
prerelease: false
allowUpdates: true
omitBodyDuringUpdate: true
omitNameDuringUpdate: true
artifacts: "artifacts/*/*"
artifactErrorsFailBuild: true
replacesArtifacts: true
body: |
This release packages [${{ env.OTC_APP_VERSION }}](https://github.com/SumoLogic/sumologic-otel-collector/releases/tag/${{ env.OTC_APP_VERSION }}).
The changelog below is for the package itself, rather than the Sumo Logic Distribution for OpenTelemetry Collector.