Push Helm Chart to OCI Registry #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Push Helm Chart to OCI Registry | |
on: | |
push: | |
branches: | |
- main | |
- v[0-9]+ | |
- v[0-9]+.[0-9]+ | |
- cryostat-v[0-9]+.[0-9]+ | |
workflow_dispatch: | |
jobs: | |
helm-push-to-OCI: | |
permissions: | |
packages: write | |
contents: write | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Configure Git | |
run: | | |
git config user.name ${{ github.actor }} | |
git config user.email ${{ github.actor }}@users.noreply.github.com | |
- name: Get release version | |
id: release-version | |
run: | | |
echo "tag=v$(yq .version charts/cryostat/Chart.yaml)" >> $GITHUB_OUTPUT | |
- name: Get previous version | |
id: previous-version | |
run: | | |
# Filter tags by regex, combine with the Chart version, sort by version number, and output the preceeding version. | |
chart_version="${{ steps.release-version.outputs.tag }}" | |
previous_version="$({ echo v${chart_version}; git tag -l | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$'; } | sort -V | grep -B1 "${chart_version}" | head -n1)" | |
echo "tag=${previous_version}" >> $GITHUB_OUTPUT | |
- name: Generate release notes | |
env: | |
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
run: | | |
gh api --method POST \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
/repos/${GITHUB_REPOSITORY}/releases/generate-notes \ | |
-f tag_name="${{ steps.release-version.outputs.tag }}" \ | |
-f target_commitish="${GITHUB_REF_NAME}" \ | |
-f previous_tag_name="${{ steps.previous-version.outputs.tag }}" | jq -r .body > charts/cryostat/release-notes.md | |
- name: Set up Helm | |
uses: azure/setup-helm@v4 | |
with: | |
version: v3.14.4 | |
- name: Run chart-releaser | |
uses: helm/chart-releaser-action@v1.6.0 | |
env: | |
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
CR_SKIP_EXISTING: "true" | |
with: | |
charts_dir: charts | |
config: .github/helm-release-config.yml | |
- name: Login to GitHub Container Registry | |
uses: docker/#-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Push charts to GHCR | |
run: | | |
for pkg in .cr-release-packages/*.tgz; do | |
if [ -z "${pkg:-}" ]; then | |
break | |
fi | |
helm push "${pkg}" oci://ghcr.io/${{ github.repository_owner }} | |
done |