release-please-action icon indicating copy to clipboard operation
release-please-action copied to clipboard

Path is not taken into account

Open xabufr opened this issue 2 years ago • 6 comments
trafficstars

TL;DR

When you add a path parameter to the action, it doesn't use it to configure the strategy. We have a Helm chart with a Chart.yaml in /chart/Chart.yaml, but when we configure the action with a path: chart it continues to lookup from git root.

Expected behavior

Path directive is used like a package in release-please-config.json, and so this:

{
  "packages": {
    "chart": {
      "release-type": "helm"
    }
  }
}

Should be equivalent to:

      - uses: google-github-actions/release-please-action@v3
        id: release
        with:
          path: chart
          release-type: helm

Observed behavior

We have the following error in our github action:

Run google-github-actions/release-please-action@v3
❯ Fetching Chart.yaml from branch releases/v3.0
Error: release-please failed: Helm (mirakl/manifests-app-mailing): Missing required file: Chart.yaml

Please note it tries to fetch Chart.yaml from the repo's root folder, not the provided chart path.

Action YAML

name: Release the Chart

on:
  push:
    branches:
      - master
      - releases/v*

permissions:
  contents: write
  pull-requests: write

env:
  CHART_NAME: XXX
  HELM_REGISTRY: XXX
  HELM_VERSION: XXX
  PYTHON_VERSION: 3

jobs:
  release-please:
    name: Release the Chart
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - name: Sets env var for main release
        id: rp_config
        run: |
          if [[ ${{github.ref}} == refs/heads/releases/v* ]]; then
            echo "::set-output name=versioning::always-bump-patch"
          else
            echo "::set-output name=versioning::default"
          fi
        shell: bash
      - uses: google-github-actions/release-please-action@v3
        id: release
        with:
          release-type: helm
          bump-minor-pre-major: true  # Remove this line and push a breaking change in order to release your first v1.x.y version
          default-branch: releases/v3.0  # TODO fix the env.GITHUB_REF_NAME that set to null :/
          versioning-strategy: ${{ steps.rp_config.outputs.versioning }}
          path: chart
      - name: Set up Helm
        if: ${{ steps.release.outputs.chart--release_created }}
        uses: azure/setup-helm@v3
        with:
          version: ${{ env.HELM_VERSION }}
      - name: Set up Python
        uses: actions/setup-python@v4
        if: ${{ steps.release.outputs.chart--release_created }}
        with:
          python-version: ${{ env.PYTHON_VERSION }}
      - name: Login to GCP artifact registry
        if: ${{ steps.release.outputs.chart--release_created }}
        uses: docker/login-action@v2
        with:
          registry: https://${{ env.HELM_REGISTRY }}
          username: _json_key_base64
          password: ${{ secrets.GCP_ARTIFACT_REGISTRY_HELM }}
      - name: Package and push the Chart
        if: ${{ steps.release.outputs.chart--release_created }}
        run: |
          helm package -u --version ${{ steps.release.outputs.chart--major }}.${{ steps.release.outputs.chart--minor }}.${{ steps.release.outputs.chart--patch }} chart -d chart/packages
          helm push chart/packages/${{ env.CHART_NAME }}-${{ steps.release.outputs.chart--major }}.${{ steps.release.outputs.chart--minor }}.${{ steps.release.outputs.chart--patch }}.tgz oci://${{ env.HELM_REGISTRY }}

Log output

Run google-github-actions/release-please-action@v3
❯ Fetching Chart.yaml from branch releases/v3.0
Error: release-please failed: Helm (mirakl/manifests-app-mailing): Missing required file: Chart.yaml

Additional information

When using a release-please-config.json we can see in logs:

Run google-github-actions/release-please-action@v3
❯ Fetching release-please-config.json from branch releases/v3.0
❯ Fetching .release-please-manifest.json from branch releases/v3.0
✔ Building pull requests
✔ Building strategies by path
❯ chart: helm
❯ Fetching chart/Chart.yaml from branch releases/v3.0

I think it is caused because path is not injected here (as it is here), so this call fails because helm strategy tries to load the package name (because the base strategy uses the overloaded function here)

xabufr avatar Mar 16 '23 16:03 xabufr