- Changed chart name from api7ee to api7ee-demo-k8s in Chart.yaml
- Renamed helm/api7ee directory to helm/api7ee-demo-k8s
- Updated all references in build.yml workflow
- Updated all references in helm-release.yml workflow
- Updated main README.md with new chart name
- Updated Helm chart README with new chart name
- Verified all old references have been replaced
- Chart packages correctly as api7ee-demo-k8s-{version}.tgz
169 lines
6.6 KiB
YAML
169 lines
6.6 KiB
YAML
name: Helm Chart Release
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
release-helm:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Install Helm
|
|
uses: azure/setup-helm@v3
|
|
with:
|
|
version: "latest"
|
|
|
|
- name: Determine version
|
|
id: version
|
|
run: |
|
|
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
|
VERSION="${{ github.event.inputs.version }}"
|
|
else
|
|
# Extract version from tag (remove 'v' prefix)
|
|
VERSION=${GITEA_REF_NAME#v}
|
|
fi
|
|
echo "VERSION=${VERSION}"
|
|
# Export for subsequent steps
|
|
echo "VERSION=${VERSION}" >> $GITHUB_ENV
|
|
echo "📌 Chart version: ${VERSION}"
|
|
|
|
- name: Update Chart version
|
|
run: |
|
|
# Update Chart.yaml with the new version
|
|
sed -i "s/^version:.*/version: ${VERSION}/" helm/api7ee-demo-k8s/Chart.yaml
|
|
|
|
# Update appVersion to match
|
|
sed -i "s/^appVersion:.*/appVersion: \"${VERSION}\"/" helm/api7ee-demo-k8s/Chart.yaml
|
|
|
|
# Update image tags in values.yaml to use this version
|
|
sed -i "s|tag: \"main\"|tag: \"v${VERSION}\"|g" helm/api7ee-demo-k8s/values.yaml
|
|
|
|
# Update registry and repository to Gitea values
|
|
sed -i "s|registry: gitea.server_url|registry: ${{ gitea.server_url }}|g" helm/api7ee-demo-k8s/values.yaml
|
|
sed -i "s|repository: gitea.repository/|repository: ${{ gitea.repository }}/|g" helm/api7ee-demo-k8s/values.yaml
|
|
|
|
echo "📝 Updated Chart.yaml and values.yaml with version ${VERSION}"
|
|
|
|
- name: Lint Helm chart
|
|
run: |
|
|
helm lint helm/api7ee-demo-k8s/
|
|
|
|
- name: Package Helm chart
|
|
run: |
|
|
helm package helm/api7ee-demo-k8s/ --version ${VERSION}
|
|
echo "CHART_FILE=api7ee-demo-k8s-${VERSION}.tgz" >> $GITHUB_ENV
|
|
|
|
# Generate chart README with installation instructions
|
|
cat > CHART_README.md << EOF
|
|
# API7 Enterprise Edition Helm Chart v${VERSION}
|
|
|
|
## Installation
|
|
|
|
\`\`\`bash
|
|
# Add the Helm repository
|
|
helm repo add api7ee https://${{ gitea.server_url }}/api/packages/${{ gitea.repository_owner }}/helm
|
|
helm repo update
|
|
|
|
# Install the chart
|
|
helm install my-api7ee api7ee/api7ee-demo-k8s --version ${VERSION}
|
|
|
|
# Install with custom values
|
|
helm install my-api7ee api7ee/api7ee-demo-k8s --version ${VERSION} -f values.yaml
|
|
\`\`\`
|
|
|
|
## Upgrade
|
|
|
|
\`\`\`bash
|
|
helm upgrade my-api7ee api7ee/api7ee-demo-k8s --version ${VERSION}
|
|
\`\`\`
|
|
|
|
## Docker Images
|
|
|
|
This chart uses the following Docker images:
|
|
- Web: \`${{ gitea.server_url }}/${{ gitea.repository }}/web:v${VERSION}\`
|
|
- API: \`${{ gitea.server_url }}/${{ gitea.repository }}/api:v${VERSION}\`
|
|
EOF
|
|
|
|
- name: Push Helm chart to Gitea Package Registry
|
|
run: |
|
|
# Upload versioned Helm chart
|
|
curl --fail-with-body \
|
|
-H "Authorization: token ${{ secrets.PACKAGES_PUSH_TOKEN }}" \
|
|
-X POST \
|
|
-F "chart=@${CHART_FILE}" \
|
|
https://${{ gitea.server_url }}/api/packages/${{ gitea.repository_owner }}/helm/api/charts
|
|
|
|
echo "✅ Helm chart v${VERSION} pushed to Gitea Package Registry"
|
|
|
|
- name: Create Release
|
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
|
run: |
|
|
# Create release using Gitea API
|
|
RELEASE_DATA=$(cat <<EOF
|
|
{
|
|
"tag_name": "v${VERSION}",
|
|
"target_commitish": "${{ gitea.sha }}",
|
|
"name": "v${VERSION}",
|
|
"body": "## Helm Chart Release v${VERSION}\n\n### Installation\n\`\`\`bash\nhelm repo add api7ee https://${{ gitea.server_url }}/api/packages/${{ gitea.repository_owner }}/helm\nhelm repo update\nhelm install my-api7ee api7ee/api7ee-demo-k8s --version ${VERSION}\n\`\`\`\n\n### Docker Images\n- Web: \`${{ gitea.server_url }}/${{ gitea.repository }}/web:v${VERSION}\`\n- API: \`${{ gitea.server_url }}/${{ gitea.repository }}/api:v${VERSION}\`\n\n### Chart Package\n- Download: [api7ee-demo-k8s-${VERSION}.tgz](https://${{ gitea.server_url }}/${{ gitea.repository }}/releases/download/v${VERSION}/api7ee-demo-k8s-${VERSION}.tgz)",
|
|
"draft": false,
|
|
"prerelease": false
|
|
}
|
|
EOF
|
|
)
|
|
|
|
# Create the release
|
|
RELEASE_RESPONSE=$(curl -X POST \
|
|
-H "Authorization: token ${{ secrets.PACKAGES_PUSH_TOKEN }}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "${RELEASE_DATA}" \
|
|
"https://${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/releases")
|
|
|
|
# Get release ID
|
|
RELEASE_ID=$(echo $RELEASE_RESPONSE | jq -r '.id')
|
|
|
|
if [ "$RELEASE_ID" != "null" ] && [ -n "$RELEASE_ID" ]; then
|
|
echo "✅ Release created with ID: $RELEASE_ID"
|
|
|
|
# Upload chart file as release asset
|
|
curl -X POST \
|
|
-H "Authorization: token ${{ secrets.PACKAGES_PUSH_TOKEN }}" \
|
|
-H "Content-Type: application/gzip" \
|
|
--data-binary "@${CHART_FILE}" \
|
|
"https://${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/releases/${RELEASE_ID}/assets?name=api7ee-demo-k8s-${VERSION}.tgz"
|
|
|
|
# Upload README as release asset
|
|
curl -X POST \
|
|
-H "Authorization: token ${{ secrets.PACKAGES_PUSH_TOKEN }}" \
|
|
-H "Content-Type: text/markdown" \
|
|
--data-binary "@CHART_README.md" \
|
|
"https://${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/releases/${RELEASE_ID}/assets?name=CHART_README.md"
|
|
|
|
echo "✅ Release assets uploaded successfully"
|
|
else
|
|
echo "⚠️ Failed to create release"
|
|
echo "Response: $RELEASE_RESPONSE"
|
|
fi
|
|
|
|
- name: Summary
|
|
run: |
|
|
echo "## 🎉 Helm Chart Release Summary"
|
|
echo ""
|
|
echo "- **Version:** v${VERSION}"
|
|
echo "- **Chart:** ${CHART_FILE}"
|
|
echo "- **Registry:** https://${{ gitea.server_url }}/api/packages/${{ gitea.repository_owner }}/helm"
|
|
echo ""
|
|
echo "### Installation Commands"
|
|
echo '```bash'
|
|
echo "helm repo add api7ee https://${{ gitea.server_url }}/api/packages/${{ gitea.repository_owner }}/helm"
|
|
echo "helm repo update"
|
|
echo "helm install my-api7ee api7ee/api7ee-demo-k8s --version ${VERSION}"
|
|
echo '```'
|