mirror of
https://github.com/bjw-s-labs/helm-charts.git
synced 2025-07-03 08:37:03 +02:00
ci: More release rework again (#386)
This commit is contained in:
parent
89be81f5b3
commit
77ab223e7e
6 changed files with 298 additions and 498 deletions
77
.github/actions/charts-package/action.yaml
vendored
77
.github/actions/charts-package/action.yaml
vendored
|
@ -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 }}
|
|
|
@ -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"
|
|
59
.github/actions/charts-release-oci/action.yaml
vendored
59
.github/actions/charts-release-oci/action.yaml
vendored
|
@ -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 }}"
|
|
243
.github/workflows/chart-release-steps.yaml
vendored
Normal file
243
.github/workflows/chart-release-steps.yaml
vendored
Normal file
|
@ -0,0 +1,243 @@
|
||||||
|
---
|
||||||
|
name: "Chart: Release"
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
chart:
|
||||||
|
description: >
|
||||||
|
Json encoded list of Helm charts to release.
|
||||||
|
Defaults to releasing everything.
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
createGithubRelease:
|
||||||
|
description: >
|
||||||
|
Should the chart be published as a GitHub release
|
||||||
|
default: false
|
||||||
|
required: false
|
||||||
|
type: boolean
|
||||||
|
publishToGhPages:
|
||||||
|
description: >
|
||||||
|
Should the charts be published to GitHub Pages.
|
||||||
|
default: false
|
||||||
|
required: false
|
||||||
|
type: boolean
|
||||||
|
deployGhPages:
|
||||||
|
description: >
|
||||||
|
Should the GitHub pages repo be deployed.
|
||||||
|
default: false
|
||||||
|
required: false
|
||||||
|
type: boolean
|
||||||
|
publishToOciRegistry:
|
||||||
|
description: >
|
||||||
|
Should the charts be published to an OCI registry.
|
||||||
|
default: false
|
||||||
|
required: false
|
||||||
|
type: boolean
|
||||||
|
helmVersion:
|
||||||
|
description: >
|
||||||
|
Helm version to use.
|
||||||
|
default: "3.11.2"
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release-chart:
|
||||||
|
name: Release chart
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
pages: write
|
||||||
|
id-token: write
|
||||||
|
contents: write
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
# ----------------------------
|
||||||
|
# Setup
|
||||||
|
# ----------------------------
|
||||||
|
- name: Checkout source branch
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
path: src
|
||||||
|
|
||||||
|
- name: Install Helm
|
||||||
|
uses: azure/setup-helm@v4
|
||||||
|
with:
|
||||||
|
version: ${{ inputs.helmVersion }}
|
||||||
|
|
||||||
|
- name: Login to OCI Registry
|
||||||
|
if: ${{ inputs.publishToOciRegistry }}
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ github.token }}
|
||||||
|
|
||||||
|
# ----------------------------
|
||||||
|
# Collect chart metadata
|
||||||
|
# ----------------------------
|
||||||
|
- name: Get chart details
|
||||||
|
id: chart-details
|
||||||
|
uses: bjw-s/helm-charts-actions/get-chart-details@main
|
||||||
|
with:
|
||||||
|
path: src/charts/${{ inputs.chart }}
|
||||||
|
validateChartYaml: true
|
||||||
|
requireChangelog: true
|
||||||
|
|
||||||
|
- name: Store chart folder
|
||||||
|
id: chart-folder
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
CHART_DIR: "${{ inputs.chart }}"
|
||||||
|
run: |
|
||||||
|
TARGET_DIR=$(basename $(dirname ${CHART_DIR}))
|
||||||
|
echo "chart_folder=${TARGET_DIR}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Format changelog
|
||||||
|
id: format-changelog
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
let input = '${{ steps.chart-details.outputs.changes }}';
|
||||||
|
let changelog = "## Changelog:";
|
||||||
|
let inputParsed = JSON.parse(input);
|
||||||
|
|
||||||
|
var changelogGrouped = inputParsed.reduce((result, currentValue) => {
|
||||||
|
(result[currentValue['kind']] = result[currentValue['kind']] || []).push(currentValue);
|
||||||
|
return result;
|
||||||
|
}, {});
|
||||||
|
|
||||||
|
for (const key in changelogGrouped) {
|
||||||
|
changelog = changelog + `\n### ${key[0].toUpperCase() + key.slice(1)}`;
|
||||||
|
let entries = changelogGrouped[key];
|
||||||
|
|
||||||
|
entries.forEach(function (entry) {
|
||||||
|
changelog = changelog + `\n- ${entry.description}`;
|
||||||
|
if ('links' in entry) {
|
||||||
|
entry.links.forEach(function (link) {
|
||||||
|
changelog = changelog + `\n - [${link.name}](${link.url})`;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
changelog = changelog + `\n`;
|
||||||
|
}
|
||||||
|
core.setOutput('changelog', changelog);
|
||||||
|
|
||||||
|
# ----------------------------
|
||||||
|
# Package Helm chart
|
||||||
|
# ----------------------------
|
||||||
|
- name: Dereference JSON schema before packaging
|
||||||
|
uses: bjw-s/helm-charts-actions/dereference-json-schema@main
|
||||||
|
with:
|
||||||
|
schemaFile: "src/charts/${{ inputs.chart }}/values.schema.json"
|
||||||
|
outputFile: "src/charts/${{ inputs.chart }}/values.schema.json"
|
||||||
|
allowFileNotFound: true
|
||||||
|
|
||||||
|
- name: Package Helm Chart
|
||||||
|
id: package-chart
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
CHART_DIR: "src/charts/${{ inputs.chart }}"
|
||||||
|
TARGET_DIR: "${{ runner.temp }}/charts_out"
|
||||||
|
run: |
|
||||||
|
mkdir -p "${TARGET_DIR}"
|
||||||
|
helm package "${CHART_DIR}" --dependency-update --destination "${TARGET_DIR}"
|
||||||
|
echo "result=$(ls ${TARGET_DIR}/*.tgz)" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
# ----------------------------
|
||||||
|
# Add chart to GitHub Pages
|
||||||
|
# ----------------------------
|
||||||
|
- name: Checkout gh-pages branch
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
if: ${{ inputs.publishToGhPages }}
|
||||||
|
with:
|
||||||
|
path: gh-pages
|
||||||
|
ref: gh-pages
|
||||||
|
|
||||||
|
- name: Copy package to gh-pages structure
|
||||||
|
id: copy-package
|
||||||
|
if: ${{ inputs.publishToGhPages }}
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
CHART_DIR: "${{ inputs.chart }}"
|
||||||
|
CHART_FOLDER: ${{ steps.chart-folder.outputs.chart_folder }}
|
||||||
|
PACKAGE_FILE: ${{ steps.package-chart.outputs.result }}
|
||||||
|
run: |
|
||||||
|
TARGET_DIR=$(dirname ${CHART_DIR})
|
||||||
|
cp "${PACKAGE_FILE}" "gh-pages/${CHART_FOLDER}/"
|
||||||
|
|
||||||
|
- name: Update repository
|
||||||
|
if: ${{ inputs.publishToGhPages }}
|
||||||
|
shell: bash
|
||||||
|
working-directory: gh-pages
|
||||||
|
run: |
|
||||||
|
git pull
|
||||||
|
|
||||||
|
- name: Update Helm chart index
|
||||||
|
if: ${{ inputs.publishToGhPages && inputs.deployGhPages }}
|
||||||
|
shell: bash
|
||||||
|
working-directory: gh-pages
|
||||||
|
run: |
|
||||||
|
helm repo index . --url https://bjw-s.github.io/helm-charts/
|
||||||
|
|
||||||
|
- name: Commit Changes
|
||||||
|
if: ${{ inputs.publishToGhPages }}
|
||||||
|
uses: stefanzweifel/git-auto-commit-action@v5
|
||||||
|
with:
|
||||||
|
commit_message: "feat: Add Chart package ${{ steps.chart-folder.outputs.chart_folder }}/${{ steps.chart-details.outputs.name }}-${{ steps.chart-details.outputs.version }}"
|
||||||
|
repository: gh-pages
|
||||||
|
branch: gh-pages
|
||||||
|
file_pattern: "index.yaml **/*.tgz"
|
||||||
|
commit_user_name: github-actions[bot]
|
||||||
|
commit_user_email: 41898282+github-actions[bot]@users.noreply.github.com
|
||||||
|
commit_author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
|
||||||
|
|
||||||
|
- name: Deploy changes to GitHub Pages
|
||||||
|
if: ${{ inputs.publishToGhPages && inputs.deployGhPages }}
|
||||||
|
uses: ./src/.github/actions/publish-folder-to-pages
|
||||||
|
with:
|
||||||
|
path: gh-pages/
|
||||||
|
deleteArtifactAfterPublish: true
|
||||||
|
|
||||||
|
# ----------------------------
|
||||||
|
# Create GitHub release
|
||||||
|
# ----------------------------
|
||||||
|
- name: Create tag
|
||||||
|
if: ${{ inputs.createGithubRelease }}
|
||||||
|
uses: EndBug/latest-tag@latest
|
||||||
|
with:
|
||||||
|
ref: ${{ steps.chart-details.outputs.name }}-${{ steps.chart-details.outputs.version }}
|
||||||
|
git-directory: src
|
||||||
|
|
||||||
|
- name: Create release for tag
|
||||||
|
uses: ncipollo/release-action@v1
|
||||||
|
if: ${{ inputs.createGithubRelease }}
|
||||||
|
with:
|
||||||
|
allowUpdates: true
|
||||||
|
tag: ${{ steps.chart-details.outputs.name }}-${{ steps.chart-details.outputs.version }}
|
||||||
|
body: ${{ steps.format-changelog.outputs.changelog }}
|
||||||
|
|
||||||
|
# ----------------------------
|
||||||
|
# Publish chart to bjw-s OCI registry
|
||||||
|
# ----------------------------
|
||||||
|
- name: Install Cosign
|
||||||
|
if: ${{ inputs.publishToOciRegistry }}
|
||||||
|
uses: sigstore/cosign-installer@v3.8.0
|
||||||
|
|
||||||
|
- name: Push Helm charts to OCI registry
|
||||||
|
if: ${{ inputs.publishToOciRegistry }}
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
PACKAGE_FILE: ${{ steps.package-chart.outputs.result }}
|
||||||
|
CHART_NAME: ${{ steps.chart-details.outputs.name }}
|
||||||
|
CHART_VERSION: ${{ steps.chart-details.outputs.version }}
|
||||||
|
CHART_TAG_BASE: ghcr.io/bjw-s/helm
|
||||||
|
CHART_TAG: ${{ steps.chart-details.outputs.name }}:${{ inputs.steps.chart-details.outputs.version }}
|
||||||
|
run: |
|
||||||
|
helm push "${PACKAGE_FILE}" 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/chart-release-steps.yaml@${{ github.ref }}"
|
256
.github/workflows/charts-release-steps.yaml
vendored
256
.github/workflows/charts-release-steps.yaml
vendored
|
@ -1,256 +0,0 @@
|
||||||
---
|
|
||||||
name: "Charts: Release"
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_call:
|
|
||||||
inputs:
|
|
||||||
charts:
|
|
||||||
description: >
|
|
||||||
Json encoded list of Helm charts to release.
|
|
||||||
Defaults to releasing everything.
|
|
||||||
default: "[]"
|
|
||||||
required: false
|
|
||||||
type: string
|
|
||||||
excludedChartsRelease:
|
|
||||||
description: >
|
|
||||||
Json encoded list of Helm charts to exclude from release.
|
|
||||||
default: "[]"
|
|
||||||
required: false
|
|
||||||
type: string
|
|
||||||
publishToGhPages:
|
|
||||||
description: >
|
|
||||||
Should the charts be published to GitHub Pages.
|
|
||||||
default: true
|
|
||||||
required: false
|
|
||||||
type: boolean
|
|
||||||
ghPagesBranch:
|
|
||||||
description: >
|
|
||||||
Target branch for GitHub Pages.
|
|
||||||
default: "gh-pages"
|
|
||||||
required: false
|
|
||||||
type: string
|
|
||||||
publishToOciRegistry:
|
|
||||||
description: >
|
|
||||||
Should the charts be published to an OCI registry.
|
|
||||||
default: true
|
|
||||||
required: false
|
|
||||||
type: boolean
|
|
||||||
ociRegistry:
|
|
||||||
description: >
|
|
||||||
Target OCI registry for Helm charts.
|
|
||||||
default: "ghcr.io"
|
|
||||||
required: false
|
|
||||||
type: string
|
|
||||||
helmVersion:
|
|
||||||
description: >
|
|
||||||
Helm version to use.
|
|
||||||
default: "3.11.2"
|
|
||||||
required: false
|
|
||||||
type: string
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
package-charts:
|
|
||||||
name: Package charts
|
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
charts: ${{ fromJSON(inputs.charts) }}
|
|
||||||
fail-fast: false
|
|
||||||
steps:
|
|
||||||
- name: Checkout source branch
|
|
||||||
if: ${{ !contains(fromJSON(inputs.excludedChartsRelease), matrix.charts) }}
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
path: src
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Package Helm charts
|
|
||||||
uses: ./src/.github/actions/charts-package
|
|
||||||
if: ${{ !contains(fromJSON(inputs.excludedChartsRelease), matrix.charts) }}
|
|
||||||
with:
|
|
||||||
rootFolder: src/charts
|
|
||||||
chartFolder: ${{ matrix.charts }}
|
|
||||||
artifactPrefix: chart__
|
|
||||||
helmVersion: ${{ inputs.helmVersion }}
|
|
||||||
|
|
||||||
tag-charts:
|
|
||||||
name: Tag charts
|
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
needs:
|
|
||||||
- package-charts
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
charts: ${{ fromJSON(inputs.charts) }}
|
|
||||||
fail-fast: false
|
|
||||||
steps:
|
|
||||||
- name: Checkout source branch
|
|
||||||
if: ${{ !contains(fromJSON(inputs.excludedChartsRelease), matrix.charts) }}
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Grab chart details
|
|
||||||
id: chart-details
|
|
||||||
if: ${{ !contains(fromJSON(inputs.excludedChartsRelease), matrix.charts) }}
|
|
||||||
shell: bash
|
|
||||||
env:
|
|
||||||
ROOT_DIR: charts
|
|
||||||
CHART_DIR: "${{ matrix.charts }}"
|
|
||||||
run: |
|
|
||||||
PARENT_DIR=$(basename $(dirname "${ROOT_DIR}/${CHART_DIR}"))
|
|
||||||
echo "name=$(yq '.name' ${ROOT_DIR}/${CHART_DIR}/Chart.yaml)" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "version=$(yq '.version' ${ROOT_DIR}/${CHART_DIR}/Chart.yaml)" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "changelog=$(yq '.annotations["artifacthub.io/changes"]' ${ROOT_DIR}/${CHART_DIR}/Chart.yaml | yq -o=json -I=0 '.' | sed 's/\\n/ /g')" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
- name: Format changelog
|
|
||||||
id: changelog
|
|
||||||
if: ${{ !contains(fromJSON(inputs.excludedChartsRelease), matrix.charts) }}
|
|
||||||
uses: actions/github-script@v7
|
|
||||||
with:
|
|
||||||
script: |
|
|
||||||
let input = '${{ steps.chart-details.outputs.changelog }}';
|
|
||||||
let changelog = "## Changelog:";
|
|
||||||
if (input === 'null') {
|
|
||||||
changelog = changelog + "\nNo changelog provided.";
|
|
||||||
} else {
|
|
||||||
let inputParsed = JSON.parse(input);
|
|
||||||
|
|
||||||
var changelogGrouped = inputParsed.reduce((result, currentValue) => {
|
|
||||||
(result[currentValue['kind']] = result[currentValue['kind']] || []).push(currentValue);
|
|
||||||
return result;
|
|
||||||
}, {});
|
|
||||||
|
|
||||||
for (const key in changelogGrouped) {
|
|
||||||
changelog = changelog + `\n### ${key[0].toUpperCase() + key.slice(1)}`;
|
|
||||||
let entries = changelogGrouped[key];
|
|
||||||
|
|
||||||
entries.forEach(function (entry) {
|
|
||||||
changelog = changelog + `\n- ${entry.description}`;
|
|
||||||
if ('links' in entry) {
|
|
||||||
entry.links.forEach(function (link) {
|
|
||||||
changelog = changelog + `\n - [${link.name}](${link.url})`;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
changelog = changelog + `\n`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
console.log(changelog);
|
|
||||||
core.setOutput('changelog', changelog);
|
|
||||||
|
|
||||||
- name: Create tag
|
|
||||||
if: ${{ !contains(fromJSON(inputs.excludedChartsRelease), matrix.charts) }}
|
|
||||||
uses: EndBug/latest-tag@latest
|
|
||||||
with:
|
|
||||||
ref: ${{ steps.chart-details.outputs.name }}-${{ steps.chart-details.outputs.version }}
|
|
||||||
|
|
||||||
- uses: ncipollo/release-action@v1
|
|
||||||
if: ${{ !contains(fromJSON(inputs.excludedChartsRelease), matrix.charts) }}
|
|
||||||
with:
|
|
||||||
allowUpdates: true
|
|
||||||
tag: ${{ steps.chart-details.outputs.name }}-${{ steps.chart-details.outputs.version }}
|
|
||||||
body: ${{ steps.changelog.outputs.changelog }}
|
|
||||||
|
|
||||||
release-charts-to-github-pages:
|
|
||||||
name: Release charts to GitHub Pages
|
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
if: ${{ inputs.publishToGhPages }}
|
|
||||||
needs:
|
|
||||||
- package-charts
|
|
||||||
steps:
|
|
||||||
- name: Checkout source branch
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
path: src
|
|
||||||
|
|
||||||
- name: Checkout gh-pages branch
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
token: ${{ github.token }}
|
|
||||||
path: gh-pages
|
|
||||||
ref: ${{ inputs.ghPagesBranch }}
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Prepare artifacts for release to GitHub Pages
|
|
||||||
uses: ./src/.github/actions/charts-release-ghpages
|
|
||||||
with:
|
|
||||||
artifactPattern: "*"
|
|
||||||
artifactPrefix: chart__
|
|
||||||
targetFolder: gh-pages
|
|
||||||
targetBranch: gh-pages
|
|
||||||
|
|
||||||
- name: Publish changes to GitHub Pages
|
|
||||||
uses: ./src/.github/actions/publish-folder-to-pages
|
|
||||||
with:
|
|
||||||
path: gh-pages/
|
|
||||||
|
|
||||||
prepare-release-charts-to-oci:
|
|
||||||
name: Prepare releasing charts to OCI registry
|
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
if: ${{ inputs.publishToOciRegistry }}
|
|
||||||
needs:
|
|
||||||
- package-charts
|
|
||||||
outputs:
|
|
||||||
artifacts: ${{ steps.artifacts.outputs.artifacts }}
|
|
||||||
steps:
|
|
||||||
- name: List artifacts
|
|
||||||
id: list
|
|
||||||
uses: yakubique/list-artifacts@v1.1
|
|
||||||
with:
|
|
||||||
name: chart__*
|
|
||||||
|
|
||||||
- name: Rewrite artifacts output
|
|
||||||
id: artifacts
|
|
||||||
shell: bash
|
|
||||||
env:
|
|
||||||
JQ_COMMAND: |-
|
|
||||||
[.[] | {artifact_name: .name, chart_name: (.name | split("__")[-2]), chart_version: (.name | split("__")[-1]) }]
|
|
||||||
run: |
|
|
||||||
echo '${{ steps.list.outputs.result }}' | jq -c -r "$JQ_COMMAND" > artifacts
|
|
||||||
echo "artifacts=$(cat artifacts)" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
release-charts-to-oci:
|
|
||||||
name: Release charts to OCI registry
|
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
if: ${{ inputs.publishToOciRegistry && needs.prepare-release-charts-to-oci.outputs.artifacts != '[]' }}
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
artifacts: ${{ fromJSON(needs.prepare-release-charts-to-oci.outputs.artifacts) }}
|
|
||||||
fail-fast: false
|
|
||||||
needs:
|
|
||||||
- package-charts
|
|
||||||
- prepare-release-charts-to-oci
|
|
||||||
env:
|
|
||||||
TARGET_REGISTRY: ghcr.io
|
|
||||||
steps:
|
|
||||||
- name: Download chart artifacts
|
|
||||||
uses: actions/download-artifact@v4
|
|
||||||
with:
|
|
||||||
path: artifacts
|
|
||||||
pattern: ${{ matrix.artifacts.artifact_name }}
|
|
||||||
|
|
||||||
- name: Checkout source branch
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
path: src
|
|
||||||
|
|
||||||
- name: Release chart to OCI registry
|
|
||||||
uses: ./src/.github/actions/charts-release-oci
|
|
||||||
with:
|
|
||||||
workingDir: artifacts/${{ matrix.artifacts.artifact_name }}
|
|
||||||
chartName: ${{ matrix.artifacts.chart_name }}
|
|
||||||
chartVersion: ${{ matrix.artifacts.chart_version }}
|
|
||||||
|
|
||||||
cleanup-charts-artifacts:
|
|
||||||
name: Clean up artifacts
|
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
needs:
|
|
||||||
- package-charts
|
|
||||||
- release-charts-to-github-pages
|
|
||||||
- release-charts-to-oci
|
|
||||||
if: ${{ always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}
|
|
||||||
steps:
|
|
||||||
- name: Clean up artifact
|
|
||||||
uses: joernott/rm-artifact@v1
|
|
||||||
with:
|
|
||||||
name: "*"
|
|
||||||
useGlob: true
|
|
||||||
failOnError: true
|
|
92
.github/workflows/charts-release.yaml
vendored
92
.github/workflows/charts-release.yaml
vendored
|
@ -22,12 +22,12 @@ jobs:
|
||||||
name: Prepare data required for workflow
|
name: Prepare data required for workflow
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
outputs:
|
outputs:
|
||||||
repoConfiguration: ${{ steps.repo-config.outputs.config }}
|
libraryChartsToRelease: ${{ steps.filtered-charts.outputs.libraryChartsToRelease }}
|
||||||
libraryChartsToRelease: |-
|
otherChartsToRelease: ${{ steps.filtered-charts.outputs.otherChartsToRelease }}
|
||||||
${{ github.event_name == 'workflow_dispatch' && steps.specified-charts.outputs.libraryChartsToRelease || steps.changed-library-charts.outputs.all_changed_files }}
|
|
||||||
otherChartsToRelease: |-
|
|
||||||
${{ github.event_name == 'workflow_dispatch' && steps.specified-charts.outputs.otherChartsToRelease || steps.changed-charts.outputs.all_changed_files }}
|
|
||||||
steps:
|
steps:
|
||||||
|
# ----------------------------
|
||||||
|
# Setup
|
||||||
|
# ----------------------------
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
|
@ -69,7 +69,8 @@ jobs:
|
||||||
uses: actions/github-script@v7
|
uses: actions/github-script@v7
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
let input = '${{ github.event.inputs.charts }}';
|
const fs = require('fs');
|
||||||
|
let input = '${{ inputs.charts }}';
|
||||||
let cwd = process.cwd();
|
let cwd = process.cwd();
|
||||||
|
|
||||||
let tmpCharts = []
|
let tmpCharts = []
|
||||||
|
@ -77,28 +78,43 @@ jobs:
|
||||||
console.log("Empty charts input, scanning for charts in repository");
|
console.log("Empty charts input, scanning for charts in repository");
|
||||||
const globber = await glob.create('charts/*/*', { implicitDescendants: false });
|
const globber = await glob.create('charts/*/*', { implicitDescendants: false });
|
||||||
for await (const file of globber.globGenerator()) {
|
for await (const file of globber.globGenerator()) {
|
||||||
relativePath = file.slice(`${cwd}/charts/`.length);
|
if (fs.lstatSync(file).isDirectory()) {
|
||||||
tmpCharts.push(relativePath);
|
relativePath = file.slice(`${cwd}/charts/`.length);
|
||||||
|
tmpCharts.push(relativePath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const fs = require('fs');
|
|
||||||
tmpCharts = JSON.parse(input);
|
tmpCharts = JSON.parse(input);
|
||||||
tmpCharts.forEach(function (chart) {
|
tmpCharts.forEach(function (chart) {
|
||||||
if (!fs.existsSync(`${cwd}/charts/${chart}`)) {
|
const fullPath = `${cwd}/charts/${chart}`;
|
||||||
|
if (!fs.existsSync(fullPath)) {
|
||||||
core.setFailed(`Chart ${chart} does not exist in repository`);
|
core.setFailed(`Chart ${chart} does not exist in repository`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
if (!fs.lstatSync(fullPath).isDirectory()) {
|
||||||
|
core.setFailed(`${chart} is not a valid directory`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let libraryCharts = tmpCharts.filter(chart => chart.startsWith('library/'));
|
let libraryCharts = tmpCharts.filter(chart => chart.startsWith('library/'));
|
||||||
let otherCharts = tmpCharts.filter(chart => !chart.startsWith('library/'));
|
|
||||||
|
|
||||||
console.log("Library charts:")
|
|
||||||
console.log(JSON.stringify(libraryCharts));
|
|
||||||
core.setOutput('libraryChartsToRelease', JSON.stringify(libraryCharts));
|
core.setOutput('libraryChartsToRelease', JSON.stringify(libraryCharts));
|
||||||
console.log("Other charts:")
|
let otherCharts = tmpCharts.filter(chart => !chart.startsWith('library/'));
|
||||||
console.log(JSON.stringify(otherCharts));
|
core.setOutput('otherChartsToRelease', JSON.stringify(otherCharts));
|
||||||
|
|
||||||
|
- name: Filter out excluded charts
|
||||||
|
id: filtered-charts
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
let libraryChartsInput = ${{ github.event_name == 'workflow_dispatch' && steps.specified-charts.outputs.libraryChartsToRelease || steps.changed-library-charts.outputs.all_changed_files }};
|
||||||
|
let otherChartsInput = ${{ github.event_name == 'workflow_dispatch' && steps.specified-charts.outputs.otherChartsToRelease || steps.changed-charts.outputs.all_changed_files }};
|
||||||
|
let excludedFromRelease = ${{ steps.repo-config.outputs.config }}['excluded-charts-release'];
|
||||||
|
|
||||||
|
let libraryCharts = libraryChartsInput.filter(item => excludedFromRelease.indexOf(item) < 0);
|
||||||
|
core.setOutput('libraryChartsToRelease', JSON.stringify(libraryCharts));
|
||||||
|
let otherCharts = otherChartsInput.filter(item => excludedFromRelease.indexOf(item) < 0);
|
||||||
core.setOutput('otherChartsToRelease', JSON.stringify(otherCharts));
|
core.setOutput('otherChartsToRelease', JSON.stringify(otherCharts));
|
||||||
|
|
||||||
release-library-charts:
|
release-library-charts:
|
||||||
|
@ -106,17 +122,18 @@ jobs:
|
||||||
needs:
|
needs:
|
||||||
- prepare
|
- prepare
|
||||||
if: ${{ needs.prepare.outputs.libraryChartsToRelease != '[]' && needs.prepare.outputs.libraryChartsToRelease != '' }}
|
if: ${{ needs.prepare.outputs.libraryChartsToRelease != '[]' && needs.prepare.outputs.libraryChartsToRelease != '' }}
|
||||||
uses: ./.github/workflows/charts-release-steps.yaml
|
strategy:
|
||||||
permissions:
|
matrix:
|
||||||
pages: write
|
chart: ${{ fromJSON(needs.prepare.outputs.libraryChartsToRelease) }}
|
||||||
id-token: write
|
fail-fast: false
|
||||||
contents: write
|
max-parallel: 1
|
||||||
packages: write
|
uses: ./.github/workflows/chart-release-steps.yaml
|
||||||
with:
|
with:
|
||||||
charts: ${{ needs.prepare.outputs.libraryChartsToRelease }}
|
chart: ${{ matrix.chart }}
|
||||||
excludedChartsRelease: ${{ toJSON(fromJSON(needs.prepare.outputs.repoConfiguration).excluded-charts-release) }}
|
createGithubRelease: true
|
||||||
ghPagesBranch: gh-pages
|
publishToGhPages: true
|
||||||
publishToOciRegistry: false
|
publishToOciRegistry: false
|
||||||
|
deployGhPages: true
|
||||||
|
|
||||||
release-other-charts:
|
release-other-charts:
|
||||||
name: Release other charts
|
name: Release other charts
|
||||||
|
@ -126,17 +143,18 @@ jobs:
|
||||||
if: |-
|
if: |-
|
||||||
${{
|
${{
|
||||||
!cancelled() &&
|
!cancelled() &&
|
||||||
(needs.prepare.result == 'skipped' || needs.prepare.result == 'success') &&
|
!contains(needs.*.result, 'failure') &&
|
||||||
(needs.release-library-charts.result == 'skipped' || needs.release-library-charts.result == 'success') &&
|
(needs.prepare.outputs.otherChartsToRelease != '[]' && needs.prepare.outputs.otherChartsToRelease != '')
|
||||||
needs.prepare.outputs.otherChartsToRelease != '[]'
|
|
||||||
}}
|
}}
|
||||||
uses: ./.github/workflows/charts-release-steps.yaml
|
strategy:
|
||||||
permissions:
|
matrix:
|
||||||
pages: write
|
chart: ${{ fromJSON(needs.prepare.outputs.otherChartsToRelease) }}
|
||||||
id-token: write
|
fail-fast: false
|
||||||
contents: write
|
max-parallel: 1
|
||||||
packages: write
|
uses: ./.github/workflows/chart-release-steps.yaml
|
||||||
with:
|
with:
|
||||||
charts: ${{ needs.prepare.outputs.otherChartsToRelease }}
|
chart: ${{ matrix.chart }}
|
||||||
excludedChartsRelease: ${{ toJSON(fromJSON(needs.prepare.outputs.repoConfiguration).excluded-charts-release) }}
|
createGithubRelease: true
|
||||||
ghPagesBranch: gh-pages
|
publishToGhPages: true
|
||||||
|
publishToOciRegistry: true
|
||||||
|
deployGhPages: true
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue