-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: bump chart versions and references automatically (#9)
- Loading branch information
1 parent
bfd6852
commit 36c0856
Showing
5 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
## This job is triggered by the "Release version" of any | ||
## of the tracetest components. When a new version of any tracetest | ||
## component is released, this workflow should be triggered and | ||
## it will update the respective chart with the new release version | ||
## | ||
## | ||
## Required values in the payload: | ||
## * @string project_name | ||
## * @string version | ||
name: Update chart version | ||
|
||
on: | ||
repository_dispatch: | ||
types: [update-chart] | ||
|
||
jobs: | ||
update-chart: | ||
name: Update chart | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Update appVersion | ||
run: | | ||
./scripts/update_chart.sh \ | ||
${{ github.event.client_payload.project_name }} \ | ||
${{ github.event.client_payload.version }} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
commit_and_push() { | ||
message=$1 | ||
|
||
git config --global user.name "GitHub Actions" | ||
git config --global user.email "" | ||
|
||
git commit -m "$message" | ||
git push | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
get_path() { | ||
path=$1 | ||
PWD=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd) | ||
realPath="$PWD/$path" | ||
|
||
echo $realPath | ||
} | ||
|
||
source `get_path ./update_chart_references.sh` | ||
source `get_path ./git.sh` | ||
|
||
# Update the `appVersion` in each chart affected by a new release | ||
# Parameters: | ||
# @string projectName | ||
# @string version | ||
projectName=$1 | ||
version=$2 | ||
|
||
update_chart_references $projectName $version `get_path ./update_chart_instructions.yaml` | ||
|
||
git add `get_path ../charts` | ||
git status | ||
|
||
commit_and_push "Bump chart to version $version" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Define what files/paths needs to be updated with new tag for each repository | ||
# The file paths are relative to `argo/` directory | ||
oss: | ||
- file: charts/tracetest-agent-operator/values.yaml | ||
jsonpath: .config.targetVersion | ||
|
||
core: | ||
- file: charts/tracetest-core/Chart.yaml | ||
jsonpath: .appVersion | ||
|
||
cloud: | ||
- file: charts/tracetest-cloud/Chart.yaml | ||
jsonpath: .appVersion | ||
- file: charts/tracetest-agent-operator/Chart.yaml | ||
jsonpath: .appVersion | ||
- file: charts/tracetest-monitor-operator/Chart.yaml | ||
jsonpath: .appVersion | ||
|
||
frontend: | ||
- file: charts/tracetest-frontend/Chart.yaml | ||
jsonpath: .appVersion | ||
|
||
pokeshop: | ||
- file: charts/pokeshop-demo/Chart.yaml | ||
jsonpath: .appVersion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
|
||
update_chart_references() { | ||
REPO_NAME=$1 | ||
NEW_TAG=$2 | ||
INSTRUCTIONS_FILE=$3 | ||
|
||
instructions=`yq e ".${REPO_NAME}" -o=json "$INSTRUCTIONS_FILE"` | ||
if [[ "$instructions" != "null" ]]; then | ||
echo "$instructions" | jq -c .[] | while read -r line; do | ||
FILE=$(echo $line | jq -r '.file') | ||
JSON_PATH=$(echo $line | jq -r '.jsonpath') | ||
SED_EXPRESSION=$(echo $line | jq -r '.sed_expression // empty') | ||
ABSOLUTE_FILE_PATH=`get_path ../$FILE` | ||
|
||
echo "$FILE:" | ||
echo " JSON path: $JSON_PATH" | ||
|
||
if [[ -n "$SED_EXPRESSION" ]]; then | ||
echo " SED expression: " '"'$SED_EXPRESSION'"' | ||
# Use yq to get the value, and then sed to update it | ||
ORIGINAL_VALUE=$(yq e "$JSON_PATH" "$ABSOLUTE_FILE_PATH") | ||
REPLACED_SED_EXPRESSION=$(echo "$SED_EXPRESSION" | sed "s/{{TAG}}/$NEW_TAG/g") | ||
UPDATED_VALUE=$(echo "$ORIGINAL_VALUE" | sed "$REPLACED_SED_EXPRESSION") | ||
yq e "$JSON_PATH = \"$UPDATED_VALUE\"" -i "$ABSOLUTE_FILE_PATH" | ||
else | ||
# Default handling for direct JSON paths | ||
yq e "$JSON_PATH = \"$NEW_TAG\"" -i "$ABSOLUTE_FILE_PATH" | ||
fi | ||
echo | ||
done | ||
fi | ||
} |