Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
169 changes: 64 additions & 105 deletions .github/workflows/manual-chart-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ on:
default: 'hoppscotch'
options:
- hoppscotch
dry_run:
description: 'Dry run mode - test without making changes'
required: false
type: boolean
default: false

jobs:
manual-chart-release:
Expand All @@ -60,15 +55,6 @@ jobs:
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: Show Dry Run Status
run: |
if [ "${{ github.event.inputs.dry_run }}" = "true" ]; then
echo "DRY RUN MODE - No changes will be made"
echo "This will test all steps without modifying files or creating releases"
else
echo "LIVE MODE - Changes will be made and release will be created"
fi

- name: Validate Inputs
run: |
CHART_VERSION="${{ github.event.inputs.chart_version }}"
Expand All @@ -78,62 +64,43 @@ jobs:
echo "Chart Version: $CHART_VERSION"
echo "App Version: ${{ github.event.inputs.app_version }}"
echo "Release Type: ${{ github.event.inputs.release_type }}"
echo "Dry Run: ${{ github.event.inputs.dry_run }}"

if [[ ! "$CHART_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Invalid chart version format. Use semantic versioning (e.g., 0.2.0)"
echo "ERROR: Invalid chart version format. Use semantic versioning (e.g., 0.2.0)"
exit 1
fi

if [ ! -f "charts/$CHART_NAME/Chart.yaml" ]; then
echo "Chart not found: charts/$CHART_NAME/Chart.yaml"
echo "ERROR: Chart not found: charts/$CHART_NAME/Chart.yaml"
exit 1
fi

CURRENT_VERSION=$(yq eval '.version' "charts/$CHART_NAME/Chart.yaml")
echo "Current chart version: $CURRENT_VERSION"
echo "New chart version: $CHART_VERSION"

if [ "$CURRENT_VERSION" = "$CHART_VERSION" ]; then
echo "Warning: New version is the same as current version"
echo "WARNING: New version is the same as current version"
fi

- name: Update Chart.yaml (Dry Run Preview)
if: github.event.inputs.dry_run == 'true'
- 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"

echo "DRY RUN: Showing what changes would be made to $CHART_FILE"
echo "Current content:"
cat "$CHART_FILE"
echo ""
echo "Changes that would be made:"

# Create temporary file to show changes
cp "$CHART_FILE" "$CHART_FILE.temp"
yq eval '.version = "'$CHART_VERSION'"' -i "$CHART_FILE.temp"
yq eval '.appVersion = "'$APP_VERSION'"' -i "$CHART_FILE.temp"

diff "$CHART_FILE" "$CHART_FILE.temp" || true
rm "$CHART_FILE.temp"

echo "Chart.yaml validation passed (dry run)"

- name: Update Chart.yaml (Live Mode)
if: github.event.inputs.dry_run != 'true'
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
Expand All @@ -146,104 +113,96 @@ jobs:
echo "Building chart dependencies for charts/$CHART_NAME..."
cd charts/$CHART_NAME

echo "Chart dependencies:"
cat Chart.yaml | grep -A 10 "dependencies:"
if grep -q "dependencies:" Chart.yaml; then
echo "Chart dependencies found:"
cat Chart.yaml | grep -A 10 "dependencies:"

echo "Building dependencies from OCI repositories..."
helm dependency build
echo ""
echo "Building dependencies from OCI repositories..."
helm dependency build

echo "Chart dependencies built successfully"
echo "Downloaded dependencies:"
ls -la charts/ || echo "No charts directory found yet"
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!"
echo "Chart validation passed"

- name: Commit Changes (Dry Run Preview)
if: github.event.inputs.dry_run == 'true'
run: |
echo "DRY RUN: Would commit with message:"
echo "Release ${{ github.event.inputs.chart_name }} chart v${{ github.event.inputs.chart_version }}"
echo ""
echo "Files that would be staged:"
echo " charts/${{ github.event.inputs.chart_name }}/Chart.yaml"

- name: Commit Changes (Live Mode)
if: github.event.inputs.dry_run != 'true'
- 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 "Release $CHART_NAME chart v$CHART_VERSION"

- name: Push Changes (Live Mode Only)
if: github.event.inputs.dry_run != 'true' && env.skip_release != 'true'
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 (Live Mode Only)
if: github.event.inputs.dry_run != 'true' && env.skip_release != 'true'
- name: Wait for Release Workflow
if: env.skip_release != 'true'
run: |
echo "Waiting for automatic release workflow to process the Chart.yaml change..."
sleep 30
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 [ "${{ github.event.inputs.dry_run }}" = "true" ]; then
echo "DRY RUN COMPLETED SUCCESSFULLY!"
if [ "${{ env.skip_release }}" = "true" ]; then
echo "No release created - no changes detected"
else
echo "Chart Release Initiated Successfully"
echo ""
echo "All validations passed. The workflow would:"
echo "Update Chart.yaml with version $CHART_VERSION"
echo "Update appVersion to ${{ github.event.inputs.app_version }}"
echo "Commit changes to main branch"
echo "Trigger automatic release workflow"
echo "Chart: ${{ github.event.inputs.chart_name }}"
echo "Version: $CHART_VERSION"
echo "Type: $RELEASE_TYPE"
echo "App Version: ${{ github.event.inputs.app_version }}"
echo ""
echo "To perform actual release, run again with 'Dry run mode' unchecked"
else
if [ "${{ env.skip_release }}" = "true" ]; then
echo "No release created - no changes detected"
else
echo "Chart Release Completed 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 ""
echo "The automatic release workflow will create the actual GitHub release."
echo "Check the Actions tab for the 'Release charts' workflow."
echo ""
echo "Users can install with:"
echo " helm repo update"
echo " helm install my-hoppscotch hoppscotch/hoppscotch --version $CHART_VERSION"
fi
fi

- name: Failure Summary
if: failure()
run: |
if [ "${{ github.event.inputs.dry_run }}" = "true" ]; then
echo "DRY RUN FAILED!"
echo "Issues found during testing - fix these before doing a live release"
else
echo "Chart Release Failed!"
fi
echo "Chart Release Failed"
echo ""
echo "Please check the logs above for details."
echo ""
echo "Common issues:"
echo " 1. Invalid version format"
echo " 2. Chart validation errors"
echo " 3. Git configuration issues"
echo " 4. Missing chart files"
echo " - Invalid version format (must be X.Y.Z)"
echo " - Chart validation errors"
echo " - Git configuration issues"
echo " - Missing chart files"
echo " - Dependency build failures"
65 changes: 65 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
name: Release charts

on:
push:
branches:
- main
paths:
- "charts/*/Chart.yaml"

jobs:
release:
permissions:
Expand All @@ -15,12 +17,75 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"

- name: Setup Helm
uses: azure/setup-helm@v4
with:
version: v3.14.4

- name: Build Chart Dependencies
run: |
echo "Building dependencies for all charts..."
for chart_dir in charts/*/; do
if [ -f "${chart_dir}Chart.yaml" ]; then
chart_name=$(basename "$chart_dir")
echo ""
echo "Processing chart: $chart_name"
cd "${chart_dir}"

if grep -q "dependencies:" Chart.yaml; then
echo " Dependencies found, building..."
helm dependency build
echo " Dependencies built successfully"

if [ -d "charts" ]; then
echo " Downloaded dependencies:"
ls -la charts/
fi
else
echo " No dependencies to build"
fi

cd - > /dev/null
fi
done
echo ""
echo "All chart dependencies built"

- name: Run chart-releaser
uses: helm/[email protected]
env:
CR_SKIP_EXISTING: true
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
with:
charts_dir: charts

- name: Success Summary
if: success()
run: |
echo "Chart release completed successfully"
echo ""
echo "The following actions were completed:"
echo " - Chart dependencies built"
echo " - Charts packaged"
echo " - GitHub releases created"
echo " - Helm repository index updated"
echo ""

- name: Failure Summary
if: failure()
run: |
echo "Chart release failed"
echo ""
echo "Common issues:"
echo " - Dependency build failures"
echo " - Invalid chart structure"
echo " - GitHub token permissions"
echo " - Duplicate release version"
echo ""
echo "Check the logs above for specific error details"
6 changes: 6 additions & 0 deletions charts/hoppscotch/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Helm dependency charts
charts/*.tgz
Chart.lock

# Backup files
*.backup