Skip to content

Commit

Permalink
ci: set version tags for dev builds
Browse files Browse the repository at this point in the history
  • Loading branch information
swiatekm-sumo committed Apr 25, 2024
1 parent 19c9005 commit bd4fa8b
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 40 deletions.
79 changes: 40 additions & 39 deletions .github/workflows/dev_builds.yml
Expand Up @@ -15,6 +15,23 @@ env:

jobs:

get-version:
name: Get application version for this revision
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version
id: get-version
run: |
TAG=$(git describe --tags --abbrev=5 --match "v[0-9]*")
echo "version=${TAG/v}" > $GITHUB_OUTPUT
- name: Print version
run: echo ::notice title=Version::${{ steps.get-version.outputs.version }}

# Add lint to dev builds as that's the only way for cache to be shared across branches.
# https://docs.github.com/en/actions/advanced-guides/caching-dependencies-to-speed-up-workflows#matching-a-cache-key
lint:
Expand Down Expand Up @@ -87,6 +104,7 @@ jobs:
build:
name: Build
uses: ./.github/workflows/workflow-build.yml
needs: [get-version]
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -115,6 +133,7 @@ jobs:
runs-on: ${{ matrix.runs-on }}
fips: ${{ matrix.fips == true }}
save-cache: true
sumo_component_gomod_version: "v${{ needs.get-version.outputs.version }}"
secrets:
apple_developer_certificate_p12_base64: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12_BASE64 }}
apple_developer_certificate_password: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_PASSWORD }}
Expand All @@ -130,19 +149,13 @@ jobs:
runs-on: ubuntu-20.04
needs:
- build
- get-version
strategy:
matrix:
arch_os: [ 'linux_amd64', 'linux_arm64' ]
steps:
- uses: actions/checkout@v4

- name: Extract tag
id: extract_tag
run: echo "tag=$(git rev-parse HEAD)" > $GITHUB_OUTPUT

- name: Print tag
run: echo "Running dev build for ${{ steps.extract_tag.outputs.tag }}"

- name: Set up QEMU
uses: docker/setup-qemu-action@v3.0.0

Expand Down Expand Up @@ -174,15 +187,15 @@ jobs:
run: |
cp otelcol-sumo-fips-${{ matrix.arch_os }} otelcol-sumo
make build-push-container-multiplatform-dev \
BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \
BUILD_TAG=${{ needs.get-version.outputs.version }} \
PLATFORM=${{ matrix.arch_os }} \
BUILD_TYPE_SUFFIX="-fips"
- name: Build and push FIPS images to DockerHub
run: |
cp otelcol-sumo-fips-${{ matrix.arch_os }} otelcol-sumo
make build-push-container-multiplatform-dev \
BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \
BUILD_TAG=${{ needs.get-version.outputs.version }} \
PLATFORM=${{ matrix.arch_os }} \
REPO_URL=sumologic/sumologic-otel-collector-dev \
BUILD_TYPE_SUFFIX="-fips"
Expand All @@ -191,15 +204,15 @@ jobs:
run: |
cp otelcol-sumo-fips-${{ matrix.arch_os }} otelcol-sumo
make build-push-container-ubi-dev \
BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \
BUILD_TAG=${{ needs.get-version.outputs.version }} \
PLATFORM=${{ matrix.arch_os }} \
BUILD_TYPE_SUFFIX="-ubi-fips"
- name: Build and push UBI-based FIPS image to DockerHub
run: |
cp otelcol-sumo-fips-${{ matrix.arch_os }} otelcol-sumo
make build-push-container-ubi-dev \
BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \
BUILD_TAG=${{ needs.get-version.outputs.version }} \
PLATFORM=${{ matrix.arch_os }} \
REPO_URL=sumologic/sumologic-otel-collector-dev \
BUILD_TYPE_SUFFIX="-ubi-fips"
Expand All @@ -213,30 +226,30 @@ jobs:
run: |
cp otelcol-sumo-${{ matrix.arch_os }} otelcol-sumo
make build-push-container-multiplatform-dev \
BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \
BUILD_TAG=${{ needs.get-version.outputs.version }} \
PLATFORM=${{ matrix.arch_os }}
- name: Build and push image to DockerHub
run: |
cp otelcol-sumo-${{ matrix.arch_os }} otelcol-sumo
make build-push-container-multiplatform-dev \
BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \
BUILD_TAG=${{ needs.get-version.outputs.version }} \
PLATFORM=${{ matrix.arch_os }} \
REPO_URL=sumologic/sumologic-otel-collector-dev
- name: Build and push UBI-based image to Open Source ECR
run: |
cp otelcol-sumo-${{ matrix.arch_os }} otelcol-sumo
make build-push-container-ubi-dev \
BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \
BUILD_TAG=${{ needs.get-version.outputs.version }} \
PLATFORM=${{ matrix.arch_os }} \
BUILD_TYPE_SUFFIX="-ubi"
- name: Build and push UBI-based image to DockerHub
run: |
cp otelcol-sumo-${{ matrix.arch_os }} otelcol-sumo
make build-push-container-ubi-dev \
BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \
BUILD_TAG=${{ needs.get-version.outputs.version }} \
PLATFORM=${{ matrix.arch_os }} \
REPO_URL=sumologic/sumologic-otel-collector-dev \
BUILD_TYPE_SUFFIX="-ubi"
Expand All @@ -246,6 +259,7 @@ jobs:
runs-on: ${{ matrix.runs-on }}
needs:
- build
- get-version
strategy:
matrix:
include:
Expand All @@ -258,13 +272,6 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Extract tag
id: extract_tag
run: echo "tag=$(git rev-parse HEAD)" > $GITHUB_OUTPUT

