Skip to content

Commit

Permalink
chore(bors): merge pull request #546
Browse files Browse the repository at this point in the history
546: Cherry Pick PR 545 to develop r=tiagolobocastro a=tiagolobocastro

    build: update control-plane dep
    
    Signed-off-by: Tiago Castro <[email protected]>



Co-authored-by: Tiago Castro <[email protected]>
  • Loading branch information
mayastor-bors and tiagolobocastro committed Sep 23, 2024
2 parents 5bed79b + 4b8f616 commit abff840
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 9 deletions.
56 changes: 54 additions & 2 deletions .github/workflows/release-chart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,67 @@ jobs:
# Publish the Chart.yaml locally
# Note this does not commit the Chart.yaml changes this the branch
nix-shell --pure --run "./scripts/helm/publish-chart-yaml.sh --app-tag "$tag"" ./scripts/helm/shell.nix
echo "PUBLISH_CHART=1" >> $GITHUB_ENV
else
branch="${{ github.ref_name }}"
nix-shell --pure --run "./scripts/helm/publish-chart-yaml.sh --check-chart "$branch"" ./scripts/helm/shell.nix
fi
nix-shell --pure --run "SKIP_GIT=1 ./scripts/helm/generate-readme.sh" ./scripts/helm/shell.nix
- name: Publish Mayastor Helm chart
uses: stefanprodan/[email protected]
if: ${{ env.PUBLISH_CHART }}
if: ${{ github.ref_type == 'tag' }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
charts_dir: .

update-chart:
runs-on: ubuntu-latest
if: ${{ github.ref_type == 'tag' }}
needs:
- release-chart
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: cachix/install-nix-action@v22
- name: Pre-populate nix-shell
run: |
export NIX_PATH=nixpkgs=$(jq '.nixpkgs.url' nix/sources.json -r)
echo "NIX_PATH=$NIX_PATH" >> $GITHUB_ENV
nix-shell --pure --run "echo" ./scripts/helm/shell.nix
- name: Publish locally in the workspace
run: |
tag="${{ github.ref_name }}"
nix-shell --pure --run "./scripts/helm/publish-chart-yaml.sh --released "$tag"" ./scripts/helm/shell.nix
nix-shell --pure --run "SKIP_GIT=1 ./scripts/helm/generate-readme.sh" ./scripts/helm/shell.nix
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v5
with:
commit-message: "chore(ci): update future helm chart versions"
committer: GitHub <[email protected]>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
title: Bump future helm chart version on the release branch
labels: |
update-release-branch
automated-pr
draft: false
signoff: true
token: ${{ secrets.ORG_CI_GITHUB }}
- name: Approve Pull Request by CI Bot
if: ${{ steps.cpr.outputs.pull-request-number }}
run: |
gh pr review ${{ steps.cpr.outputs.pull-request-number }} --approve
env:
GH_TOKEN: ${{ github.token }}
- name: Approve Pull Request by CI User
if: ${{ steps.cpr.outputs.pull-request-number }}
run: |
gh pr review ${{ steps.cpr.outputs.pull-request-number }} --approve
env:
GH_TOKEN: ${{ secrets.ORG_CI_GITHUB_2 }}
- name: Bors Merge Pull Request
if: ${{ steps.cpr.outputs.pull-request-number }}
run: |
gh pr comment ${{ steps.cpr.outputs.pull-request-number }} --body "bors merge"
env:
GH_TOKEN: ${{ secrets.ORG_CI_GITHUB }}
2 changes: 1 addition & 1 deletion chart/.helmignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
.idea/
*.tmproj
.vscode/
*.md
README.md.tmpl
# Nix Shell
*.nix
50 changes: 46 additions & 4 deletions scripts/helm/publish-chart-yaml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ output_yaml()
{
newChartVersion=$1
newChartAppVersion=$2
imageTag=$3
imagePullPolicy=$4
imageTag=${3:-}
imagePullPolicy=${4:-}

echo "NEW_CHART_VERSION: $newChartVersion"
echo "NEW_CHART_APP_VERSION: $newChartAppVersion"
Expand All @@ -204,8 +204,12 @@ output_yaml()
sed -i "s/^version:.*/version: $newChartVersion/" "$CRDS_SUBCHART_CHART_FILE"
yq_ibl "(.dependencies[] | select(.name == \"crds\").version) |= \"$newChartVersion\"" "$CHART_FILE"

yq_ibl ".image.tag |= \"$imageTag\"" "$CHART_VALUES"
yq_ibl ".image.pullPolicy |= \"$imagePullPolicy\"" "$CHART_VALUES"
if [ -n "$imageTag" ]; then
yq_ibl ".image.tag |= \"$imageTag\"" "$CHART_VALUES"
fi
if [ -n "$imagePullPolicy" ]; then
yq_ibl ".image.pullPolicy |= \"$imagePullPolicy\"" "$CHART_VALUES"
fi
yq_ibl ".chart.version |= \"$newChartVersion\"" "$CHART_DOC"
fi
}
Expand All @@ -219,6 +223,7 @@ Options:
-h, --help Display this text.
--check-chart <branch> Check if the chart version/app version is correct for the branch.
--develop-to-release Also upgrade the chart to the release version matching the branch.
--released <released-tag> Bumps the future chart version after releasing the given tag.
--helm-testing <branch> Upgrade the chart to the appropriate branch chart version.
--app-tag <tag> The appVersion tag.
--override-index <latest_version> Override the latest chart version from the published chart's index.
Expand Down Expand Up @@ -258,6 +263,7 @@ INDEX_BRANCH_FILE="index.yaml"
INDEX_FILE=
DRY_RUN=
DEVELOP_TO_REL=
UPDATE_REL=
HELM_TESTING=
DATE_TIME_FMT="%Y-%m-%d-%H-%M-%S"
DATE_TIME=
Expand Down Expand Up @@ -289,6 +295,11 @@ while [ "$#" -gt 0 ]; do
DEVELOP_TO_REL=1
shift
;;
--released)
shift
UPDATE_REL=$1
shift
;;
--helm-testing)
HELM_TESTING=1
shift
Expand Down Expand Up @@ -362,6 +373,12 @@ if [ -n "$CHECK_BRANCH" ]; then
fi
APP_TAG=$(branch_chart_version "$CHECK_BRANCH")
else
if [ -n "$UPDATE_REL" ]; then
if [ -n "$APP_TAG" ]; then
die "Cannot specify --update-release and --app-tag together"
fi
APP_TAG=$(semver bump "patch" "$UPDATE_REL")
fi
if [ -z "$APP_TAG" ]; then
die "--app-tag not specified"
fi
Expand Down Expand Up @@ -402,6 +419,24 @@ if [ -n "$CHECK_BRANCH" ]; then
fi
fi

