Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Github Worfklow coverage to update values.yaml and Chart.yaml dependency versions #852

Merged
merged 4 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/update_chart_dependencies.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Check for new chart dependency updates

on:
schedule:
# Run every Monday at noon.
- cron: "0 12 * * 1"
workflow_dispatch:

env:
CHART_YAML: helm-charts/splunk-otel-collector/Chart.yaml

jobs:
maybe_update:
runs-on: ubuntu-latest
strategy:
matrix:
# Currently this worfklow will update the listed dependencies in the Chart.yaml
repo: ['cert-manager', 'opentelemetry-operator'] # Add other repos here
steps:
- uses: actions/[email protected]
- name: Update Chart
id: update_chart
run: |
# Run make repo-update to ensure repositories are up-to-date
make repo-update

# Fetch the latest version using helm search repo
LATEST_VER=$(helm search repo ${{ matrix.repo }} --versions | awk 'NR==2{print $2}')
echo "LATEST_VER=$LATEST_VER" >> $GITHUB_OUTPUT

# Retrieve the current version from chart.yaml
DEP_PATH=$(yq eval ".dependencies[] | select(.name == \"${{ matrix.repo }}\") | .version" $CHART_YAML)

echo "Current version of ${{ matrix.repo }} is $DEP_PATH, latest is $LATEST_VER"

if [ "$LATEST_VER" == "$DEP_PATH" ]; then
echo We are already up to date. Nothing else to do.
else
echo 'Looks like we need to update...'
echo Updating to new version in chart.yaml
echo "NEED_UPDATE=1" >> $GITHUB_OUTPUT

# Update the version in chart.yaml using yq and jq
DEP_LINE=$(yq eval ".dependencies | keys | map(tonumber) | map(select(. != null)) | map(select(. < 10000)) | map(. + 1)" $CHART_YAML | jq ".[] | select(.[\"name\"] == \"${{ matrix.repo }}\")")
sed -i "${DEP_LINE}s/$DEP_PATH/$LATEST_VER/" $CHART_YAML
jinja2 marked this conversation as resolved.
Show resolved Hide resolved

echo Updating rendered examples
make render

echo "Current git diff:"
git --no-pager diff
fi
- name: PR the new version
if: ${{ steps.update_chart.outputs.NEED_UPDATE == 1 }}
uses: peter-evans/create-pull-request@v5
with:
commit-message: Update ${{ matrix.repo }} chart version
title: Update ${{ matrix.repo }} chart version to ${{ steps.update_chart.outputs.LATEST_VER }}
body: Use the new version of the ${{ matrix.repo }} chart
branch: "update-${{ matrix.repo }}-${{ steps.update_chart.outputs.LATEST_VER }}"
base: main
delete-branch: true
modify-outputs: false
42 changes: 23 additions & 19 deletions .github/workflows/update_instrumentation_dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ name: Check for new instrumentation versions

on:
schedule:
- cron: "45 */4 * * *"
# Run every 12th hour at minute 45 past.
- cron: "45 */12 * * *"
workflow_dispatch:

env:
Expand All @@ -14,6 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
# Currently this workflow will update the listed operator instrumentatipon dependencies in values.yaml
jvoravong marked this conversation as resolved.
Show resolved Hide resolved
language: ['java'] # Add other languages here
steps:
- uses: actions/[email protected]
Expand All @@ -25,37 +27,39 @@ jobs:
LATEST_VER=$(curl -qs -H "Accept: application/vnd.github+json" $(echo $LATEST_API | sed "s/{lang}/${{ matrix.language }}/g") | jq -r .tag_name)
echo "LATEST_VER=$LATEST_VER" >> $GITHUB_OUTPUT
echo "Current version of ${{ matrix.language }} is $LOCAL_VER, latest is $LATEST_VER"