- name: Print tag
run: echo "Running dev build for ${{ steps.extract_tag.outputs.tag }}"

- name: Login to Open Source ECR
run: |
USERNAME=$(powershell.exe "echo \$Env:UserName")
Expand Down Expand Up @@ -292,14 +299,14 @@ jobs:
run: |
cp artifacts/otelcol-sumo-${{matrix.arch_os}}.exe otelcol-sumo.exe
make build-push-container-windows-dev \
BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \
BUILD_TAG=${{ needs.get-version.outputs.version }} \
PLATFORM=${{ matrix.arch_os }}_${{ matrix.base_image_tag }}
- name: Build and push images to DockerHub
run: |
cp artifacts/otelcol-sumo-${{matrix.arch_os}}.exe otelcol-sumo.exe
make build-push-container-windows-dev \
BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \
BUILD_TAG=${{ needs.get-version.outputs.version }} \
REPO_URL=sumologic/sumologic-otel-collector-dev \
PLATFORM=${{ matrix.arch_os }}_${{ matrix.base_image_tag }}
Expand All @@ -309,16 +316,10 @@ jobs:
needs:
- build-container-images
- build-windows-container-images
- get-version
steps:
- uses: actions/checkout@v4

- name: Extract tag
id: extract_tag
run: echo "tag=$(git rev-parse HEAD)" > $GITHUB_OUTPUT

- name: Print tag
run: echo "Running dev build for ${{ steps.extract_tag.outputs.tag }}"

- name: Set up QEMU
uses: docker/setup-qemu-action@v3.0.0

