Skip to content

Manual Chart Release #13

Manual Chart Release

Manual Chart Release #13

name: Manual Chart Release
on:
workflow_dispatch:
inputs:
chart_version:
description: 'New chart version (e.g., 0.2.0)'
required: true
type: string
app_version:
description: 'App version compatibility (e.g., 2025.8.1)'
required: true
type: string
release_type:
description: 'Type of release'
required: true
type: choice
default: 'minor'
options:
- patch
- minor
- major
- hotfix
release_notes:
description: 'Release notes (what changed in the chart)'
required: false
type: string
default: 'Manual chart release'
chart_name:
description: 'Chart name to release'
required: true
type: choice
default: 'hoppscotch'
options:
- hoppscotch
- she
- shc
jobs:
manual-chart-release:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Install yq
run: |
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
sudo chmod +x /usr/local/bin/yq
- name: Validate Inputs
run: |
CHART_VERSION="${{ github.event.inputs.chart_version }}"
CHART_NAME="${{ github.event.inputs.chart_name }}"
echo "Validating inputs..."
echo "Chart: $CHART_NAME"
echo "Chart Version: $CHART_VERSION"
echo "App Version: ${{ github.event.inputs.app_version }}"
echo "Release Type: ${{ github.event.inputs.release_type }}"
# Validate semantic versioning format
if [[ ! "$CHART_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "ERROR: Invalid chart version format. Use semantic versioning (e.g., 0.2.0)"
exit 1
fi
# Check if chart exists
if [ ! -f "charts/$CHART_NAME/Chart.yaml" ]; then
echo "ERROR: Chart not found: charts/$CHART_NAME/Chart.yaml"
exit 1
fi
# Get current version and compare
CURRENT_VERSION=$(yq eval '.version' "charts/$CHART_NAME/Chart.yaml")
echo "Current chart version: $CURRENT_VERSION"
echo "New chart version: $CHART_VERSION"
# Prevent same version release
if [ "$CURRENT_VERSION" = "$CHART_VERSION" ]; then
echo "ERROR: New version must be different from current version"
echo "Current version in Chart.yaml: $CURRENT_VERSION"
echo "Requested version: $CHART_VERSION"
echo ""
echo "Please increment the version number before releasing."
exit 1
fi
# Check if version is being incremented (not decremented)
IFS='.' read -ra CURR <<< "$CURRENT_VERSION"
IFS='.' read -ra NEW <<< "$CHART_VERSION"
CURRENT_NUM=$((CURR[0] * 10000 + CURR[1] * 100 + CURR[2]))
NEW_NUM=$((NEW[0] * 10000 + NEW[1] * 100 + NEW[2]))
if [ $NEW_NUM -le $CURRENT_NUM ]; then
echo "ERROR: New version ($CHART_VERSION) must be greater than current version ($CURRENT_VERSION)"
echo ""
echo "Semantic versioning requires incrementing version numbers."
exit 1
fi
echo "Version validation passed"
- name: Update Chart.yaml
run: |
CHART_NAME="${{ github.event.inputs.chart_name }}"
CHART_VERSION="${{ github.event.inputs.chart_version }}"
APP_VERSION="${{ github.event.inputs.app_version }}"
CHART_FILE="charts/$CHART_NAME/Chart.yaml"
cp "$CHART_FILE" "$CHART_FILE.backup"
yq eval '.version = "'$CHART_VERSION'"' -i "$CHART_FILE"
yq eval '.appVersion = "'$APP_VERSION'"' -i "$CHART_FILE"
echo "Updated $CHART_FILE:"
echo " Chart version: $CHART_VERSION"
echo " App version: $APP_VERSION"
echo ""
echo "Changes made:"
diff "$CHART_FILE.backup" "$CHART_FILE" || true
rm "$CHART_FILE.backup"
- name: Setup Helm
uses: azure/setup-helm@v4
with:
version: v3.14.4
- name: Build Chart Dependencies
run: |
CHART_NAME="${{ github.event.inputs.chart_name }}"
echo "Building chart dependencies for charts/$CHART_NAME..."
cd charts/$CHART_NAME
if grep -q "dependencies:" Chart.yaml; then
echo "Chart dependencies found:"
cat Chart.yaml | grep -A 10 "dependencies:"
echo ""
echo "Building dependencies from OCI repositories..."
helm dependency build
echo "Chart dependencies built successfully"
if [ -d "charts" ]; then
echo "Downloaded dependencies:"
ls -la charts/
fi
else
echo "No dependencies defined in Chart.yaml"
fi
- name: Validate Chart
run: |
CHART_NAME="${{ github.event.inputs.chart_name }}"
echo "Testing template generation..."
helm template test-release charts/$CHART_NAME > /dev/null
echo "Chart validation passed"
- name: Commit Changes
run: |
CHART_NAME="${{ github.event.inputs.chart_name }}"
CHART_VERSION="${{ github.event.inputs.chart_version }}"
APP_VERSION="${{ github.event.inputs.app_version }}"
RELEASE_TYPE="${{ github.event.inputs.release_type }}"
RELEASE_NOTES="${{ github.event.inputs.release_notes }}"
git add charts/$CHART_NAME/Chart.yaml
if git diff --staged --quiet; then
echo "No changes to commit"
echo "skip_release=true" >> $GITHUB_ENV
exit 0
fi
git commit -m "chore(release): bump $CHART_NAME chart to v$CHART_VERSION" \
-m "App version: $APP_VERSION" \
-m "Release type: $RELEASE_TYPE" \
-m "$RELEASE_NOTES"
- name: Push Changes
if: env.skip_release != 'true'
run: |
echo "Pushing changes to main branch..."
git push origin main
echo "Changes pushed successfully"
- name: Wait for Release Workflow
if: env.skip_release != 'true'
run: |
echo "Waiting for automatic release workflow to trigger..."
echo "The 'Release charts' workflow will:"
echo " 1. Build chart dependencies"
echo " 2. Package the chart"
echo " 3. Create GitHub release"
echo " 4. Update Helm repository index"
sleep 10
- name: Success Summary
run: |
CHART_VERSION="${{ github.event.inputs.chart_version }}"
RELEASE_TYPE="${{ github.event.inputs.release_type }}"
if [ "${{ env.skip_release }}" = "true" ]; then
echo "No release created - no changes detected"
else
echo "Chart Release Initiated Successfully"
echo ""
echo "Chart: ${{ github.event.inputs.chart_name }}"
echo "Version: $CHART_VERSION"
echo "Type: $RELEASE_TYPE"
echo "App Version: ${{ github.event.inputs.app_version }}"
echo ""
fi
- name: Failure Summary
if: failure()
run: |
echo "Chart Release Failed"
echo ""
echo "Please check the logs above for details."
echo ""
echo "Common issues:"
echo " - Invalid version format (must be X.Y.Z)"
echo " - Version not incremented properly"
echo " - Chart validation errors"
echo " - Git configuration issues"
echo " - Missing chart files"
echo " - Dependency build failures"