From bd4fa8b81cffd260f96fa967f6c49cd8539413a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20=C5=9Awi=C4=85tek?= Date: Wed, 24 Apr 2024 20:48:09 +0200 Subject: [PATCH] ci: set version tags for dev builds --- .github/workflows/dev_builds.yml | 79 ++++++++++++++-------------- .github/workflows/workflow-build.yml | 10 +++- 2 files changed, 49 insertions(+), 40 deletions(-) diff --git a/.github/workflows/dev_builds.yml b/.github/workflows/dev_builds.yml index ef8ea7bb3b..93d859f08a 100644 --- a/.github/workflows/dev_builds.yml +++ b/.github/workflows/dev_builds.yml @@ -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: @@ -87,6 +104,7 @@ jobs: build: name: Build uses: ./.github/workflows/workflow-build.yml + needs: [get-version] strategy: fail-fast: false matrix: @@ -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 }} @@ -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 @@ -174,7 +187,7 @@ 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" @@ -182,7 +195,7 @@ 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 }} \ REPO_URL=sumologic/sumologic-otel-collector-dev \ BUILD_TYPE_SUFFIX="-fips" @@ -191,7 +204,7 @@ 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" @@ -199,7 +212,7 @@ 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 }} \ REPO_URL=sumologic/sumologic-otel-collector-dev \ BUILD_TYPE_SUFFIX="-ubi-fips" @@ -213,14 +226,14 @@ 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 @@ -228,7 +241,7 @@ jobs: 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" @@ -236,7 +249,7 @@ jobs: 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" @@ -246,6 +259,7 @@ jobs: runs-on: ${{ matrix.runs-on }} needs: - build + - get-version strategy: matrix: include: @@ -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") @@ -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 }} @@ -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 @@ -344,14 +345,14 @@ 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" @@ -359,14 +360,14 @@ jobs: - 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" @@ -374,27 +375,27 @@ jobs: - 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" diff --git a/.github/workflows/workflow-build.yml b/.github/workflows/workflow-build.yml index 9c17d79215..256696d5f7 100644 --- a/.github/workflows/workflow-build.yml +++ b/.github/workflows/workflow-build.yml @@ -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 @@ -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" @@ -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