From 51a08152305aa4e83d594a260e0bca48239c3fd4 Mon Sep 17 00:00:00 2001 From: Riadh Meghenem Date: Thu, 6 Aug 2026 11:01:38 +0200 Subject: [PATCH] ci: chart auto bump --- .github/workflows/bump-version.yaml | 64 +++++++++++++++++++++++++++++ .github/workflows/open-bump-pr.yaml | 50 ++++++++++++++++++++++ Makefile | 19 ++++++++- 3 files changed, 132 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/bump-version.yaml create mode 100644 .github/workflows/open-bump-pr.yaml diff --git a/.github/workflows/bump-version.yaml b/.github/workflows/bump-version.yaml new file mode 100644 index 0000000..410ff2c --- /dev/null +++ b/.github/workflows/bump-version.yaml @@ -0,0 +1,64 @@ +name: Bump Stream version + +# Entry point (dispatched from the stream release pipeline). This workflow only +# routes: it resolves which branch the bump belongs on (legacy/stream-X.Y if it +# exists, otherwise master) and dispatches open-bump-pr.yaml on that branch, which +# opens the actual pull request in the context of the target branch. + +on: + workflow_dispatch: + inputs: + stream_version: + description: "The released Stream version, without the leading v (e.g. 2.10.7)" + required: true + type: string + migration_version: + description: "The Stream Migration image version (e.g. 1.27.0)" + required: true + type: string + +permissions: + id-token: write + contents: read + +jobs: + route: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Fetch secrets via Vault + uses: hashicorp/vault-action@v2 + with: + url: ${{ vars.VAULT_ADDR }} + method: ${{ vars.VAULT_AUTH_METHOD }} + path: ${{ vars.VAULT_AUTH_PATH }} + secrets: | + ci/data/global/webhooks stream_helm_webhook | EVT_HELM_TOKEN ; + + - name: Resolve target branch + id: branch + env: + STREAM_VERSION: ${{ inputs.stream_version }} + run: echo "base=$(make -s resolve-base-branch STREAM_VERSION="$STREAM_VERSION")" >> "$GITHUB_OUTPUT" + + - name: Dispatch PR workflow on target branch + env: + BASE: ${{ steps.branch.outputs.base }} + STREAM_VERSION: ${{ inputs.stream_version }} + MIGRATION_VERSION: ${{ inputs.migration_version }} + REPOSITORY: ${{ github.repository }} + run: | + curl -L \ + -X POST \ + --fail \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${EVT_HELM_TOKEN}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + "https://api.github.com/repos/${REPOSITORY}/actions/workflows/open-bump-pr.yaml/dispatches" \ + -d "$(jq -n \ + --arg ref "$BASE" \ + --arg sv "$STREAM_VERSION" \ + --arg mv "$MIGRATION_VERSION" \ + '{ref: $ref, inputs: {stream_version: $sv, migration_version: $mv}}')" diff --git a/.github/workflows/open-bump-pr.yaml b/.github/workflows/open-bump-pr.yaml new file mode 100644 index 0000000..b11d990 --- /dev/null +++ b/.github/workflows/open-bump-pr.yaml @@ -0,0 +1,50 @@ +name: Open Stream bump PR + +# Runs in the context of the branch it is dispatched on (master or a legacy/stream-X.Y +# branch, selected by bump-version.yaml). It bumps that branch's chart versions and opens +# the pull request against it. + +on: + workflow_dispatch: + inputs: + stream_version: + description: "The released Stream version, without the leading v (e.g. 2.10.7)" + required: true + type: string + migration_version: + description: "The Stream Migration image version (e.g. 1.27.0)" + required: true + type: string + +permissions: + contents: write + pull-requests: write + +jobs: + bump: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install yq + run: | + sudo curl -fsSL -o /usr/local/bin/yq https://github.com/mikefarah/yq/releases/download/v4.53.3/yq_linux_amd64 + sudo chmod +x /usr/local/bin/yq + yq --version + + - name: Bump chart versions + env: + STREAM_VERSION: ${{ inputs.stream_version }} + MIGRATION_VERSION: ${{ inputs.migration_version }} + run: make bump STREAM_VERSION="$STREAM_VERSION" MIGRATION_VERSION="$MIGRATION_VERSION" + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v7.0.8 + with: + add-paths: | + Chart.yaml + values.yaml + title: "fix: bump stream to ${{ inputs.stream_version }} and stream-migration to ${{ inputs.migration_version }}" + commit-message: "fix: bump stream to ${{ inputs.stream_version }} and stream-migration to ${{ inputs.migration_version }}" + branch: "bump_stream_${{ inputs.stream_version }}" diff --git a/Makefile b/Makefile index 23c5250..ad64e16 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,22 @@ all: gen-schema dependencies package test setup-unittest +resolve-base-branch: + @if [ -z "$(STREAM_VERSION)" ]; then echo "STREAM_VERSION is not set" >&2; exit 1; fi; \ + base_version="$$(echo "$(STREAM_VERSION)" | cut -d. -f1,2)"; \ + branch="legacy/stream-$$base_version"; \ + if git ls-remote --exit-code --heads origin "$$branch" >/dev/null 2>&1; then \ + echo "$$branch"; \ + else \ + echo "master"; \ + fi + +bump: + @if [ -z "$(STREAM_VERSION)" ]; then echo "STREAM_VERSION is not set"; exit 1; fi + @if [ -z "$(MIGRATION_VERSION)" ]; then echo "MIGRATION_VERSION is not set"; exit 1; fi + STREAM_VERSION="$(STREAM_VERSION)" yq -i '.appVersion = strenv(STREAM_VERSION) | .appVersion style="double"' Chart.yaml + STREAM_VERSION="$(STREAM_VERSION)" yq -i '.image.tag = strenv(STREAM_VERSION)' values.yaml + MIGRATION_VERSION="$(MIGRATION_VERSION)" yq -i '.upgrade.image.tag = strenv(MIGRATION_VERSION)' values.yaml + gen-schema: readme-generator -r README.md -v values.yaml -s values.schema.json @@ -18,4 +35,4 @@ setup-unittest: helm plugin install https://github.com/helm-unittest/helm-unittest.git; \ else \ echo "helm unittest plugin already installed"; \ - fi \ No newline at end of file + fi