chart-releaser
chart-releaser copied to clipboard
How to combine with image push/release?
Hi, I have a single repo containing my container source and the relevant helm package. I'd like to do the following on every push to master:
- calculate new semantic release version
- build & push image to github registry
- update a helm repository with my chart on branch
gh-pages
Altough I'm unsure how to do this since chart-releaser
will create the GitHub release itself, but there is no way to re-use that release for the image tag? Anyone doing the same?
Hi @hazcod, I have a similar workflow. I use Chart.yaml
version to version everything (docker, git tag, chart etc.), this way if someone wants to update version it goes through pull request (I don't think semver can be calculated, but has to be created manually). I also use my own version of chart releaser -> https://github.com/pete911/hcr
Github action looks like this (you need to replace <project-name>
and <user>
, also instead of dockerhub you want to use ghcr, but the rest should be the same):
name: release
on:
push:
branches:
- main
paths:
- "charts/<project-name>/Chart.yaml"
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Get helm chart version
run: echo "CHART_VERSION=$(grep '^version:' charts/<project-name>/Chart.yaml | cut -d ":" -f2 | tr -d ' ')" >> $GITHUB_ENV
- name: Create tag
uses: actions/github-script@v3
with:
github-token: ${{ github.token }}
script: |
github.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/${{ env.CHART_VERSION }}",
sha: context.sha
})
- name: Set up qemu
uses: docker/setup-qemu-action@v1
- name: Set up docker buildx
uses: docker/setup-buildx-action@v1
- name: Login to dockerhub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push docker image
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
docker.io/<user>/<project-name>:${{ env.CHART_VERSION }}
- name: Download chart releaser
run: |
curl -sSLo hcr.tar.gz "https://github.com/pete911/hcr/releases/download/v0.0.3/hcr_0.0.3_linux_amd64.tar.gz"
tar -xzf hcr.tar.gz
rm -f hcr.tar.gz
- name: Package and release chart
run: |
git config user.email "[email protected]"
git config user.name "gh-action"
./hcr -token "${{ secrets.GITHUB_TOKEN }}"