Expand All @@ -344,57 +345,57 @@ jobs:
- name: Push joint FIPS container manifest for all platforms to Open Source ECR
run: |
make push-container-manifest-dev \
BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \
BUILD_TAG=${{ needs.get-version.outputs.version }} \
PLATFORMS="linux/amd64" \
BUILD_TYPE_SUFFIX="-fips"
- name: Push joint FIPS container manifest for all platforms to DockerHub
run: |
make push-container-manifest-dev \
BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \
BUILD_TAG=${{ needs.get-version.outputs.version }} \
PLATFORMS="linux/amd64" \
REPO_URL=sumologic/sumologic-otel-collector-dev \
BUILD_TYPE_SUFFIX="-fips"
- name: Push joint UBI-based FIPS container manifest for all platforms to Open Source ECR
run: |
make push-container-manifest-dev \
BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \
BUILD_TAG=${{ needs.get-version.outputs.version }} \
PLATFORMS="linux/amd64" \
BUILD_TYPE_SUFFIX="-ubi-fips"
- name: Push joint UBI-based FIPS container manifest for all platforms to DockerHub
run: |
make push-container-manifest-dev \
BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \
BUILD_TAG=${{ needs.get-version.outputs.version }} \
PLATFORMS="linux/amd64" \
REPO_URL=sumologic/sumologic-otel-collector-dev \
BUILD_TYPE_SUFFIX="-ubi-fips"
- name: Push joint container manifest for all platforms to Open Source ECR
run: |
make push-container-manifest-dev \
BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \
BUILD_TAG=${{ needs.get-version.outputs.version }} \
PLATFORMS="linux/amd64 linux/arm64 windows/amd64/ltsc2022 windows/amd64/ltsc2019"
- name: Push joint container manifest for all platforms to DockerHub
run: |
make push-container-manifest-dev \
BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \
BUILD_TAG=${{ needs.get-version.outputs.version }} \
PLATFORMS="linux/amd64 linux/arm64 windows/amd64/ltsc2022 windows/amd64/ltsc2019" \
REPO_URL=sumologic/sumologic-otel-collector-dev
- name: Push joint UBI-based container manifest for all platforms to Open Source ECR
run: |
make push-container-manifest-dev \
BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \
BUILD_TAG=${{ needs.get-version.outputs.version }} \
PLATFORMS="linux/amd64" \
BUILD_TYPE_SUFFIX="-ubi"
- name: Push joint UBI-based container manifest for all platforms to DockerHub
run: |
make push-container-manifest-dev \
BUILD_TAG=${{ steps.extract_tag.outputs.tag }} \
BUILD_TAG=${{ needs.get-version.outputs.version }} \
PLATFORMS="linux/amd64" \
REPO_URL=sumologic/sumologic-otel-collector-dev \
BUILD_TYPE_SUFFIX="-ubi"
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/workflow-build.yml
Expand Up @@ -7,6 +7,10 @@ on:
description: Architecture and OS in the form "{arch}_{os}". See GOARCH and GOOS for accepted values.
default: linux_amd64
type: string
sumo_component_gomod_version:
description: Package version for components hosted in this repo. Normally, this is the v0.0.0-00010101000000-000000000000 placeholder.
type: string
required: false
fips:
description: Build binary with FIPS support
default: false
Expand Down Expand Up @@ -80,6 +84,10 @@ jobs:
echo "/d/a/_work/1/s/go/bin" >> $GITHUB_PATH &&
powershell -command "Set-ItemProperty -Path HKLM:\System\CurrentControlSet\Control\Lsa\FipsAlgorithmPolicy -Name Enabled -Value \$true"
- name: Set Sumo component version in go.mod
if: inputs.sumo_component_gomod_version != ''
run: make prepare-tag TAG=${{ inputs.sumo_component_gomod_version }}

- name: Get Go env values
run: |
echo "GOMODCACHE=$(go env GOMODCACHE)" >> "$GITHUB_ENV"
Expand Down Expand Up @@ -217,7 +225,7 @@ jobs:

- name: Store Mac .dmg as action artifact
uses: actions/upload-artifact@v4
if: ${{ runner.os == 'macOS' }}
if: runner.os == 'macOS' && env.MACOS_SIGNING_ENABLED == 'true'
with:
name: ${{ steps.set-binary-name.outputs.binary_name }}.dmg
path: ./otelcolbuilder/cmd/${{ steps.set-binary-name.outputs.binary_name }}.dmg
Expand Down

0 comments on commit bd4fa8b

Please sign in to comment.