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:
@@ -32,26 +32,28 @@ jobs:
|
|||||||
VERSION="${{ github.event.inputs.version }}"
|
VERSION="${{ github.event.inputs.version }}"
|
||||||
else
|
else
|
||||||
# Extract version from tag (remove 'v' prefix)
|
# Extract version from tag (remove 'v' prefix)
|
||||||
VERSION=${GITHUB_REF#refs/tags/v}
|
VERSION=${GITEA_REF_NAME#v}
|
||||||
fi
|
fi
|
||||||
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
|
echo "VERSION=${VERSION}"
|
||||||
|
# Export for subsequent steps
|
||||||
|
echo "VERSION=${VERSION}" >> $GITHUB_ENV
|
||||||
echo "📌 Chart version: ${VERSION}"
|
echo "📌 Chart version: ${VERSION}"
|
||||||
|
|
||||||
- name: Update Chart version
|
- name: Update Chart version
|
||||||
run: |
|
run: |
|
||||||
# Update Chart.yaml with the new version
|
# 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
|
# 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
|
# 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
|
# Update registry to Gitea URL
|
||||||
sed -i "s|registry: gitea.server_url|registry: ${{ gitea.server_url }}|g" helm/api7ee/values.yaml
|
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
|
- name: Lint Helm chart
|
||||||
run: |
|
run: |
|
||||||
@@ -59,12 +61,12 @@ jobs:
|
|||||||
|
|
||||||
- name: Package Helm chart
|
- name: Package Helm chart
|
||||||
run: |
|
run: |
|
||||||
helm package helm/api7ee/ --version ${{ steps.version.outputs.VERSION }}
|
helm package helm/api7ee/ --version ${VERSION}
|
||||||
echo "CHART_FILE=api7ee-${{ steps.version.outputs.VERSION }}.tgz" >> $GITHUB_ENV
|
echo "CHART_FILE=api7ee-${VERSION}.tgz" >> $GITHUB_ENV
|
||||||
|
|
||||||
# Generate chart README with installation instructions
|
# Generate chart README with installation instructions
|
||||||
cat > CHART_README.md << EOF
|
cat > CHART_README.md << EOF
|
||||||
# API7 Enterprise Edition Helm Chart v${{ steps.version.outputs.VERSION }}
|
# API7 Enterprise Edition Helm Chart v${VERSION}
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
@@ -74,23 +76,23 @@ jobs:
|
|||||||
helm repo update
|
helm repo update
|
||||||
|
|
||||||
# Install the chart
|
# 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
|
# 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
|
## Upgrade
|
||||||
|
|
||||||
\`\`\`bash
|
\`\`\`bash
|
||||||
helm upgrade my-api7ee api7ee/api7ee --version ${{ steps.version.outputs.VERSION }}
|
helm upgrade my-api7ee api7ee/api7ee --version ${VERSION}
|
||||||
\`\`\`
|
\`\`\`
|
||||||
|
|
||||||
## Docker Images
|
## Docker Images
|
||||||
|
|
||||||
This chart uses the following Docker images:
|
This chart uses the following Docker images:
|
||||||
- Web: \`${{ gitea.server_url }}/${{ gitea.repository }}/web:v${{ steps.version.outputs.VERSION }}\`
|
- Web: \`${{ gitea.server_url }}/${{ gitea.repository }}/web:v${VERSION}\`
|
||||||
- API: \`${{ gitea.server_url }}/${{ gitea.repository }}/api:v${{ steps.version.outputs.VERSION }}\`
|
- API: \`${{ gitea.server_url }}/${{ gitea.repository }}/api:v${VERSION}\`
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
- name: Push Helm chart to Gitea Package Registry
|
- name: Push Helm chart to Gitea Package Registry
|
||||||
@@ -102,46 +104,68 @@ jobs:
|
|||||||
-F "chart=@${CHART_FILE}" \
|
-F "chart=@${CHART_FILE}" \
|
||||||
https://${{ gitea.server_url }}/api/packages/${{ gitea.repository_owner }}/helm/api/charts
|
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
|
- name: Create Release
|
||||||
uses: softprops/action-gh-release@v1
|
|
||||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||||
with:
|
run: |
|
||||||
files: |
|
# Create release using Gitea API
|
||||||
${{ env.CHART_FILE }}
|
RELEASE_DATA=$(cat <<EOF
|
||||||
CHART_README.md
|
{
|
||||||
generate_release_notes: true
|
"tag_name": "v${VERSION}",
|
||||||
body: |
|
"target_commitish": "${{ gitea.sha }}",
|
||||||
## Helm Chart Release v${{ steps.version.outputs.VERSION }}
|
"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
|
# Create the release
|
||||||
```bash
|
RELEASE_RESPONSE=$(curl -X POST \
|
||||||
helm repo add api7ee https://${{ gitea.server_url }}/api/packages/${{ gitea.repository_owner }}/helm
|
-H "Authorization: token ${{ secrets.PACKAGES_PUSH_TOKEN }}" \
|
||||||
helm repo update
|
-H "Content-Type: application/json" \
|
||||||
helm install my-api7ee api7ee/api7ee --version ${{ steps.version.outputs.VERSION }}
|
-d "${RELEASE_DATA}" \
|
||||||
```
|
"https://${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/releases")
|
||||||
|
|
||||||
### Docker Images
|
# Get release ID
|
||||||
- Web: `${{ gitea.server_url }}/${{ gitea.repository }}/web:v${{ steps.version.outputs.VERSION }}`
|
RELEASE_ID=$(echo $RELEASE_RESPONSE | jq -r '.id')
|
||||||
- API: `${{ gitea.server_url }}/${{ gitea.repository }}/api:v${{ steps.version.outputs.VERSION }}`
|
|
||||||
|
|
||||||
### Changes
|
if [ "$RELEASE_ID" != "null" ] && [ -n "$RELEASE_ID" ]; then
|
||||||
See the full changelog below.
|
echo "✅ Release created with ID: $RELEASE_ID"
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
# 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
|
- name: Summary
|
||||||
run: |
|
run: |
|
||||||
echo "## 🎉 Helm Chart Release Summary" >> $GITHUB_STEP_SUMMARY
|
echo "## 🎉 Helm Chart Release Summary"
|
||||||
echo "" >> $GITHUB_STEP_SUMMARY
|
echo ""
|
||||||
echo "- **Version:** v${{ steps.version.outputs.VERSION }}" >> $GITHUB_STEP_SUMMARY
|
echo "- **Version:** v${VERSION}"
|
||||||
echo "- **Chart:** ${CHART_FILE}" >> $GITHUB_STEP_SUMMARY
|
echo "- **Chart:** ${CHART_FILE}"
|
||||||
echo "- **Registry:** https://${{ gitea.server_url }}/api/packages/${{ gitea.repository_owner }}/helm" >> $GITHUB_STEP_SUMMARY
|
echo "- **Registry:** https://${{ gitea.server_url }}/api/packages/${{ gitea.repository_owner }}/helm"
|
||||||
echo "" >> $GITHUB_STEP_SUMMARY
|
echo ""
|
||||||
echo "### Installation Commands" >> $GITHUB_STEP_SUMMARY
|
echo "### Installation Commands"
|
||||||
echo '```bash' >> $GITHUB_STEP_SUMMARY
|
echo '```bash'
|
||||||
echo "helm repo add api7ee https://${{ gitea.server_url }}/api/packages/${{ gitea.repository_owner }}/helm" >> $GITHUB_STEP_SUMMARY
|
echo "helm repo add api7ee https://${{ gitea.server_url }}/api/packages/${{ gitea.repository_owner }}/helm"
|
||||||
echo "helm repo update" >> $GITHUB_STEP_SUMMARY
|
echo "helm repo update"
|
||||||
echo "helm install my-api7ee api7ee/api7ee --version ${{ steps.version.outputs.VERSION }}" >> $GITHUB_STEP_SUMMARY
|
echo "helm install my-api7ee api7ee/api7ee --version ${VERSION}"
|
||||||
echo '```' >> $GITHUB_STEP_SUMMARY
|
echo '```'
|
||||||
Reference in New Issue
Block a user