Skip to content

Commit

Permalink
ci: only use workflow_id for building packages
Browse files Browse the repository at this point in the history
Signed-off-by: Justin Kolberg <[email protected]>
  • Loading branch information
amdprophet committed Oct 31, 2024
1 parent f939d71 commit a65a9c2
Show file tree
Hide file tree
Showing 21 changed files with 440 additions and 487 deletions.
146 changes: 42 additions & 104 deletions .github/workflows/_reusable_build_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ 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
Expand All @@ -18,10 +12,6 @@ on:
workflow_id:
required: false
type: string
use_release_artifacts:
required: false
type: boolean
default: false
runs_on:
required: true
type: string
Expand Down Expand Up @@ -80,7 +70,7 @@ jobs:
- name: Download packagecloud-go tool
run: |
baseURL="https://github.com/amdprophet/packagecloud-go/releases/download"
version="0.1.5"
version="0.2.2"
file="packagecloud-go_${version}_linux_amd64.tar.gz"
curl -Lo /tmp/packagecloud-go.tar.gz $baseURL/$version/$file
Expand All @@ -90,7 +80,6 @@ jobs:
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"
Expand All @@ -111,10 +100,6 @@ jobs:
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' }}
Expand All @@ -128,13 +113,28 @@ jobs:
/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: Fetch version artifact
if: runner.os == 'Linux'
uses: ./ci/github-actions/cmake
with:
args: -P version_artifact.cmake
gh_token: ${{ secrets.gh_artifacts_token }}
workflow_id: ${{ inputs.workflow_id }}
work_dir: .

- name: Fetch version artifact
if: runner.os != 'Linux'
env:
GH_TOKEN: ${{ secrets.gh_artifacts_token }}
GH_WORKFLOW_ID: ${{ inputs.workflow_id }}
run: cmake -P version_artifact.cmake

- 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 }}
gh_token: ${{ secrets.gh_artifacts_token }}
otc_build_number: ${{ inputs.otc_build_number }}
target: ${{ inputs.cmake_target }}
workflow_id: ${{ inputs.workflow_id }}
Expand All @@ -143,11 +143,11 @@ jobs:
id: cmake-other
if: runner.os != 'Linux'
env:
OTC_VERSION: ${{ inputs.otc_version }}
OTC_SUMO_VERSION: ${{ inputs.otc_sumo_version }}
GH_TOKEN: ${{ secrets.gh_artifacts_token }}
GH_WORKFLOW_ID: ${{ inputs.workflow_id }}
OTC_BUILD_NUMBER: ${{ inputs.otc_build_number }}
TARGET: ${{ inputs.cmake_target }}
PRODUCTBUILD_IDENTITY_NAME: ${{ secrets.productbuild_identity_name }}
TARGET: ${{ inputs.cmake_target }}
working-directory: build
run: cmake ../

Expand All @@ -162,62 +162,17 @@ jobs:
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:
gh_token: ${{ secrets.gh_artifacts_token }}
target: package

- name: Build package
if: runner.os != 'Linux'
env:
GH_TOKEN: ${{ secrets.gh_artifacts_token }}
working-directory: build
run: make package

Expand All @@ -233,7 +188,7 @@ jobs:
uses: ./ci/github-actions/make
with:
target: publish-package
packagecloud-token: ${{ secrets.PACKAGECLOUD_TOKEN }}
packagecloud_token: ${{ secrets.PACKAGECLOUD_TOKEN }}

test_package:
runs-on: ${{ inputs.runs_on }}
Expand All @@ -258,14 +213,11 @@ jobs:
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"
Expand All @@ -278,54 +230,39 @@ jobs:
- 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: Fetch version artifact
env:
GH_TOKEN: ${{ secrets.gh_artifacts_token }}
GH_WORKFLOW_ID: ${{ inputs.workflow_id }}
shell: cmd
run: cmake -P version_artifact.cmake

- name: Determine version from binary
id: determine_version
working-directory: ./build/version_detection
run: >
version=$(./otelcol-sumo.exe --version |
sed -E -n 's/.* v([0-9]+\.[0-9]+\.[0-9]+)\-sumo.*/\1/p') &&
echo product_version="${version}.${{ inputs.otc_build_number }}" >> $GITHUB_OUTPUT
- 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
# Download the artifacts required to build the package target.
- name: Download otelcol-sumo 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 }}
Expand All @@ -337,6 +274,7 @@ jobs:
working-directory: ./msi/wix
env:
PLATFORM: ${{ inputs.package_arch }}
PRODUCT_VERSION: ${{ steps.determine_version.outputs.product_version }}
run: |
msbuild.exe -p:Configuration=Release \
-p:Platform=$PLATFORM \
Expand Down
Loading

0 comments on commit a65a9c2

Please sign in to comment.