Skip to content

Commit

Permalink
chore(ci): use new version determination (#1699)
Browse files Browse the repository at this point in the history
Signed-off-by: Justin Kolberg <[email protected]>
  • Loading branch information
amdprophet authored Nov 8, 2024
1 parent c17283d commit 1b49351
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 76 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/_get-version-workflow.yml
Original file line number Diff line number Diff line change
@@ -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 }}
23 changes: 5 additions & 18 deletions .github/workflows/dev_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/pull_requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 }}
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/

Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/workflow-build-otelcol-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
16 changes: 13 additions & 3 deletions .github/workflows/workflow-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -46,6 +50,7 @@ defaults:

env:
GO_VERSION: "1.22.6"
VERSION: ${{ inputs.version }}

jobs:
build:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/workflow-trigger-packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 0 additions & 31 deletions ci/_build_functions.sh

This file was deleted.

8 changes: 0 additions & 8 deletions ci/fetch_current_branch.sh

This file was deleted.

2 changes: 1 addition & 1 deletion ci/get_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ declare -i sumo_version

usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [core|sumo|productversion]
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [core|sumo|full|productversion]
Detects the version to use for building otelcol-sumo using a combination of the
otelcol-builder config and Git tags. It can output version information in
Expand Down
4 changes: 2 additions & 2 deletions ci/get_version_from_binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ declare -i sumo_version

usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [otc|sumo] [path/to/otelcol-sumo]
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [core|sumo|productversion] [path/to/otelcol-sumo]
Retrieves the version of an otelcol-sumo binary by parsing the output of
otelcol-sumo's version flag.
Expand Down Expand Up @@ -53,7 +53,7 @@ parse_version() {

output="$(${binary_path} --version)"

regex=".* v([0-9]+)\.([0-9]+)\.([0-9]+)\-sumo\-([0-9]+).*"
regex=".* ([0-9]+)\.([0-9]+)\.([0-9]+)\-sumo\-([0-9]+).*"

if [[ $output =~ $regex ]]; then
major_version="${BASH_REMATCH[1]}"
Expand Down
2 changes: 1 addition & 1 deletion otelcolbuilder/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ install-builder:

.PHONY: _builder
_builder:
$(eval VERSION ?= $(shell ./ci/get_version.sh full | xargs)-$(shell git rev-parse HEAD | xargs))
$(eval VERSION ?= devel-$(shell git rev-parse HEAD | xargs))
# Need to specify go path because otherwise opentelemetry-collector-builder
# uses /usr/bin/go which on Github Actions is using preinstalled 1.15.12 by default.
CGO_ENABLED=$(CGO_ENABLED) $(BUILDER_BIN_NAME) \
Expand Down

0 comments on commit 1b49351

Please sign in to comment.