add uploading to packagecloud #1
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: '_reusable_build_package' | |
on: | |
workflow_call: | |
inputs: | |
otc_version: | |
required: true | |
type: string | |
otc_sumo_version: | |
required: true | |
type: string | |
otc_build_number: | |
required: false | |
type: string | |
cmake_target: | |
required: true | |
type: string | |
workflow_id: | |
required: false | |
type: string | |
use_release_artifacts: | |
required: false | |
type: boolean | |
default: false | |
runs_on: | |
required: true | |
type: string | |
goarch: | |
required: false | |
type: string | |
package_arch: | |
required: false | |
type: string | |
build_tool: | |
required: true | |
type: string | |
fips: | |
required: false | |
type: boolean | |
default: false | |
secrets: | |
gh_artifacts_token: | |
required: true | |
apple_developer_certificate_p12_base64: | |
required: false | |
apple_developer_certificate_password: | |
required: false | |
productbuild_identity_name: | |
required: false | |
microsoft_certificate: | |
required: false | |
microsoft_certificate_password: | |
required: false | |
microsoft_certhash: | |
required: false | |
microsoft_certname: | |
required: false | |
microsoft_description: | |
required: false | |
gh_ci_token: | |
required: true | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
build_package: | |
runs-on: ${{ inputs.runs_on }} | |
name: Build (CMake) | |
if: inputs.build_tool == 'cmake' | |
outputs: | |
package_path: ${{ steps.package.outputs.path }} | |
steps: | |
- 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: | | |
org="SumoLogic" | |
repo="sumologic-otel-collector" | |
workflow_id="${{ inputs.workflow_id }}" | |
echo "https://github.com/${org}/${repo}/actions/runs/${workflow_id}" | |
- name: Determine if MacOS package should be signed | |
if: runner.os == 'macOS' | |
env: | |
PRODUCTBUILD_IDENTITY_NAME: ${{ secrets.productbuild_identity_name }} | |
GH_CI_TOKEN: ${{ secrets.GH_CI_TOKEN }} | |
run: | | |
if [ -n "${PRODUCTBUILD_IDENTITY_NAME}" ]; then | |
echo "MACOS_SIGNING_ENABLED=true" >> $GITHUB_ENV | |
fi | |
- name: Make build directory | |
if: runner.os != 'Linux' | |
run: mkdir build | |
- name: Use GitHub Artifacts for binaries | |
if: ${{ !inputs.use_release_artifacts && inputs.workflow_id != '' }} | |
run: echo "OTC_ARTIFACTS_SOURCE=github-artifacts" >> $GITHUB_ENV | |
# TODO: Go back to using Apple-Actions/import-codesign-certs once https://github.com/Apple-Actions/import-codesign-certs/pull/58 is merged | |
- name: Import macOS Code-Signing Certificates | |
if: ${{ runner.os == 'macOS' && env.MACOS_SIGNING_ENABLED == 'true' }} | |
run: | | |
export p12_filepath=$(mktemp) | |
echo '${{ secrets.apple_developer_certificate_p12_base64 }}' | base64 --decode >${p12_filepath} | |
/usr/bin/security create-keychain -p ${{ secrets.apple_developer_certificate_password }} signing_temp.keychain | |
/usr/bin/security set-keychain-settings -lut 21600 signing_temp.keychain | |
/usr/bin/security unlock-keychain -p ${{ secrets.apple_developer_certificate_password }} signing_temp.keychain | |
/usr/bin/security import ${p12_filepath} -k signing_temp.keychain -f pkcs12 -A -T /usr/bin/codesign -T /usr/bin/security -P ${{ secrets.apple_developer_certificate_password }} | |
/usr/bin/security set-key-partition-list -S apple-tool:,apple: -k ${{ secrets.apple_developer_certificate_password }} signing_temp.keychain | |
/usr/bin/security list-keychains -d user -s signing_temp.keychain login.keychain | |
- name: Build Makefile | |
id: cmake-linux | |
if: runner.os == 'Linux' | |
uses: ./ci/github-actions/cmake | |
with: | |
otc_version: ${{ inputs.otc_version }} | |
otc_sumo_version: ${{ inputs.otc_sumo_version }} | |
otc_build_number: ${{ inputs.otc_build_number }} | |
target: ${{ inputs.cmake_target }} | |
workflow_id: ${{ inputs.workflow_id }} | |
- name: Build Makefile | |
id: cmake-other | |
if: runner.os != 'Linux' | |
env: | |
OTC_VERSION: ${{ inputs.otc_version }} | |
OTC_SUMO_VERSION: ${{ inputs.otc_sumo_version }} | |
OTC_BUILD_NUMBER: ${{ inputs.otc_build_number }} | |
TARGET: ${{ inputs.cmake_target }} | |
PRODUCTBUILD_IDENTITY_NAME: ${{ secrets.productbuild_identity_name }} | |
working-directory: build | |
run: cmake ../ | |
- name: Set simple package outputs | |
id: package | |
env: | |
PACKAGE_NAME: >- | |
${{ | |
steps.cmake-linux.outputs.package_name || | |
steps.cmake-other.outputs.package_name | |
}} | |
run: > | |
echo path="$PACKAGE_NAME" >> $GITHUB_OUTPUT | |
- name: Set simple otc-bin outputs | |
id: bin | |
if: ${{ !inputs.use_release_artifacts && inputs.workflow_id != '' }} | |
env: | |
OTC_BIN: >- | |
${{ | |
steps.cmake-linux.outputs.otc-bin || | |
steps.cmake-other.outputs.otc-bin | |
}} | |
OTC_CONFIG_BIN: >- | |
${{ | |
steps.cmake-linux.outputs.otc-config-bin || | |
steps.cmake-other.outputs.otc-config-bin | |
}} | |
run: > | |
echo otelcol_sumo_path="$OTC_BIN" >> $GITHUB_OUTPUT && | |
echo otelcol_config_path="$OTC_CONFIG_BIN" >> $GITHUB_OUTPUT | |
# Download the artifacts required to build the package target. If | |
# inputs.workflow_id is empty then this will be skipped and CMake will | |
# attempt to fetch the artifacts from a GitHub Release matching | |
# otc_version and otc_sumo_version. | |
- name: Download otelcol-sumo artifact from sumologic-otel-collector | |
uses: dawidd6/[email protected] | |
if: ${{ !inputs.use_release_artifacts && inputs.workflow_id != '' }} | |
with: | |
github_token: ${{ secrets.gh_artifacts_token }} | |
repo: SumoLogic/sumologic-otel-collector | |
run_id: ${{ inputs.workflow_id }} | |
workflow: dev_builds.yml | |
workflow_conclusion: success | |
name: ${{ steps.bin.outputs.otelcol_sumo_path }} | |
path: ./build/gh-artifacts | |
if_no_artifact_found: fail | |
- name: Download otelcol-config artifact from sumologic-otel-collector | |
uses: dawidd6/[email protected] | |
if: inputs.workflow_id != '' | |
with: | |
github_token: ${{ secrets.gh_artifacts_token }} | |
repo: SumoLogic/sumologic-otel-collector | |
run_id: ${{ inputs.workflow_id }} | |
workflow: dev_builds.yml | |
workflow_conclusion: success | |
name: ${{ steps.bin.outputs.otelcol_config_path }} | |
path: ./build/gh-artifacts | |
if_no_artifact_found: fail | |
- name: Build package | |
if: runner.os == 'Linux' | |
uses: ./ci/github-actions/make | |
with: | |
target: package | |
- name: Build package | |
if: runner.os != 'Linux' | |
working-directory: build | |
run: make package | |
- name: Store package as action artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.package.outputs.path }} | |
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) | |
if: inputs.build_tool == 'cmake' | |
needs: build_package | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download macOS package | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ needs.build_package.outputs.package_path }} | |
path: artifacts/ | |
- name: Verify installer | |
if: inputs.cmake_target == 'otc_darwin_amd64_productbuild' | |
run: sudo ./ci/verify_installer.sh "artifacts/${{ needs.build_package.outputs.package_path }}" | |
build_wix_package: | |
runs-on: ${{ inputs.runs_on }} | |
name: Build (WiX) ${{ inputs.fips && 'FIPS' || '' }} | |
if: inputs.build_tool == 'wix' | |
env: | |
PRODUCT_VERSION: ${{ inputs.otc_version }}.${{ inputs.otc_build_number }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Workflow URL for sumologic-otel-collector | |
if: ${{ !inputs.use_release_artifacts && inputs.workflow_id != '' }} | |
run: | | |
org="SumoLogic" | |
repo="sumologic-otel-collector" | |
workflow_id="${{ inputs.workflow_id }}" | |
echo "https://github.com/${org}/${repo}/actions/runs/${workflow_id}" | |
- name: Make build directory | |
run: mkdir build | |
- name: Add msbuild to PATH | |
uses: microsoft/setup-msbuild@v2 | |
- name: Use GitHub Artifacts for binaries | |
if: ${{ !inputs.use_release_artifacts && inputs.workflow_id != '' }} | |
run: echo "OTC_ARTIFACTS_SOURCE=github-artifacts" >> $GITHUB_ENV | |
- name: Determine artifact names | |
run: | | |
echo "OTC_WORKFLOW_ARTIFACT_NAME=otelcol-sumo-${{ inputs.fips && 'fips-' || '' }}windows_${{ inputs.goarch }}.exe" >> $GITHUB_ENV | |
echo "OTC_RELEASE_ARTIFACT_NAME=otelcol-sumo-${{ inputs.otc_version }}-sumo-${{inputs.otc_sumo_version }}-${{ inputs.fips && 'fips-' || '' }}windows_${{ inputs.goarch }}.exe" >> $GITHUB_ENV | |
echo "OTC_BUILD_INPUT_NAME=otelcol-sumo-windows_${{ inputs.goarch }}.exe" >> $GITHUB_ENV | |
# Download the artifacts required to build the package target. If | |
# inputs.workflow_id is empty then this will be skipped and an attempt | |
# will be made to fetch the artifacts from a GitHub Release matching | |
# otc_version and otc_sumo_version. | |
- name: Download artifact from workflow | |
uses: dawidd6/[email protected] | |
if: ${{ !inputs.use_release_artifacts && inputs.workflow_id != '' }} | |
with: | |
github_token: ${{ secrets.gh_artifacts_token }} | |
repo: SumoLogic/sumologic-otel-collector | |
run_id: ${{ inputs.workflow_id }} | |
workflow: dev_builds.yml | |
workflow_conclusion: success | |
name: ${{ env.OTC_WORKFLOW_ARTIFACT_NAME }} | |
path: ./build/artifacts | |
if_no_artifact_found: fail | |
# Download the artifacts, required to build the package target, from a | |
# GitHub Release. | |
- name: Download artifact from GitHub Release | |
uses: robinraju/[email protected] | |
if: ${{ inputs.use_release_artifacts && inputs.workflow_id == '' }} | |
with: | |
repository: SumoLogic/sumologic-otel-collector | |
tag: v${{ inputs.otc_version }}-sumo-${{ inputs.otc_sumo_version }} | |
fileName: ${{ env.OTC_RELEASE_ARTIFACT_NAME }} | |
out-file-path: build/artifacts | |
- name: Rename GitHub Release artifact | |
if: ${{ inputs.use_release_artifacts && inputs.workflow_id == '' }} | |
working-directory: ./build/artifacts | |
env: | |
MV_FROM: ${{ env.OTC_RELEASE_ARTIFACT_NAME }} | |
MV_TO: ${{ env.OTC_BUILD_INPUT_NAME }} | |
run: mv -n "$MV_FROM" "$MV_TO" | |
- name: Rename GitHub Workflow artifact | |
if: ${{ !inputs.use_release_artifacts && inputs.workflow_id != '' }} | |
working-directory: ./build/artifacts | |
env: | |
MV_FROM: ${{ env.OTC_WORKFLOW_ARTIFACT_NAME }} | |
MV_TO: ${{ env.OTC_BUILD_INPUT_NAME }} | |
run: mv -n "$MV_FROM" "$MV_TO" | |
- name: Build MSI | |
id: build | |
working-directory: ./msi/wix | |
env: | |
PLATFORM: ${{ inputs.package_arch }} | |
run: | | |
msbuild.exe -p:Configuration=Release \ | |
-p:Platform=$PLATFORM \ | |
-p:ProductVersion=$PRODUCT_VERSION \ | |
-p:FIPSEnabled=${{ inputs.fips }} \ | |
-Restore | |
PACKAGE_PATH=./msi/wix/$(find bin/${{ inputs.package_arch }}/en-US -name "*.msi") | |
echo "package_path=${PACKAGE_PATH}" >> $GITHUB_OUTPUT | |
echo "package_filename=$(basename ${PACKAGE_PATH})" >> $GITHUB_OUTPUT | |
- name: Sign MSI | |
uses: skymatic/code-sign-action@v3 | |
with: | |
certificate: ${{ secrets.microsoft_certificate }} | |
password: ${{ secrets.microsoft_certificate_password }} | |
certificatesha1: ${{ secrets.microsoft_certhash }} | |
description: ${{ secrets.microsoft_description }} | |
folder: ./msi/wix/bin/${{ inputs.package_arch }}/en-US | |
- name: Store MSI as action artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.build.outputs.package_filename }} | |
path: ${{ steps.build.outputs.package_path }} | |
if-no-files-found: error | |
test_wixext: | |
name: Test (SumoLogic.wixext) | |
if: inputs.build_tool == 'wix' | |
runs-on: windows-2019 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Add msbuild to PATH | |
uses: microsoft/setup-msbuild@v2 | |
- name: Restore NuGet packages | |
working-directory: ./msi/SumoLogic.wixext/SumoLogicTests | |
run: nuget.exe restore -PackagesDirectory ../packages | |
- name: Build unit tests | |
working-directory: ./msi/SumoLogic.wixext/SumoLogicTests | |
run: msbuild.exe -p:Configuration=Release -p:Platform=AnyCPU -Restore | |
- name: Run unit tests | |
working-directory: ./msi/SumoLogic.wixext/SumoLogicTests/bin/Release | |
run: dotnet test -v:n ./SumoLogicTests.dll |