if [ "$LATEST_VER" == "$LOCAL_VER" ]; then
echo We are already up to date. Nothing else to do.
else
echo 'Verifying that the image is pullable...'
echo '(If this fails, the agent version is out of sync with ghcr version)'
echo '(If this fails, the image version is out of sync with ghcr version)'
docker pull $REPO:$LATEST_VER
echo 'Looks like we are good to update...'
echo Updating to new version
echo Updating to new version in values.yaml
echo "NEED_UPDATE=1" >> $GITHUB_OUTPUT
VLINE=$(grep -n $REPO $VALUES_YAML | cut -f1 -d:)
echo sed -i "${VLINE}s|:${LOCAL_VER}|:${LATEST_VER}|" $VALUES_YAML
sed -i "${VLINE}s|:${LOCAL_VER}|:${LATEST_VER}|" $VALUES_YAML
VLINE=$(grep -n "${REPO}" $VALUES_YAML | cut -f1 -d:)
echo "Line number for ${REPO} in ${VALUES_YAML} is: ${VLINE}"
OLD_VER=$(sed -n "${VLINE}p" $VALUES_YAML | grep -oP 'v\K[0-9.]+')
echo "Old version number is: ${OLD_VER}"
NEW_VER=${LATEST_VER#v} # removes 'v' from the start of the string
echo "New version number is: ${NEW_VER}"
echo "sed: ${VLINE}s/${OLD_VER}/${NEW_VER}/"
sed -i "${VLINE}s/${OLD_VER}/${NEW_VER}/" $VALUES_YAML

echo Render chart template
make render

echo "Current git diff:"
git --no-pager diff
fi
- name: render some templates
if: ${{ steps.swizzle_version.outputs.NEED_UPDATE == 1 }}
run: |
echo Making the templates
curl https://baltocdn.com/helm/signing.asc | gpg --dearmor | sudo tee /usr/share/keyrings/helm.gpg > /dev/null
sudo apt install -y apt-transport-https
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/helm.gpg] https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list
sudo apt update
sudo apt install -y build-essential zip helm gh
make render
git --no-pager diff
- name: PR the new version
if: ${{ steps.swizzle_version.outputs.NEED_UPDATE == 1 }}
uses: peter-evans/create-pull-request@v5
with:
commit-message: Update ${{ matrix.language }} instrumentation version
title: Update ${{ matrix.language }} agent version to ${{ steps.swizzle_version.outputs.LATEST_VER }}
body: Use the new version of the ${{ matrix.language }} instrumentation library
title: Update ${{ matrix.language }} instrumentation version to ${{ steps.swizzle_version.outputs.LATEST_VER }}
body: Use the new version of the ${{ matrix.language }} instrumentation
branch: "update-${{ matrix.language }}-${{ steps.swizzle_version.outputs.LATEST_VER }}"
base: main
delete-branch: true
modify-outputs: false
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Update PodDisruptionBudgets API version to allow both `policy/v1beta1` and `policy/v1` [#835](https://github.com/signalfx/splunk-otel-collector-chart/pull/835)
- Update clusterrole to allow collector to check for the `aws-auth` configmap in EKS clusters [#840](https://github.com/signalfx/splunk-otel-collector-chart/pull/840)
- Add support to create default Instrumentation for operator based auto-instrumentation [#836](https://github.com/signalfx/splunk-otel-collector-chart/pull/836)
- Add Github workflow coverage to update values.yaml and Chart.yaml dependency versions [#852](https://github.com/signalfx/splunk-otel-collector-chart/pull/852)
jvoravong marked this conversation as resolved.
Show resolved Hide resolved

## [0.80.0] - 2023-06-27

Expand Down
5 changes: 0 additions & 5 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ of `version` field.

To make a new release of the helm chart:
1. Bump the chart `version` in [Chart.yaml](helm-charts/splunk-otel-collector/Chart.yaml)
1. Bump dependencies versions as needed
- Look for new releases
- https://cert-manager.io/docs/installation/supported-releases/
- https://github.com/open-telemetry/opentelemetry-operator/releases
- Increment versions under `dependencies` in [Chart.yaml](helm-charts/splunk-otel-collector/Chart.yaml#)
1. Run `make render` to update Helm dependencies and render all the examples with the latest changes.
1. Create PR and request review from the team.
1. When the PR gets merged, the release will automatically be made and the helm repo updated.
Expand Down
Loading