diff --git a/.github/workflows/release-chart.yml b/.github/workflows/release-chart.yml index 9e201d770..7d6345c5f 100644 --- a/.github/workflows/release-chart.yml +++ b/.github/workflows/release-chart.yml @@ -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/helm-gh-pages@v1.7.0 - 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 + 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 }} diff --git a/chart/.helmignore b/chart/.helmignore index 27c82af97..d3403136e 100644 --- a/chart/.helmignore +++ b/chart/.helmignore @@ -21,6 +21,6 @@ .idea/ *.tmproj .vscode/ -*.md +README.md.tmpl # Nix Shell *.nix diff --git a/dependencies/control-plane b/dependencies/control-plane index ea844b8d0..defcd62d4 160000 --- a/dependencies/control-plane +++ b/dependencies/control-plane @@ -1 +1 @@ -Subproject commit ea844b8d076766cbf840d68d26715e9ea714f7af +Subproject commit defcd62d427f75589599921be5d5291c03a05b0e diff --git a/scripts/helm/publish-chart-yaml.sh b/scripts/helm/publish-chart-yaml.sh index 45be78796..e224b27e3 100755 --- a/scripts/helm/publish-chart-yaml.sh +++ b/scripts/helm/publish-chart-yaml.sh @@ -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" @@ -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 } @@ -219,6 +223,7 @@ Options: -h, --help Display this text. --check-chart 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 Bumps the future chart version after releasing the given tag. --helm-testing Upgrade the chart to the appropriate branch chart version. --app-tag The appVersion tag. --override-index Override the latest chart version from the published chart's index. @@ -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= @@ -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 @@ -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 @@ -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!" @@ -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" diff --git a/scripts/helm/test-publish-chart-yaml.sh b/scripts/helm/test-publish-chart-yaml.sh index 08008d19c..1f12f6cae 100755 --- a/scripts/helm/test-publish-chart-yaml.sh +++ b/scripts/helm/test-publish-chart-yaml.sh @@ -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 @@ -78,6 +80,9 @@ CHART_APP_VERSION: $CHART_APP_VERSION EOF fi else + if [ -n "$RELEASED" ]; then + APP_TAG=$NEW_CHART_VERSION + fi cat <