diff --git a/.github/workflows/_get-version-workflow.yml b/.github/workflows/_get-version-workflow.yml new file mode 100644 index 0000000000..280bec31df --- /dev/null +++ b/.github/workflows/_get-version-workflow.yml @@ -0,0 +1,32 @@ +name: Get next available version + +on: + workflow_call: + outputs: + version: + description: "The next unused version to use" + value: ${{ jobs.get-version.outputs.version }} + +defaults: + run: + shell: bash + +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: | + version=$(./ci/get_version.sh full | xargs)-$(git rev-parse HEAD | xargs) + echo "version=${version}" > $GITHUB_OUTPUT + + - name: Print version + run: echo ::notice title=Version::${{ steps.get-version.outputs.version }} diff --git a/.github/workflows/dev_builds.yml b/.github/workflows/dev_builds.yml index 03095188c0..ce34024609 100644 --- a/.github/workflows/dev_builds.yml +++ b/.github/workflows/dev_builds.yml @@ -14,23 +14,6 @@ env: GO_VERSION: "1.22.6" 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: @@ -119,6 +102,10 @@ jobs: save-cache: true boringcrypto: ${{ matrix.boringcrypto == true }} + get-version: + name: Get next available version + uses: ./.github/workflows/_get-version-workflow.yml + build: name: Build uses: ./.github/workflows/workflow-build.yml @@ -151,7 +138,7 @@ jobs: runs-on: ${{ matrix.runs-on }} fips: ${{ matrix.fips == true }} save-cache: true - sumo_component_gomod_version: "v${{ needs.get-version.outputs.version }}" + version: ${{ 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 }} diff --git a/.github/workflows/pull_requests.yml b/.github/workflows/pull_requests.yml index 6de4938012..e00ddae670 100644 --- a/.github/workflows/pull_requests.yml +++ b/.github/workflows/pull_requests.yml @@ -223,9 +223,14 @@ jobs: - name: Run staticcheck run: make golint + get-version: + name: Get next available version + uses: ./.github/workflows/_get-version-workflow.yml + build: name: Build uses: ./.github/workflows/workflow-build.yml + needs: [get-version] strategy: matrix: include: @@ -249,6 +254,7 @@ jobs: arch_os: ${{ matrix.arch_os }} runs-on: ${{ matrix.runs-on }} fips: ${{ matrix.fips == true }} + version: ${{ 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 }} diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml index b7009fdcdc..d56a28f4df 100644 --- a/.github/workflows/releases.yml +++ b/.github/workflows/releases.yml @@ -315,9 +315,6 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Fetch current branch - run: ./ci/fetch_current_branch.sh - - name: Archive Chef cookbook run: tar -cvf ./examples/chef/chef-cookbook.tar.gz -C ./examples/chef sumologic-otel-collector/ diff --git a/.github/workflows/workflow-build-otelcol-config.yml b/.github/workflows/workflow-build-otelcol-config.yml index 4f60e5d858..62ebf9e9ce 100644 --- a/.github/workflows/workflow-build-otelcol-config.yml +++ b/.github/workflows/workflow-build-otelcol-config.yml @@ -46,9 +46,6 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Fetch current branch - run: ./ci/fetch_current_branch.sh - - name: Setup go uses: actions/setup-go@v5 with: diff --git a/.github/workflows/workflow-build.yml b/.github/workflows/workflow-build.yml index 11f77d5239..5f8a4d9b08 100644 --- a/.github/workflows/workflow-build.yml +++ b/.github/workflows/workflow-build.yml @@ -22,6 +22,10 @@ on: description: Save the module and build caches. default: false type: boolean + version: + description: Version to use when building the binary + required: true + type: string secrets: apple_developer_certificate_p12_base64: required: false @@ -46,6 +50,7 @@ defaults: env: GO_VERSION: "1.22.6" + VERSION: ${{ inputs.version }} jobs: build: @@ -57,9 +62,6 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Fetch current branch - run: ./ci/fetch_current_branch.sh - - name: Determine if MacOS package should be signed if: runner.os == 'macOS' env: @@ -186,6 +188,14 @@ jobs: go tool nm ${{ steps.set-binary-name.outputs.binary_name }} | \ grep "vendor/github.com/microsoft/go-crypto-winnative/internal/bcrypt.GetFipsAlgorithmMode" + - name: Verify binary version + if: inputs.arch_os == 'linux_amd64' || inputs.arch_os == 'darwin_amd64' + run: | + binary=${{ steps.set-binary-name.outputs.binary_name }} + binary_path=otelcolbuilder/cmd/${binary} + ./ci/get_version_from_binary.sh otc "${binary_path}" + ./ci/get_version_from_binary.sh sumo "${binary_path}" + - uses: apple-actions/import-codesign-certs@v3 if: ${{ runner.os == 'macOS' && env.MACOS_SIGNING_ENABLED == 'true' }} with: diff --git a/.github/workflows/workflow-trigger-packaging.yml b/.github/workflows/workflow-trigger-packaging.yml index 0f4892f5e1..dd043e014f 100644 --- a/.github/workflows/workflow-trigger-packaging.yml +++ b/.github/workflows/workflow-trigger-packaging.yml @@ -20,12 +20,6 @@ jobs: name: Trigger Packaging runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - filter: 'tree:0' - # TODO: output the workflow url - name: Trigger packaging workflow id: trigger-packaging-workflow diff --git a/ci/_build_functions.sh b/ci/_build_functions.sh deleted file mode 100755 index 509a160b33..0000000000 --- a/ci/_build_functions.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bash - -# shellcheck disable=SC2154 - -err_report() { - echo "Script error on line $1" - exit 1 -} -trap 'err_report $LINENO' ERR - -function fetch_current_branch() { - # No need to fetch when we can already do 'git describe ...' - git describe --tags >/dev/null && return - - # No need to fetch full history with: - # git fetch --tags --unshallow - # Just fetch the current branch and its tags so that git describe works. - local BRANCH - BRANCH="$(git rev-parse --abbrev-ref HEAD)" - - # Need to check if repo is shallow because: - # "fatal: --unshallow on a complete repository does not make sense" - # and we need to unshallow the repository because otherwise we'd get: - # fatal: No tags can describe ''. - # Try --always, or create some tags. - if [[ "true" == "$(git rev-parse --is-shallow-repository)" ]]; then - git fetch -v --tags --unshallow origin "${BRANCH}" - else - git fetch -v --tags origin "${BRANCH}" - fi -} diff --git a/ci/fetch_current_branch.sh b/ci/fetch_current_branch.sh deleted file mode 100755 index b0b06aad0e..0000000000 --- a/ci/fetch_current_branch.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -ROOT_DIR="$(dirname "$(dirname "${0}")")" -readonly ROOT_DIR -# shellcheck disable=SC1090 -source "${ROOT_DIR}"/ci/_build_functions.sh - -fetch_current_branch diff --git a/ci/get_version.sh b/ci/get_version.sh index 3ae74f1833..3afd84ddb6 100755 --- a/ci/get_version.sh +++ b/ci/get_version.sh @@ -7,7 +7,7 @@ declare -i sumo_version usage() { cat <