Skip to content

Commit

Permalink
ci: update script to allow no op on rc tags
Browse files Browse the repository at this point in the history
Signed-off-by: Abhinandan Purkait <[email protected]>
  • Loading branch information
Abhinandan-Purkait committed Jul 22, 2024
1 parent da38d75 commit 230b109
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/branch_preparation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
tag=${{ github.ref_name }}
echo "BASE=$(nix-shell --pure --run "./scripts/update-chart-version.sh --tag $tag --type develop" ./shell.nix)" >> $GITHUB_ENV
- name: Create Pull Request to develop
if: ${{ env.BASE }}
id: cpr
uses: peter-evans/create-pull-request@v5
with:
Expand Down Expand Up @@ -67,6 +68,7 @@ jobs:
tag=${{ github.ref_name }}
echo "BASE=$(nix-shell --pure --run "./scripts/update-chart-version.sh --tag $tag --type release" ./shell.nix)" >> $GITHUB_ENV
- name: Create Pull Request to release
if: ${{ env.BASE }}
id: cpr
uses: peter-evans/create-pull-request@v5
with:
Expand Down
8 changes: 8 additions & 0 deletions scripts/test-update-chart-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,11 @@ run_test "Test 6: Valid tag with type develop [patch release]" \
run_test "Test 7: Invalid tag format" \
"Invalid tag format. Expected 'vX.Y.Z'" \
--tag "1.2.3" --type "release" --dry-run

run_test "Test 8: Supply an rc tag, with release type" \
"" \
--tag "v1.2.3-rc" --type "release" --dry-run

run_test "Test 9: Supply an rc tag, with develop type" \
"" \
--tag "v1.2.3-rc" --type "develop" --dry-run
20 changes: 13 additions & 7 deletions scripts/update-chart-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ create_version_from_release_branch() {
if [[ "$CURRENT_CHART_VERSION" == *"-develop" ]]; then
VERSION="${EXTRACTED_VERSION}.0-prerelease"
elif [[ "$CURRENT_CHART_VERSION" == *"-prerelease" ]]; then
VERSION=$CURRENT_CHART_VERSION
NO_OP=1
else
die "Current chart version doesn't match a develop or prerel format"
fi
Expand All @@ -74,6 +74,8 @@ create_version_from_tag() {
else
die "Invalid type. Expected 'release' or 'develop'."
fi
elif [[ "$TAG" == *"-rc" ]]; then
NO_OP=1
else
die "Invalid tag format. Expected 'vX.Y.Z'"
fi
Expand All @@ -91,6 +93,8 @@ update_chart_yaml() {

set -euo pipefail

DRY_RUN=
NO_OP=
# Set the path to the Chart.yaml file
SCRIPT_DIR="$(dirname "$(realpath "${BASH_SOURCE[0]:-"$0"}")")"
ROOT_DIR="$SCRIPT_DIR/.."
Expand Down Expand Up @@ -144,12 +148,14 @@ else
die "Either --branch or --tag and --type must be specified."
fi

if [[ -n $VERSION ]]; then
if [[ -z $DRY_RUN ]];then
update_chart_yaml "$VERSION" "$VERSION"
if [[ -z $NO_OP ]]; then
if [[ -n $VERSION ]]; then
if [[ -z $DRY_RUN ]];then
update_chart_yaml "$VERSION" "$VERSION"
else
echo "$VERSION"
fi
else
echo "$VERSION"
die "Failed to update the chart versions"
fi
else
die "Failed to update the chart versions"
fi

0 comments on commit 230b109

Please sign in to comment.