ci: More release rework again (#386)

This commit is contained in:
Bernd Schorgers 2025-02-12 16:52:43 +01:00
parent 89be81f5b3
commit 77ab223e7e
No known key found for this signature in database
GPG key ID: BC5E2BD907F9A8EC
6 changed files with 298 additions and 498 deletions

View file

@ -1,77 +0,0 @@
---
name: "Package charts"
description: "Package charts for release"
inputs:
rootFolder:
description: "Root folder containing the charts to package"
required: true
chartFolder:
description: "Folder containing the chart to package relative to the base folder"
required: true
destinationFolder:
description: "Folder where the chart packages should be stored"
required: true
default: "out"
artifactPrefix:
description: "Prefix for the artifact name"
required: false
default: ""
retentionDays:
description: "Duration after which artifacts will expire in days."
required: true
default: "1"
helmVersion:
description: "Helm version to use for packaging"
required: true
default: 3.17.0
runs:
using: "composite"
steps:
- name: Install Kubernetes tools
uses: yokawasa/action-setup-kube-tools@v0.11.2
with:
setup-tools: |
helmv3
helm: "${{ inputs.helmVersion }}"
- name: Grab chart details
id: chart-details
shell: bash
env:
ROOT_DIR: "${{ inputs.rootFolder }}"
CHART_DIR: "${{ inputs.chartFolder }}"
run: |
PARENT_DIR=$(basename $(dirname "${ROOT_DIR}/${CHART_DIR}"))
echo "parentdir=${PARENT_DIR}" >> "$GITHUB_OUTPUT"
echo "name=$(yq '.name' ${ROOT_DIR}/${CHART_DIR}/Chart.yaml)" >> "$GITHUB_OUTPUT"
echo "version=$(yq '.version' ${ROOT_DIR}/${CHART_DIR}/Chart.yaml)" >> "$GITHUB_OUTPUT"
- name: Dereference JSON schema before packaging
uses: bjw-s/helm-charts-actions/dereference-json-schema@main
with:
schemaFile: "${{ inputs.rootFolder }}/${{ inputs.chartFolder }}/values.schema.json"
outputFile: "${{ inputs.rootFolder }}/${{ inputs.chartFolder }}/values.schema.json"
allowFileNotFound: true
- name: Package Helm Chart
shell: bash
env:
ROOT_DIR: "${{ inputs.rootFolder }}"
CHART_DIR: "${{ inputs.chartFolder }}"
PARENT_DIR: "${{ steps.chart-details.outputs.parentdir }}"
TARGET_DIR: "${{ inputs.destinationFolder }}"
run: |
helm package "${ROOT_DIR}/${CHART_DIR}" --dependency-update --destination "${TARGET_DIR}/${PARENT_DIR}"
- name: Upload artifact
uses: actions/upload-artifact@v4
env:
PARENT_DIR: "${{ steps.chart-details.outputs.parentdir }}"
CHART_NAME: "${{ steps.chart-details.outputs.name }}"
CHART_VERSION: "${{ steps.chart-details.outputs.version }}"
TARGET_DIR: "${{ inputs.destinationFolder }}"
with:
name: "${{ inputs.artifactPrefix }}${{ env.PARENT_DIR }}__${{ env.CHART_NAME }}__${{ env.CHART_VERSION }}"
path: "${{ env.TARGET_DIR }}/${{ env.PARENT_DIR }}/${{ env.CHART_NAME }}-${{ env.CHART_VERSION }}.tgz"
retention-days: ${{ inputs.retentionDays }}

View file

@ -1,69 +0,0 @@
---
name: "Prepare chart artifacts for release"
description: "Prepare chart artifacts for release to GitHub Pages"
inputs:
artifactPattern:
description: "Pattern to match artifacts to release"
required: true
artifactPrefix:
description: "Prefix to strip from the artifact names"
required: false
default: ""
targetFolder:
description: "Folder where to move the chart artifacts"
required: true
default: gh-pages
targetBranch:
description: "Branch to push the chart artifacts"
required: true
default: gh-pages
runs:
using: "composite"
steps:
- name: Prepare artifacts folder
shell: bash
run: |
mkdir -p artifacts
- name: Download chart artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
pattern: ${{ inputs.artifactPrefix }}${{ inputs.artifactPattern }}
- name: Copy artifacts to gh-pages structure
uses: actions/github-script@v7
with:
script: |
const dstFolder = "${{ inputs.targetFolder }}";
const artifactPrefix = "${{ inputs.artifactPrefix }}";
baseDir = process.cwd();
artifactsDir = `${baseDir}/artifacts`;
const globber = await glob.create(`${artifactsDir}/${artifactPrefix}*/*.tgz`);
for await (const file of globber.globGenerator()) {
relativePath = file.startsWith(artifactsDir) ? file.slice(artifactsDir.length) : file;
artifactFolder = relativePath.split('/')[1];
artifactFolderStrippedPrefix = artifactFolder.startsWith(artifactPrefix) ? artifactFolder.slice(artifactPrefix.length) : artifactFolder;
chartType = artifactFolderStrippedPrefix.split('__')[0];
targetFolder = `${baseDir}/${dstFolder}/${chartType}`;
console.log(`Copying ${file} to ${targetFolder}/`);
await io.mkdirP(targetFolder);
await io.cp(file, `${targetFolder}/`);
}
- name: Update chart index
shell: bash
working-directory: ${{ inputs.targetFolder }}
run: |
helm repo index . --url https://bjw-s.github.io/helm-charts/
- name: Commit Changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
repository: ${{ inputs.targetFolder }}
branch: ${{ inputs.targetBranch }}
file_pattern: "index.yaml **/*.tgz"

View file

@ -1,59 +0,0 @@
---
name: "Release charts to OCI registry"
description: "Release charts to OCI registry"
inputs:
chartName:
description: "Name of the chart to release"
required: true
chartVersion:
description: "Version of the chart to release"
required: true
workingDir:
description: "Working directory"
required: true
default: "."
ociRegistry:
description: >
Target OCI registry for Helm charts.
required: true
default: "ghcr.io"
helmVersion:
description: "Helm version to use for packaging"
required: true
default: 3.17.0
runs:
using: "composite"
steps:
- name: Install Cosign
uses: sigstore/cosign-installer@v3.6.0
- name: Install Kubernetes tools
uses: yokawasa/action-setup-kube-tools@v0.11.2
with:
setup-tools: |
helmv3
helm: ${{ inputs.helmVersion }}
- name: Login to OCI Registry
uses: docker/login-action@v3
with:
registry: ${{ inputs.ociRegistry }}
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Push Helm charts to OCI registry
shell: bash
working-directory: ${{ inputs.workingDir }}
env:
CHART_NAME: ${{ inputs.chartName }}
CHART_VERSION: ${{ inputs.chartVersion }}
CHART_TAG_BASE: ${{ inputs.ociRegistry }}/${{ github.actor }}/helm
CHART_TAG: ${{ inputs.chartName }}:${{ inputs.chartVersion }}
run: |
helm push "${CHART_NAME}-${CHART_VERSION}.tgz" oci://${CHART_TAG_BASE} &> push-metadata.txt
CHART_DIGEST=$(awk '/Digest: /{print $2}' push-metadata.txt)
cosign sign --yes "${CHART_TAG_BASE}/${CHART_TAG}@${CHART_DIGEST}"
cosign verify "${CHART_TAG_BASE}/${CHART_TAG}@${CHART_DIGEST}" \
--certificate-oidc-issuer "https://token.actions.githubusercontent.com" \
--certificate-identity "https://github.com/${{ github.repository }}/.github/workflows/charts-release-steps.yaml@${{ github.ref }}"