nflaig / semantic-release-helm

semantic-release plugin to publish Helm charts
MIT License
13 stars 11 forks source link

Allow multiple charts in the same repo #33

Closed Piwero closed 3 months ago

Piwero commented 3 months ago

Is there any way of the plugin to check in the multiple charts in the same repo? on this repo https://github.com/Piwero/helmseum, I have multiple charts inside the charts/ directory but when adding

        [
            'semantic-release-helm3',
            {
                chartPath: 'charts',
                onlyUpdateVersion: true,
            }
        ]

It fails with :

[10:03:54 AM] [semantic-release] › ℹ  Start step "prepare" of plugin "semantic-release-helm3"
[10:03:54 AM] [semantic-release] › ✖  Failed step "prepare" of plugin "semantic-release-helm3"
[10:03:54 AM] [semantic-release] › ✖  An error occurred while running semantic-release: [Error: ENOENT: no such file or directory, open 'charts/Chart.yaml'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: 'charts/Chart.yaml',
  pluginName: 'semantic-release-helm3'
}

It's trying to look for file Chart.yaml which lives in each subdirectory of charts.

Please, find gh action with above setup error https://github.com/Piwero/helmseum/actions/runs/9329440411/job/25681881096

nflaig commented 3 months ago

This is a general limitation of semantic release, it is by default designed to just maintain one version (one chart in your case). There are solutions for this, e.g. https://github.com/pmowrer/semantic-release-monorepo. I haven't used this myself and can't guarantee it works with this plugin but might be worth to give it a try.

I have used this plugin in previously in a repo with multiple charts, this is how the gitlab ci config looked like

.release-helm:
  extends: [.release]  # <-- this was a custom semantic-release job (default should work for you)
  variables:
    PACKAGE_MANAGER: "helm"
    HELM_CHART_REPO: "oci://your-domain.com/project"

release-chart1:
  extends: [.release-helm]
  variables:
    PACKAGE_NAME: "chart2"
    RELEASE_CONTEXT: "./charts/chart1" # <-- this was to run the job in the subdirectory

release-chart2:
  extends: [.release-helm]
  variables:
    PACKAGE_NAME: "chart2"
    RELEASE_CONTEXT: "./charts/chart2"

Essentially, you would have a job per chart which is executed inside the subdirectory. I would recommend to first try using public plugins like the monorepo one before implementing a custom solution like I did previously.

Piwero commented 3 months ago

This is a general limitation of semantic release, it is by default designed to just maintain one version (one chart in your case). There are solutions for this, e.g. https://github.com/pmowrer/semantic-release-monorepo. I haven't used this myself and can't guarantee it works with this plugin but might be worth to give it a try.

I have used this plugin in previously in a repo with multiple charts, this is how the gitlab ci config looked like

.release-helm:
  extends: [.release]  # <-- this was a custom semantic-release job (default should work for you)
  variables:
    PACKAGE_MANAGER: "helm"
    HELM_CHART_REPO: "oci://your-domain.com/project"

release-chart1:
  extends: [.release-helm]
  variables:
    PACKAGE_NAME: "chart2"
    RELEASE_CONTEXT: "./charts/chart1" # <-- this was to run the job in the subdirectory

release-chart2:
  extends: [.release-helm]
  variables:
    PACKAGE_NAME: "chart2"
    RELEASE_CONTEXT: "./charts/chart2"

Essentially, you would have a job per chart which is executed inside the subdirectory. I would recommend to first try using public plugins like the monorepo one before implementing a custom solution like I did previously.

Great, @nflaig . Thanks for the info, I'll try with those approaches.