Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Governance: Automatically update the appVersion in Chart when released #547

Closed
elliotxx opened this issue Jul 26, 2024 · 14 comments · Fixed by #596 or #607
Closed

Governance: Automatically update the appVersion in Chart when released #547

elliotxx opened this issue Jul 26, 2024 · 14 comments · Fixed by #596 or #607
Assignees
Labels
chore good first issue Good for newcomers governance hacktoberfest https://hacktoberfest.com/ help wanted Extra attention is needed

Comments

@elliotxx
Copy link
Collaborator

elliotxx commented Jul 26, 2024

What would you like to be added?

Automatically update the appVersion in Chart when released.

Why is this needed?

The current release process is:

  1. Push tag, such as v0.4.5
  2. Auto trigger a karpor release pipeline. It will build an image and publish changelog, artifacts to the github release.
  3. Modify Karpor Chart's appVersion to the new version, such as v0.4.5.
  4. Auto trigger a chart release pipeline.
  5. End.

We hope the 3 and 4 steps can be merged into the 2 step and automated together.

@rajeshkio
Copy link
Contributor

I can take this if there is no urgency to complete this. I can work on it next week.

@elliotxx
Copy link
Collaborator Author

@rajeshkio Yeah, this issue is not very urgent, you can start when you are convenient.

@rajeshkio
Copy link
Contributor

I am confused. I do not see anything related to the helm chart in the current workflow; the helm chart has a different repo. So does the task include updating the Chart.yml in the helm chart repo?

@elliotxx
Copy link
Collaborator Author

elliotxx commented Aug 11, 2024

@rajeshkio Ohh, I didn't make it clear. Chart repo is here.

The current workflow is as described in the issue, after each release, I manually update the version and appVersion in the chart repo, similar to this PR.

My idea is that after each release, this PR can be automatically generated through a github action (yaml-update-action is good), and maintainers only need to click merge.

Example ( in release.yaml ):

      - name: Get version
        id: get_version
        run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
      - name: Bump version in the related HelmChart Chart.yaml
        uses: fjogeleit/yaml-update-action@main
        with:
          repository: KusionStack/charts
          valueFile: 'charts/karpor/Chart.yaml'
          propertyPath: '{"version":"${{ steps.get_version.outputs.VERSION }}", "appVersion":"${{ steps.get_version.outputs.VERSION }}"}'
          value: ${{ steps.get_version.outputs.VERSION }}
          branch: bump-karpor-to-${{ steps.get_version.outputs.VERSION }}
          targetBranch: main
          createPR: true
          message: 'refactor: bump karpor version to ${{ steps.get_version.outputs.VERSION }}'
          token: ${{ secrets.GITHUB_TOKEN }}
          workDir: .

@rajeshkio
Copy link
Contributor

Interesting. This would mean directly updating the version in the helm chart whenever there is a new image without considering if there are any changes in the helm chart repo. Also updating the appVersion in helm chart means we need to update the helm chart version as well, no?

@elliotxx
Copy link
Collaborator Author

elliotxx commented Aug 11, 2024

@rajeshkio Yeah, as long as release has a new image, we can automatically generate a PR that only includes version bump. And just like you said, version (chart version) and appVersion(image version) need to be updated. We really need to consider how to update the version, its target value is not easy to get. Let me see. 🤔

@elliotxx
Copy link
Collaborator Author

@rajeshkio I think of a way, it can obtain and automatically bump chart version:

      - name: Get karpor version
        id: get_version
        run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
      - name: Get new chart version
        id: get-chart-version
        run: |
          helm repo add kusionstack https://kusionstack.github.io/charts
          helm repo update
          version=$(helm search repo kusionstack/karpor --versions | head -n 2 | tail -n 1 | awk '{print $2}')
          echo "Current chart version is: $version"
  
          major=$(echo "$version" | cut -d. -f1)
          minor=$(echo "$version" | cut -d. -f2)
          patch=$(echo "$version" | cut -d. -f3)
          new_chart_version="${major}.${minor}.$((patch + 1))"
  
          echo "New chart version is: $new_chart_version"
          echo "::set-output name=new_chart_version::$new_chart_version"
      - name: Bump version in the related HelmChart Chart.yaml
        uses: fjogeleit/yaml-update-action@main
        with:
          repository: KusionStack/charts
          valueFile: 'charts/karpor/Chart.yaml'
          propertyPath: '{"version":"${{ steps.get-chart-version.outputs.new_chart_version }}", "appVersion":"${{ steps.get_version.outputs.VERSION }}"}'
          value: ${{ steps.get_version.outputs.VERSION }}
          branch: bump-karpor-to-${{ steps.get_version.outputs.VERSION }}
          targetBranch: main
          createPR: true
          message: 'refactor: bump karpor version to ${{ steps.get_version.outputs.VERSION }}'
          token: ${{ secrets.GITHUB_TOKEN }}
          workDir: .

@rajeshkio
Copy link
Contributor

Bro, you have already done all the hard work. Now I just need to copy and update the release YAML

@elliotxx
Copy link
Collaborator Author

@rajeshkio Yeah, but I did not do any tests in the above yaml... and its verification and debug is also important!

@rajeshkio
Copy link
Contributor

Sure. I will try to complete it by the end of the week.

elliotxx pushed a commit that referenced this issue Aug 28, 2024
…ersion (#596)

#547

## What type of PR is this?

/kind feature

## What this PR does / why we need it:

Governance: Automatically update the appVersion in the Chart when
released

## Which issue(s) this PR fixes:

Fixes #547
@elliotxx elliotxx added the hacktoberfest https://hacktoberfest.com/ label Sep 24, 2024
@rajeshkio
Copy link
Contributor

@elliotxx What is remaining in this issue?

@elliotxx
Copy link
Collaborator Author

@rajeshkio Sorry, brother. Some things at home some time ago have caused my energy to be a little scattered. This issue has some verification work that is not completed. If it is smooth, this week will be merged into.

ruquanzhao pushed a commit that referenced this issue Dec 20, 2024
…new version (#607)

## What type of PR is this?

/kind chore

## What this PR does / why we need it:

When the Release workflow is triggered, a PR will be automatically
created in the [charts
repository](https://github.com/KusionStack/charts), and the change
content in the PR is to upgrade the `chart version` and `app version`.

Demo PR: KusionStack/charts#76

Screenshots:


![image](https://github.com/user-attachments/assets/11f69b98-f803-42ae-b9ad-5f0b0147b29d)

## Which issue(s) this PR fixes:

Fix #547

---------

Co-authored-by: Rajesh Kumar <107089376+rajeshkio@users.noreply.github.com>
@elliotxx
Copy link
Collaborator Author

@rajeshkio Hi! After testing and verification, your PR has been merged. It was previously stuck in a permission issue, but after using PAT, it can now work normally.

Automatically generated PR:

image

I'm sorry to let you wait for so long...

@rajeshkio
Copy link
Contributor

No problem. Let me know if there are any other issues I can work with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore good first issue Good for newcomers governance hacktoberfest https://hacktoberfest.com/ help wanted Extra attention is needed
Projects
None yet
2 participants