if [ -n "$UPDATE_REL" ]; then
if [ "$CHART_VERSION" == "0.0.0" ]; then
die "Must be used on a release branch only but \$CHART_VERSION $CHART_VERSION "
elif [ "$CHART_VERSION" != "$APP_TAG" ]; then
if [ "$(semver compare "$CHART_VERSION" "$APP_TAG")" == "1" ]; then
die "Future version can't possibly be older than the current"
fi
# TODO: if we're on a release/3 branch, then we may allow minor updates
# however, this doesn't seem likely to happen anytime soon, so, defer until then...
if [ "$(semver diff "$CHART_VERSION" "$APP_TAG")" != "patch" ]; then
die "Only future patch releases are allowed!"
fi
else
# Nothing to do here...
exit 0
fi
fi

diff="$(semver diff "$APP_TAG" "$CHART_APP_VERSION")"
if ! [[ " ${allowed_diff[*]} " =~ " $diff " ]]; then
die "Difference($diff) between APP_TAG($APP_TAG) CHART_APP_VERSION($CHART_APP_VERSION) not allowed!"
Expand Down Expand Up @@ -448,6 +483,13 @@ if [ -z "$IGNORE_INDEX_CHECK" ]; then
fi
fi

if [ -n "$UPDATE_REL" ]; then
if [ "$CHART_VERSION" != "$APP_TAG" ]; then
output_yaml "$APP_TAG" "$APP_TAG"
exit 0
fi
fi

