diff --git a/.github/ct.yaml b/.github/ct.yml similarity index 87% rename from .github/ct.yaml rename to .github/ct.yml index 037a4ea9..2da39475 100644 --- a/.github/ct.yaml +++ b/.github/ct.yml @@ -1,6 +1,6 @@ # See https://github.com/helm/chart-testing#configuration chart-dirs: charts -check-version-increment: true +check-version-increment: false debug: false remote: origin target-branch: main diff --git a/.github/updatecli/helm-kdl-server-appversion.yaml b/.github/updatecli/helm-kdl-server-appversion.yaml new file mode 100644 index 00000000..da103386 --- /dev/null +++ b/.github/updatecli/helm-kdl-server-appversion.yaml @@ -0,0 +1,17 @@ +sources: + kdl-server: + kind: dockerimage + spec: + image: konstellation/kdl-server + architecture: linux/amd64 + versionFilter: + kind: semver +conditions: {} +targets: + kdl-server: + name: bump chart appversion + kind: yaml + spec: + file: charts/kdl-server/Chart.yaml + key: $.appVersion + sourceid: kdl-server diff --git a/.github/updatecli/helm-kdl-server-dependencies.yaml b/.github/updatecli/helm-kdl-server-dependencies.yaml new file mode 100644 index 00000000..c689333f --- /dev/null +++ b/.github/updatecli/helm-kdl-server-dependencies.yaml @@ -0,0 +1,83 @@ +sources: + konstellation-base: + kind: helmchart + spec: + url: https://charts.konstellation.io + name: konstellation-base + versionFilter: + kind: semver + pattern: '*' # replace with CI/CD updatecli + sourceid: konstellation-base + minio: + kind: helmchart + spec: + url: https://charts.bitnami.com/bitnami + name: minio + versionFilter: + kind: semver + pattern: '*' # replace with CI/CD updatecli + sourceid: minio + mongodb: + kind: helmchart + spec: + url: https://charts.bitnami.com/bitnami + name: mongodb + versionFilter: + kind: semver + pattern: '*' # replace with CI/CD updatecli + sourceid: mongodb + oauth2-proxy: + kind: helmchart + spec: + url: https://oauth2-proxy.github.io/manifests + name: oauth2-proxy + versionFilter: + kind: semver + pattern: '*' # replace with CI/CD updatecli + sourceid: oauth2-proxy + postgresql: + kind: helmchart + spec: + url: https://charts.bitnami.com/bitnami + name: postgresql + versionFilter: + kind: semver + pattern: '*' # replace with CI/CD updatecli + sourceid: postgresql +conditions: {} +targets: + konstellation-base: + name: bump chart dependencies + kind: yaml + spec: + file: charts/kdl-server/Chart.yaml + key: $.dependencies[0].version + sourceid: konstellation-base + minio: + name: bump chart dependencies + kind: yaml + spec: + file: charts/kdl-server/Chart.yaml + key: $.dependencies[1].version + sourceid: minio + mongodb: + name: bump chart dependencies + kind: yaml + spec: + file: charts/kdl-server/Chart.yaml + key: $.dependencies[2].version + sourceid: mongodb + oauth2-proxy: + name: bump chart dependencies + kind: yaml + spec: + file: charts/kdl-server/Chart.yaml + key: $.dependencies[3].version + sourceid: oauth2-proxy + postgresql: + name: bump chart dependencies + kind: yaml + spec: + file: charts/kdl-server/Chart.yaml + key: $.dependencies[4].version + sourceid: postgresql diff --git a/.github/workflows/helm-check-kdl-server-major-dependencies.yml b/.github/workflows/helm-check-kdl-server-major-dependencies.yml new file mode 100644 index 00000000..c504484b --- /dev/null +++ b/.github/workflows/helm-check-kdl-server-major-dependencies.yml @@ -0,0 +1,81 @@ +name: "[Helm] Check KDL Server major dependencies releases" + +on: + workflow_dispatch: + schedule: + - cron: '0 0 1 * *' # first day of month + +jobs: + check-and-update-major-dependencies: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Prepare updatecli configuration + id: dependencies + run: | + # get name dependencies + dependencies=($(yq eval -o=json '.dependencies[] | .name' charts/kdl-server/Chart.yaml | xargs)) + + # replace version + for dependency in "${dependencies[@]}"; do + yq eval -i ".sources.${dependency}.spec.versionFilter.pattern = \"*\"" .github/updatecli/helm-kdl-server-dependencies.yaml + done + + - name: Install updatecli + uses: updatecli/updatecli-action@v2 + + - name: Update dependencies + run: | + updatecli apply --config .github/updatecli/helm-kdl-server-dependencies.yaml --commit=false 2>&1 | tee > $GITHUB_WORKSPACE/major-output.log + + # show PR body + cat major-output.log + shell: bash + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + + - name: Update README.md Helm Chart + uses: losisin/helm-docs-github-action@v1 + with: + chart-search-root: charts/kdl-server + + - name: Get current date + id: date + run: | + echo "date=$(date -I)" >> $GITHUB_OUTPUT + + - name: Create PR with changes (dry-run) + uses: peter-evans/create-pull-request@v7 + if: github.event_name == 'workflow_dispatch' + with: + add-paths: charts/kdl-server + token: ${{ secrets.PAT }} + commit-message: "fix: update major dependencies version" + signoff: false + branch: chore/upgrade-kdl-server-major-dependencies-${{ steps.date.outputs.date }} + delete-branch: true + title: '[kdl-server] upgrade major dependencies (${{ steps.date.outputs.date }})' + body-path: major-output.log + draft: true + labels: | + auto-pr-bump-version + + - name: Create PR with changes + uses: peter-evans/create-pull-request@v7 + if: github.event_name == 'schedule' + with: + add-paths: charts/kdl-server + token: ${{ secrets.PAT }} + commit-message: "fix: update major dependencies version" + signoff: false + branch: chore/upgrade-kdl-server-major-dependencies-${{ steps.date.outputs.date }} + delete-branch: true + title: '[kdl-server] upgrade major dependencies (${{ steps.date.outputs.date }})' + body-path: major-output.log + labels: | + auto-pr-bump-version diff --git a/.github/workflows/helm-check-kdl-server-minor-dependencies.yml b/.github/workflows/helm-check-kdl-server-minor-dependencies.yml new file mode 100644 index 00000000..48b01558 --- /dev/null +++ b/.github/workflows/helm-check-kdl-server-minor-dependencies.yml @@ -0,0 +1,79 @@ +name: "[Helm] Check KDL Server minor dependencies releases" + +on: + workflow_dispatch: + schedule: + - cron: '0 0 * * 1' # every monday + +jobs: + check-and-update-minor-dependencies: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Prepare updatecli configuration + id: dependencies + run: | + # get name dependencies + dependencies=($(yq eval -o=json '.dependencies[] | .name' charts/kdl-server/Chart.yaml | xargs)) + + # replace version + for dependency in "${dependencies[@]}"; do + version="~$(yq eval -r ".dependencies[] | select(.name == \"${dependency}\") | .version" charts/kdl-server/Chart.yaml | cut -d'.' -f1)" + yq eval -i ".sources.${dependency}.spec.versionFilter.pattern = \"${version}\"" .github/updatecli/helm-kdl-server-dependencies.yaml + done + + - name: Install updatecli + uses: updatecli/updatecli-action@v2 + + - name: Update dependencies + run: | + updatecli apply --config .github/updatecli/helm-kdl-server-dependencies.yaml --commit=false 2>&1 | tee > $GITHUB_WORKSPACE/minor-output.log + shell: bash + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + + - name: Update README.md Helm Chart + uses: losisin/helm-docs-github-action@v1 + with: + chart-search-root: charts/kdl-server + + - name: Get current date + id: date + run: | + echo "date=$(date -I)" >> $GITHUB_OUTPUT + + - name: Create PR with changes (dry-run) + uses: peter-evans/create-pull-request@v7 + if: github.event_name == 'workflow_dispatch' + with: + add-paths: charts/kdl-server + token: ${{ secrets.PAT }} + commit-message: "fix: update minor dependencies version" + signoff: false + branch: chore/upgrade-kdl-server-minor-dependencies-${{ steps.date.outputs.date }} + delete-branch: true + title: '[kdl-server] upgrade minor dependencies (${{ steps.date.outputs.date }})' + body-path: minor-output.log + draft: true + labels: | + auto-pr-bump-version + + - name: Create PR with changes + uses: peter-evans/create-pull-request@v7 + if: github.event_name == 'schedule' + with: + add-paths: charts/kdl-server + token: ${{ secrets.PAT }} + commit-message: "fix: update minor dependencies version" + signoff: false + branch: chore/upgrade-kdl-server-minor-dependencies-${{ steps.date.outputs.date }} + delete-branch: true + title: '[kdl-server] upgrade minor dependencies (${{ steps.date.outputs.date }})' + body-path: minor-output.log + labels: | + auto-pr-bump-version diff --git a/.github/workflows/helm-check-kdl-server-release.yml b/.github/workflows/helm-check-kdl-server-release.yml new file mode 100644 index 00000000..c0133196 --- /dev/null +++ b/.github/workflows/helm-check-kdl-server-release.yml @@ -0,0 +1,67 @@ +name: "[Helm] Check KDL Server new releases" + +on: + workflow_dispatch: + schedule: + - cron: '0 0 * * *' # every day + +jobs: + check-and-update-kdl-server: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Get current release + id: current_release + run: | + current_release=$(grep appVersion charts/kdl-server/Chart.yaml | awk '{ print $2 }') + echo "current_release=$current_release" >> $GITHUB_OUTPUT + + - name: Install updatecli + uses: updatecli/updatecli-action@v2 + + - name: Update dependencies + run: | + updatecli apply --config .github/updatecli/helm-kdl-server-appversion.yaml --commit=false + + - name: Get latest release + id: latest_release + run: | + latest_release=$(grep appVersion charts/kdl-server/Chart.yaml | awk '{ print $2 }') + echo "latest_release=$latest_release" >> $GITHUB_OUTPUT + + - name: Check if release changed + id: check_changes + run: | + if [ ${{ steps.latest_release.outputs.latest_release }} != ${{ steps.current_release.outputs.current_release }} ]; then + echo "release_changed=true" >> $GITHUB_OUTPUT + fi + + - name: Update README.md Helm Chart + if: steps.check_changes.outputs.release_changed == 'true' + uses: losisin/helm-docs-github-action@v1 + with: + chart-search-root: charts/kdl-server + + - name: Create PR with changes + if: steps.check_changes.outputs.release_changed == 'true' + uses: peter-evans/create-pull-request@v7 + with: + token: ${{ secrets.PAT }} + commit-message: "fix: update KDL Server version to ${{ steps.latest_release.outputs.latest_release }}" + signoff: false + branch: chore/upgrade-kdl-server-appversion-${{ steps.latest_release.outputs.latest_release }} + delete-branch: true + title: '[kdl-server] new release: ${{ steps.latest_release.outputs.latest_release }}' + body: | + KDL Server version: + - :information_source: Current: `${{ steps.current_release.outputs.current_release }}` + - :up: Upgrade: `${{ steps.latest_release.outputs.latest_release }}` + + Changelog: https://github.com/konstellation-io/kdl-server/releases/tag/${{ steps.latest_release.outputs.latest_release }} + labels: | + auto-pr-bump-version diff --git a/.github/workflows/helm-lint-test.yml b/.github/workflows/helm-lint-test.yml index a3c5b231..d56c4952 100644 --- a/.github/workflows/helm-lint-test.yml +++ b/.github/workflows/helm-lint-test.yml @@ -14,6 +14,7 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + persist-credentials: false # default install latest (stable) - name: Set up Helm @@ -30,14 +31,20 @@ jobs: - name: Run chart-testing (list-changed) id: list-changed run: | - changed=$(ct list-changed --config .github/ct.yaml) + changed=$(ct list-changed --config .github/ct.yml) if [[ -n "${changed}" ]]; then echo "changed=true" >> "$GITHUB_OUTPUT" fi + - name: Add repositories + run: | + for dir in $(ls -d charts/*/); do + helm dependency list $dir 2> /dev/null | grep -v 'oci://' | tail +2 | head -n -1 | awk '{ print "helm repo add " $1 " " $3 }' | while read cmd; do $cmd; done + done + - name: Run ct lint if: steps.list-changed.outputs.changed == 'true' || github.event_name == 'workflow_dispatch' - run: ct lint --config .github/ct.yaml --lint-conf .github/helmlintconf.yaml + run: ct lint --config .github/ct.yml --lint-conf .github/helmlintconf.yaml - name: Create kind cluster if: steps.list-changed.outputs.changed == 'true' || github.event_name == 'workflow_dispatch' @@ -45,8 +52,8 @@ jobs: - name: Run ct install if: steps.list-changed.outputs.changed == 'true' - run: ct install --config .github/ct.yaml --helm-extra-args '--timeout 900s --debug' + run: ct install --config .github/ct.yml --helm-extra-args '--timeout 900s --debug' - name: (workflow_dispatch) Run ct install if: github.event_name == 'workflow_dispatch' - run: ct install --config .github/ct.yaml --helm-extra-args '--timeout 900s --debug' --all + run: ct install --config .github/ct.yml --helm-extra-args '--timeout 900s --debug' --all diff --git a/.github/workflows/helm-release.yml b/.github/workflows/helm-release.yml index d112d6a4..bb08c5ac 100644 --- a/.github/workflows/helm-release.yml +++ b/.github/workflows/helm-release.yml @@ -26,6 +26,7 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + persist-credentials: false - name: Configure Git run: |