Fix Gitea workflow to use Gitea-specific variables and APIs

- Replaced GitHub-specific variables with Gitea equivalents
- Changed GITHUB_REF to GITEA_REF_NAME for tag extraction
- Replaced github.sha with gitea.sha for commit reference
- Removed GitHub release action, using Gitea API directly
- Fixed environment variable references to use proper syntax
- Removed GITHUB_STEP_SUMMARY as it's GitHub-specific
- Updated all VERSION references to use environment variable
This commit is contained in:
d.viti
2025-10-03 02:06:54 +02:00
parent fd832e9b42
commit 733826890e

View File

@@ -32,26 +32,28 @@ jobs:
VERSION="${{ github.event.inputs.version }}"
else
# Extract version from tag (remove 'v' prefix)
VERSION=${GITHUB_REF#refs/tags/v}
VERSION=${GITEA_REF_NAME#v}
fi
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
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: ${{ steps.version.outputs.VERSION }}/" helm/api7ee/Chart.yaml
sed -i "s/^version:.*/version: ${VERSION}/" helm/api7ee/Chart.yaml
# Update appVersion to match
sed -i "s/^appVersion:.*/appVersion: \"${{ steps.version.outputs.VERSION }}\"/" helm/api7ee/Chart.yaml
sed -i "s/^appVersion:.*/appVersion: \"${VERSION}\"/" helm/api7ee/Chart.yaml
# Update image tags in values.yaml to use this version
sed -i "s|tag: \"main\"|tag: \"v${{ steps.version.outputs.VERSION }}\"|g" helm/api7ee/values.yaml
sed -i "s|tag: \"main\"|tag: \"v${VERSION}\"|g" helm/api7ee/values.yaml
# Update registry to Gitea URL
sed -i "s|registry: gitea.server_url|registry: ${{ gitea.server_url }}|g" helm/api7ee/values.yaml
echo "📝 Updated Chart.yaml and values.yaml with version ${{ steps.version.outputs.VERSION }}"
echo "📝 Updated Chart.yaml and values.yaml with version ${VERSION}"
- name: Lint Helm chart
run: |
@@ -59,12 +61,12 @@ jobs:
- name: Package Helm chart
run: |
helm package helm/api7ee/ --version ${{ steps.version.outputs.VERSION }}
echo "CHART_FILE=api7ee-${{ steps.version.outputs.VERSION }}.tgz" >> $GITHUB_ENV
helm package helm/api7ee/ --version ${VERSION}
echo "CHART_FILE=api7ee-${VERSION}.tgz" >> $GITHUB_ENV
# Generate chart README with installation instructions
cat > CHART_README.md << EOF
# API7 Enterprise Edition Helm Chart v${{ steps.version.outputs.VERSION }}
# API7 Enterprise Edition Helm Chart v${VERSION}
## Installation
@@ -74,23 +76,23 @@ jobs:
helm repo update
# Install the chart
helm install my-api7ee api7ee/api7ee --version ${{ steps.version.outputs.VERSION }}
helm install my-api7ee api7ee/api7ee --version ${VERSION}
# Install with custom values
helm install my-api7ee api7ee/api7ee --version ${{ steps.version.outputs.VERSION }} -f values.yaml
helm install my-api7ee api7ee/api7ee --version ${VERSION} -f values.yaml
\`\`\`
## Upgrade
\`\`\`bash
helm upgrade my-api7ee api7ee/api7ee --version ${{ steps.version.outputs.VERSION }}
helm upgrade my-api7ee api7ee/api7ee --version ${VERSION}
\`\`\`
## Docker Images
This chart uses the following Docker images:
- Web: \`${{ gitea.server_url }}/${{ gitea.repository }}/web:v${{ steps.version.outputs.VERSION }}\`
- API: \`${{ gitea.server_url }}/${{ gitea.repository }}/api:v${{ steps.version.outputs.VERSION }}\`
- 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
@@ -102,46 +104,68 @@ jobs:
-F "chart=@${CHART_FILE}" \
https://${{ gitea.server_url }}/api/packages/${{ gitea.repository_owner }}/helm/api/charts
echo "✅ Helm chart v${{ steps.version.outputs.VERSION }} pushed to Gitea Package Registry"
echo "✅ Helm chart v${VERSION} pushed to Gitea Package Registry"
- name: Create Release
uses: softprops/action-gh-release@v1
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
with:
files: |
${{ env.CHART_FILE }}
CHART_README.md
generate_release_notes: true
body: |
## Helm Chart Release v${{ steps.version.outputs.VERSION }}
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 --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-${VERSION}.tgz](https://${{ gitea.server_url }}/${{ gitea.repository }}/releases/download/v${VERSION}/api7ee-${VERSION}.tgz)",
"draft": false,
"prerelease": false
}
EOF
)
### Installation
```bash
helm repo add api7ee https://${{ gitea.server_url }}/api/packages/${{ gitea.repository_owner }}/helm
helm repo update
helm install my-api7ee api7ee/api7ee --version ${{ steps.version.outputs.VERSION }}
```
# 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")
### Docker Images
- Web: `${{ gitea.server_url }}/${{ gitea.repository }}/web:v${{ steps.version.outputs.VERSION }}`
- API: `${{ gitea.server_url }}/${{ gitea.repository }}/api:v${{ steps.version.outputs.VERSION }}`
# Get release ID
RELEASE_ID=$(echo $RELEASE_RESPONSE | jq -r '.id')
### Changes
See the full changelog below.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
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-${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" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Version:** v${{ steps.version.outputs.VERSION }}" >> $GITHUB_STEP_SUMMARY
echo "- **Chart:** ${CHART_FILE}" >> $GITHUB_STEP_SUMMARY
echo "- **Registry:** https://${{ gitea.server_url }}/api/packages/${{ gitea.repository_owner }}/helm" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Installation Commands" >> $GITHUB_STEP_SUMMARY
echo '```bash' >> $GITHUB_STEP_SUMMARY
echo "helm repo add api7ee https://${{ gitea.server_url }}/api/packages/${{ gitea.repository_owner }}/helm" >> $GITHUB_STEP_SUMMARY
echo "helm repo update" >> $GITHUB_STEP_SUMMARY
echo "helm install my-api7ee api7ee/api7ee --version ${{ steps.version.outputs.VERSION }}" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
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 --version ${VERSION}"
echo '```'