if [ "$(semver get prerel "$APP_TAG")" == "" ]; then
# It's the stable release!
newChartVersion="$APP_TAG"
Expand Down
55 changes: 54 additions & 1 deletion scripts/helm/test-publish-chart-yaml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ CHECK_BRANCH=
DATE_TIME=
# Upgrade from develop to release/x.y*
DEVELOP_TO_REL=
# Update the release version after release
RELEASED=
# Upgrade from develop to helm-testing
HELM_TESTING=
# Tag that has been pushed
Expand Down Expand Up @@ -78,6 +80,9 @@ CHART_APP_VERSION: $CHART_APP_VERSION
EOF
fi
else
if [ -n "$RELEASED" ]; then
APP_TAG=$NEW_CHART_VERSION
fi
cat <<EOF
APP_TAG: $APP_TAG
CHART_VERSION: $CHART_VERSION
Expand Down Expand Up @@ -120,8 +125,14 @@ call_script()
fi
fi
else
ARGS="--app-tag $APP_TAG $ARGS"
if [ -n "$RELEASED" ]; then
ARGS="--released $RELEASED $ARGS"
fi
if [ -n "$APP_TAG" ]; then
ARGS="--app-tag $APP_TAG $ARGS"
fi
fi

if [ -n "$DATE_TIME" ]; then
ARGS="--date-time $DATE_TIME $ARGS"
fi
Expand Down Expand Up @@ -169,6 +180,7 @@ test_one()
CHECK_BRANCH=
DATE_TIME=
DEVELOP_TO_REL=
RELEASED=
HELM_TESTING=
APP_TAG=
CHART_VERSION=
Expand Down Expand Up @@ -371,6 +383,47 @@ NEW_CHART_VERSION=2.0.0
NEW_CHART_APP_VERSION=2.0.0
test_one "A more stable version is already published, but the app tag stable is new"

RELEASED=2.0.0
CHART_VERSION=2.0.0
CHART_APP_VERSION=2.0.0
NEW_CHART_VERSION=2.0.1
NEW_CHART_APP_VERSION=2.0.1
test_one "After release 2.0.0, the next one is 2.0.1"

RELEASED=2.0.0
CHART_VERSION=2.0.0
CHART_APP_VERSION=2.0.0
INDEX_CHART_VERSIONS=(2.0.1 2.0.0-a.0)
EXPECT_FAIL=1
test_one "We've actually already release 2.0.1, so the next one is 2.0.2"

RELEASED=2.0.1
CHART_VERSION=2.0.0
CHART_APP_VERSION=2.0.0
INDEX_CHART_VERSIONS=(2.0.1 2.0.0-a.0)
NEW_CHART_VERSION=2.0.2
NEW_CHART_APP_VERSION=2.0.2
test_one "We've actually already release 2.0.1, so the next one is 2.0.2"

RELEASED=2.2.0
CHART_VERSION=2.0.0
CHART_APP_VERSION=2.0.0
EXPECT_FAIL=1
test_one "Can't bump beyond patch!"

RELEASED=1.2.0
CHART_VERSION=2.0.0
CHART_APP_VERSION=2.0.0
EXPECT_FAIL=1
test_one "Can't bump to an older version!"

RELEASED=1.2.0
APP_TAG=1.2.0
CHART_VERSION=2.0.0
CHART_APP_VERSION=2.0.0
EXPECT_FAIL=1
test_one "Can't specify both!"

echo "Done"

if [ -n "$FAILED" ]; then
Expand Down

0 comments on commit abff840

Please sign in to comment.