Skip to content

fix: use 'latest' as default tag for API and Portal images #9

fix: use 'latest' as default tag for API and Portal images

fix: use 'latest' as default tag for API and Portal images #9

Workflow file for this run

name: Release Helm Chart
on:
push:
branches: [main]
paths:
- 'tron/Chart.yaml'
- 'tron/values.yaml'
- 'tron/templates/**'
- '.github/workflows/release-chart.yml'
- 'index.html'
workflow_dispatch:
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
pages: write
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: 'latest'
- name: Update chart dependencies
working-directory: ./tron
run: |
helm dependency update
- name: Lint chart
working-directory: ./tron
run: |
helm lint .
- name: Package chart
working-directory: ./tron
run: |
helm package .
CHART_VERSION=$(grep '^version:' Chart.yaml | awk '{print $2}')
CHART_NAME=$(grep '^name:' Chart.yaml | awk '{print $2}')
echo "CHART_FILE=${CHART_NAME}-${CHART_VERSION}.tgz" >> $GITHUB_ENV
echo "CHART_VERSION=${CHART_VERSION}" >> $GITHUB_ENV
echo "CHART_NAME=${CHART_NAME}" >> $GITHUB_ENV
- name: Check if tag exists
id: check-tag
run: |
TAG="v${{ env.CHART_VERSION }}"
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "exists=true" >> $GITHUB_OUTPUT
echo "Tag $TAG already exists"
else
echo "exists=false" >> $GITHUB_OUTPUT
echo "Tag $TAG does not exist, will create"
fi
echo "tag=$TAG" >> $GITHUB_OUTPUT
- name: Generate release notes
id: release-notes
if: steps.check-tag.outputs.exists == 'false'
working-directory: ./tron
run: |
if [ -f CHANGELOG.md ]; then
# Extract changelog for current version
VERSION="${{ env.CHART_VERSION }}"
# Try to extract version section from CHANGELOG
if grep -q "## \[$VERSION\]" CHANGELOG.md; then
awk "/## \[$VERSION\]/,/## \[/" CHANGELOG.md | head -n -1 > /tmp/release-notes.md
elif grep -q "## $VERSION" CHANGELOG.md; then
awk "/## $VERSION/,/## /" CHANGELOG.md | head -n -1 > /tmp/release-notes.md
else
echo "## Chart Release v$VERSION" > /tmp/release-notes.md
echo "" >> /tmp/release-notes.md
echo "Helm chart version $VERSION for Tron Platform" >> /tmp/release-notes.md
fi
else
echo "## Chart Release v${{ env.CHART_VERSION }}" > /tmp/release-notes.md
echo "" >> /tmp/release-notes.md
echo "Helm chart version ${{ env.CHART_VERSION }} for Tron Platform" >> /tmp/release-notes.md
fi
echo "notes<<EOF" >> $GITHUB_OUTPUT
cat /tmp/release-notes.md >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Check if gh-pages exists
id: check-branch
run: |
if git ls-remote --heads origin gh-pages | grep -q gh-pages; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Checkout gh-pages branch
if: steps.check-branch.outputs.exists == 'true'
uses: actions/checkout@v4
with:
ref: gh-pages
path: gh-pages
token: ${{ secrets.GITHUB_TOKEN }}
- name: Create gh-pages directory
if: steps.check-branch.outputs.exists == 'false'
run: |
mkdir -p gh-pages
cd gh-pages
git init
git checkout -b gh-pages
- name: Prepare gh-pages content
run: |
# Copy chart package
cp tron/${{ env.CHART_FILE }} gh-pages/
# Copy index.html
cp index.html gh-pages/index.html
# Generate or update index
cd gh-pages
if [ -f index.yaml ]; then
helm repo index . --url https://grid-labs-tech.github.io/charts --merge index.yaml
else
helm repo index . --url https://grid-labs-tech.github.io/charts
fi
ls -la
echo "Files in gh-pages:"
find . -type f
- name: Commit and push to gh-pages
working-directory: ./gh-pages
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git remote add origin https://github.com/${{ github.repository }}.git || true
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
git add .
if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "Release chart version ${{ env.CHART_VERSION }} [skip ci]"
git push origin gh-pages --force
fi
- name: Create Git tag
if: steps.check-tag.outputs.exists == 'false'
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag -a "${{ steps.check-tag.outputs.tag }}" -m "Release ${{ env.CHART_NAME }} chart version ${{ env.CHART_VERSION }}"
git push origin "${{ steps.check-tag.outputs.tag }}"
- name: Create GitHub Release
if: steps.check-tag.outputs.exists == 'false'
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.check-tag.outputs.tag }}
name: "${{ env.CHART_NAME }} Chart v${{ env.CHART_VERSION }}"
body: ${{ steps.release-notes.outputs.notes }}
draft: false
prerelease: false
files: |
tron/${{ env.CHART_FILE }}