Release Charts #5
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: Release Charts | |
# only run one instance of this workflow at a time | |
# ref: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency | |
concurrency: chart_releaser | |
on: | |
workflow_call: | |
workflow_dispatch: | |
jobs: | |
release: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Fetch history | |
run: git fetch --prune --unshallow | |
- name: Configure Git | |
run: | | |
git config user.name "$GITHUB_ACTOR" | |
git config user.email "$GITHUB_ACTOR@users.noreply.github.com" | |
- name: OCI - Login to GHCR | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Update Chart AppVersion | |
if: github.event_name == 'workflow_call' | |
run: | | |
CHART_PATH="charts/sogo/Chart.yaml" | |
# Update chart version | |
# Extract the current version from the file | |
CURRENT_VERSION=$(grep -Eo 'version: [0-9]+\.[0-9]+\.[0-9]+' "$CHART_PATH" | awk '{print $2}') | |
# If no version is found, exit with an error | |
if [ -z "$CURRENT_VERSION" ]; then | |
echo "No version found in the file!" | |
exit 0 | |
fi | |
# Split the version into major, minor, and patch | |
IFS='.' read -r -a VERSION_PARTS <<< "$CURRENT_VERSION" | |
MAJOR=${VERSION_PARTS[0]} | |
MINOR=${VERSION_PARTS[1]} | |
PATCH=${VERSION_PARTS[2]} | |
MINOR=$((MINOR + 1)) | |
# Form the new version | |
NEW_VERSION="$MAJOR.$MINOR.$PATCH" | |
# Update the file with the new version | |
sed -i 's/version: '"$CURRENT_VERSION"'/version: '"$NEW_VERSION"'/' "$CHART_PATH" | |
- name: Commit files and push it | |
run: | | |
git add . | |
git commit -m "chore: bump chart version" | |
git push | |
# See https://github.com/helm/chart-releaser-action/issues/6 | |
- name: Set up Helm | |
uses: azure/setup-helm@v3.5 | |
with: | |
version: v3.11.1 | |
- name: Add dependency chart repos | |
run: | | |
helm repo add bitnami https://charts.bitnami.com/bitnami | |
- name: Run chart-releaser | |
uses: helm/chart-releaser-action@v1.6.0 | |
with: | |
charts_dir: charts | |
pages_branch: gh-pages | |
mark_as_latest: false | |
skip_existing: true | |
config: ./charts/cr.yaml | |
env: | |
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
CR_GENERATE_RELEASE_NOTES: true | |
- name: OCI Push to GHCR | |
run: | | |
if [ -z "$(ls -A .cr-release-packages)" ]; then | |
echo "No packages found under .cr-release-packages/" | |
exit 0 | |
fi | |
for pkg in .cr-release-packages/*; do | |
if [ -z "${pkg:-}" ]; then | |
break | |
fi | |
REPO="${{ github.repository }}" | |
echo "Pushing $pkg to ghcr.io/${REPO,,}" | |
helm push "$pkg" "oci://ghcr.io/${REPO,,}" | |
done |